@@ -1,6 +1,6 @@ | |||||
<?xml version="1.0" encoding="ASCII"?> | <?xml version="1.0" encoding="ASCII"?> | ||||
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_Lw_ZsEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.application"> | <application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_Lw_ZsEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.application"> | ||||
<children xsi:type="basic:TrimmedWindow" xmi:id="_QDxdgEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.trimmedwindow.main" label="BGG Tool Another" width="700" height="700"> | |||||
<children xsi:type="basic:TrimmedWindow" xmi:id="_QDxdgEqSEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.trimmedwindow.main" label="BGG Tool Another" width="700" height="800"> | |||||
<children xsi:type="basic:PartStack" xmi:id="_uw_Z4F9REeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.partstack.0"> | <children xsi:type="basic:PartStack" xmi:id="_uw_Z4F9REeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.partstack.0"> | ||||
<children xsi:type="basic:Part" xmi:id="_co2toF9CEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.batmain" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BatMain" label="Home"/> | <children xsi:type="basic:Part" xmi:id="_co2toF9CEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.batmain" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BatMain" label="Home"/> | ||||
<children xsi:type="basic:Part" xmi:id="_JsfvUF9YEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.fetch" visible="false" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.FetchPart" label="Fetch"> | <children xsi:type="basic:Part" xmi:id="_JsfvUF9YEeuvNqpgCDWpdQ" elementId="xyz.veronie.bgg.ui.part.fetch" visible="false" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.FetchPart" label="Fetch"> | ||||
@@ -14,8 +14,10 @@ import org.eclipse.jface.viewers.IStructuredSelection; | |||||
import org.eclipse.jface.viewers.SelectionChangedEvent; | import org.eclipse.jface.viewers.SelectionChangedEvent; | ||||
import org.eclipse.jface.viewers.StructuredSelection; | import org.eclipse.jface.viewers.StructuredSelection; | ||||
import org.eclipse.swt.SWT; | import org.eclipse.swt.SWT; | ||||
import org.eclipse.swt.custom.ScrolledComposite; | |||||
import org.eclipse.swt.events.FocusAdapter; | import org.eclipse.swt.events.FocusAdapter; | ||||
import org.eclipse.swt.events.FocusEvent; | import org.eclipse.swt.events.FocusEvent; | ||||
import org.eclipse.swt.layout.FillLayout; | |||||
import org.eclipse.swt.layout.GridData; | import org.eclipse.swt.layout.GridData; | ||||
import org.eclipse.swt.layout.GridLayout; | import org.eclipse.swt.layout.GridLayout; | ||||
import org.eclipse.swt.widgets.Combo; | import org.eclipse.swt.widgets.Combo; | ||||
@@ -82,27 +84,39 @@ public class BggUserSourceFilter { | |||||
}); | }); | ||||
Composite centerComposite = new Composite(main, SWT.NONE); | |||||
centerComposite.setLayout(new GridLayout(1, false)); | |||||
centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); | |||||
// centerComposite.setLayout(new FillLayout(SWT.VERTICAL)); | |||||
Composite bottomComposite = new Composite(main, SWT.NONE); | |||||
bottomComposite.setLayout(new GridLayout(1, false)); | |||||
bottomComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | |||||
Label infoLabel = new Label(centerComposite, SWT.LEFT); | |||||
Label infoLabel = new Label(bottomComposite, SWT.LEFT); | |||||
infoLabel.setText("Select which flags are used as filter. Filters follow 'AND' rule."); | infoLabel.setText("Select which flags are used as filter. Filters follow 'AND' rule."); | ||||
GridData gdInfo = new GridData(SWT.FILL, SWT.FILL, true, false); | GridData gdInfo = new GridData(SWT.FILL, SWT.FILL, true, false); | ||||
gdInfo.horizontalSpan = 2; | |||||
infoLabel.setLayoutData(gdInfo); | infoLabel.setLayoutData(gdInfo); | ||||
new FilterFlagComposite(centerComposite, UserFlag.OWN, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.PREORDERED, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.WISHLIST, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.WTB, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.WTP, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.WANT, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.PREVIOUSLY_OWNED, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.PLAYED, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.TRADE, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.RATED, configManager, eventBroker); | |||||
new FilterFlagComposite(centerComposite, UserFlag.COMMENT, configManager, eventBroker); | |||||
// ScrolledComposite flagsComposite = new ScrolledComposite(mainComposite, SWT.V_SCROLL); | |||||
// flagsComposite.setMinHeight(300); | |||||
// flagsComposite.setExpandVertical(true); | |||||
// flagsComposite.setExpandHorizontal(true); | |||||
// flagsComposite.setAlwaysShowScrollBars(false); | |||||
// //flagsComposite.setLayout(new FillLayout(SWT.VERTICAL)); | |||||
Composite flagsComposite = new Composite(bottomComposite, SWT.NONE); | |||||
flagsComposite.setLayout(new GridLayout(2, false)); | |||||
flagsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.OWN, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.PREORDERED, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.WISHLIST, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.WTB, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.WTP, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.WANT, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.PREVIOUSLY_OWNED, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.PLAYED, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.TRADE, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.RATED, configManager, eventBroker); | |||||
new FilterFlagComposite(flagsComposite, UserFlag.COMMENT, configManager, eventBroker); | |||||
parent.pack(); | parent.pack(); | ||||
parent.layout(true, true); | parent.layout(true, true); | ||||
@@ -2,6 +2,8 @@ package xyz.veronie.bgg.ui.filters.composites; | |||||
import org.eclipse.e4.core.services.events.IEventBroker; | import org.eclipse.e4.core.services.events.IEventBroker; | ||||
import org.eclipse.swt.SWT; | import org.eclipse.swt.SWT; | ||||
import org.eclipse.swt.events.MouseEvent; | |||||
import org.eclipse.swt.events.MouseListener; | |||||
import org.eclipse.swt.events.SelectionAdapter; | import org.eclipse.swt.events.SelectionAdapter; | ||||
import org.eclipse.swt.events.SelectionEvent; | import org.eclipse.swt.events.SelectionEvent; | ||||
import org.eclipse.swt.layout.GridData; | import org.eclipse.swt.layout.GridData; | ||||
@@ -18,7 +20,7 @@ import xyz.veronie.bgg.types.UserFlagEvent; | |||||
public class FilterFlagComposite extends Composite { | public class FilterFlagComposite extends Composite { | ||||
private Button btnFlagSwitch; | |||||
private SwitchLabel flagSwitch; | |||||
/** | /** | ||||
* Create the composite. | * Create the composite. | ||||
@@ -41,15 +43,16 @@ public class FilterFlagComposite extends Composite { | |||||
btnCheckFlag.setText(flag.toString()); | btnCheckFlag.setText(flag.toString()); | ||||
btnCheckFlag.setSelection(isTurnedOn); | btnCheckFlag.setSelection(isTurnedOn); | ||||
GridData gd_btnCheckFlag = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); | GridData gd_btnCheckFlag = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); | ||||
gd_btnCheckFlag.widthHint = 100; | |||||
gd_btnCheckFlag.widthHint = 120; | |||||
btnCheckFlag.setLayoutData(gd_btnCheckFlag); | btnCheckFlag.setLayoutData(gd_btnCheckFlag); | ||||
btnFlagSwitch = new Button(this, SWT.TOGGLE); | |||||
GridData gd_btnFlagSwitch = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); | |||||
gd_btnFlagSwitch.widthHint = 30; | |||||
flagSwitch = new SwitchLabel(this, SWT.NONE); | |||||
flagSwitch.setOnImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_switch on_30x30.png")); | |||||
flagSwitch.setOffImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_switch off_30x30.png")); | |||||
btnFlagSwitch.setEnabled(isTurnedOn); | |||||
flagSwitch.setEnabled(isTurnedOn); | |||||
if(isTurnedOn) { | if(isTurnedOn) { | ||||
if(flagState.equals(FilterFlagState.IS)) { | if(flagState.equals(FilterFlagState.IS)) { | ||||
setSwitchOn(); | setSwitchOn(); | ||||
@@ -60,15 +63,21 @@ public class FilterFlagComposite extends Composite { | |||||
setSwitchOn(); | setSwitchOn(); | ||||
} | } | ||||
btnFlagSwitch.addSelectionListener(new SelectionAdapter() { | |||||
flagSwitch.addMouseListener(new MouseListener() { | |||||
@Override | @Override | ||||
public void widgetSelected(SelectionEvent e) { | |||||
Button source = (Button)e.getSource(); | |||||
public void mouseDoubleClick(MouseEvent e) { | |||||
} | |||||
@Override | |||||
public void mouseDown(MouseEvent e) { | |||||
} | |||||
@Override | |||||
public void mouseUp(MouseEvent e) { | |||||
UserFlagEvent ufe = new UserFlagEvent(); | UserFlagEvent ufe = new UserFlagEvent(); | ||||
ufe.flag = flag; | ufe.flag = flag; | ||||
boolean isSelected = source.getSelection(); | |||||
boolean isSelected = !flagSwitch.getState(); | |||||
if(isSelected) { | if(isSelected) { | ||||
ufe.state = FilterFlagState.IS; | ufe.state = FilterFlagState.IS; | ||||
setSwitchOn(); | setSwitchOn(); | ||||
@@ -95,14 +104,14 @@ public class FilterFlagComposite extends Composite { | |||||
if(!isSelected) { | if(!isSelected) { | ||||
ufe.state = FilterFlagState.IGNORE; | ufe.state = FilterFlagState.IGNORE; | ||||
setSwitchOn(); | setSwitchOn(); | ||||
btnFlagSwitch.setEnabled(false); | |||||
flagSwitch.setEnabled(false); | |||||
} else { | } else { | ||||
if(btnFlagSwitch.getSelection()) { | |||||
if(flagSwitch.getState()) { | |||||
ufe.state = FilterFlagState.IS; | ufe.state = FilterFlagState.IS; | ||||
} else { | } else { | ||||
ufe.state = FilterFlagState.ISNOT; | ufe.state = FilterFlagState.ISNOT; | ||||
} | } | ||||
btnFlagSwitch.setEnabled(true); | |||||
flagSwitch.setEnabled(true); | |||||
} | } | ||||
eventBroker.send(EventConstants.TOPIC_USERFLAG_CHANGED, ufe); | eventBroker.send(EventConstants.TOPIC_USERFLAG_CHANGED, ufe); | ||||
} | } | ||||
@@ -113,12 +122,10 @@ public class FilterFlagComposite extends Composite { | |||||
} | } | ||||
private void setSwitchOn() { | private void setSwitchOn() { | ||||
btnFlagSwitch.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_switch on_30x30.png")); | |||||
btnFlagSwitch.setSelection(true); | |||||
flagSwitch.setState(true); | |||||
} | } | ||||
private void setSwitchOff() { | private void setSwitchOff() { | ||||
btnFlagSwitch.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_switch off_30x30.png")); | |||||
btnFlagSwitch.setSelection(false); | |||||
flagSwitch.setState(false); | |||||
} | } | ||||
@@ -0,0 +1,60 @@ | |||||
package xyz.veronie.bgg.ui.filters.composites; | |||||
import org.eclipse.swt.SWT; | |||||
import org.eclipse.swt.events.MouseListener; | |||||
import org.eclipse.swt.graphics.Image; | |||||
import org.eclipse.swt.layout.RowLayout; | |||||
import org.eclipse.swt.widgets.Composite; | |||||
import org.eclipse.swt.widgets.Label; | |||||
public class SwitchLabel extends Composite { | |||||
private Label label; | |||||
private boolean isTurnedOn; | |||||
private Image imageOn; | |||||
private Image imageOff; | |||||
public SwitchLabel(Composite parent, int style) { | |||||
super(parent, style); | |||||
this.setLayout(new RowLayout()); | |||||
label = new Label(this, SWT.None); | |||||
isTurnedOn = false; | |||||
} | |||||
/// set image for switch off state | |||||
public void setOnImage(Image imageOn) { | |||||
this.imageOn = imageOn; | |||||
} | |||||
/// set image for switch on state | |||||
public void setOffImage(Image imageOff) { | |||||
this.imageOff = imageOff; | |||||
} | |||||
/// Set switch state: true = on, false = off | |||||
public void setState(boolean isTurnedOn) { | |||||
this.isTurnedOn = isTurnedOn; | |||||
setSwitchImage(); | |||||
} | |||||
/// Get the switch state: true = on, false = off | |||||
public boolean getState() { | |||||
return isTurnedOn; | |||||
} | |||||
private void setSwitchImage() { | |||||
label.setImage(isTurnedOn ? imageOn : imageOff); | |||||
pack(); | |||||
layout(); | |||||
} | |||||
@Override | |||||
public void addMouseListener(MouseListener listener) { | |||||
label.addMouseListener(listener); | |||||
} | |||||
@Override | |||||
public void setEnabled(boolean enabled) { | |||||
label.setEnabled(enabled); | |||||
} | |||||
} |
@@ -45,7 +45,6 @@ import xyz.veronie.bgg.ui.helpers.BatColors; | |||||
import xyz.veronie.bgg.ui.helpers.BatLayouts; | import xyz.veronie.bgg.ui.helpers.BatLayouts; | ||||
// TODO: layout of user flags | |||||
// TODO: load thing list from DB | // TODO: load thing list from DB | ||||
// TODO: image sizes | // TODO: image sizes | ||||
// TODO: display current thinglist name | // TODO: display current thinglist name | ||||
@@ -55,6 +54,7 @@ import xyz.veronie.bgg.ui.helpers.BatLayouts; | |||||
// TODO: handle thing list overwrite | // TODO: handle thing list overwrite | ||||
// TODO: Display selection details on game | // TODO: Display selection details on game | ||||
// TODO: cache family/geeklist descriptions | // TODO: cache family/geeklist descriptions | ||||
// TODO: allow different screen scalings | |||||
@SuppressWarnings("restriction") | @SuppressWarnings("restriction") | ||||
public class BatMain { | public class BatMain { | ||||