| @@ -0,0 +1,11 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <projectDescription> | |||
| <name>BggToolAnother</name> | |||
| <comment></comment> | |||
| <projects> | |||
| </projects> | |||
| <buildSpec> | |||
| </buildSpec> | |||
| <natures> | |||
| </natures> | |||
| </projectDescription> | |||
| @@ -1,34 +1,34 @@ | |||
| <?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:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" 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="1200" height="800"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_B_h_UEqVEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.0"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_tbnr0EqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.main" horizontal="true"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_4NsHQEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.bggload"> | |||
| <children xsi:type="basic:PartStack" xmi:id="_7KNiwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partstack.bggloadconf" containerData="1000"> | |||
| <children xsi:type="basic:Part" xmi:id="_9ocfwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.part.resultconfig" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.LoadFromBggPart" label="Load IDs from BGG"/> | |||
| </children> | |||
| <children xsi:type="basic:PartStack" xmi:id="_7hQw0EqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partstack.bggresult" containerData="1000"> | |||
| <children xsi:type="basic:Part" xmi:id="_97XbwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.part.resulttable" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BggResultPart" label="BGG Result"/> | |||
| </children> | |||
| </children> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_AF1vQEqUEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.gamelist"> | |||
| <children xsi:type="basic:PartStack" xmi:id="_0MbRQEqTEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.partstack.gameslistconf"> | |||
| <children xsi:type="basic:Part" xmi:id="_-Mdy0EqTEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.part.gamesconfig" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.LoadThingDetailsPart" label="Load game details"/> | |||
| </children> | |||
| <children xsi:type="basic:PartStack" xmi:id="_CS1yUEqUEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.partstack.gameslist"> | |||
| <children xsi:type="basic:Part" xmi:id="_Ckm3wEqUEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.part.gamestable" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.ThingListPart" label="Games list"/> | |||
| </children> | |||
| </children> | |||
| </children> | |||
| <children xsi:type="advanced:Area" xmi:id="_8nEs4EqUEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.area.status" containerData="100" label="Status"/> | |||
| </children> | |||
| <mainMenu xmi:id="_wtXeQEs0EeqGDvPDavxXPQ" elementId="org.eclipse.ui.main.menu"/> | |||
| </children> | |||
| <addons xmi:id="_Lw_ZsUqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/> | |||
| <addons xmi:id="_Lw_ZskqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/> | |||
| <addons xmi:id="_Lw_Zs0qSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/> | |||
| <addons xmi:id="_Lw_ZtEqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/> | |||
| <addons xmi:id="_Lw_ZtUqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/> | |||
| <addons xmi:id="_Lw_ZtkqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/> | |||
| <addons xmi:id="_Lw_Zt0qSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/> | |||
| </application:Application> | |||
| <?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:advanced="http://www.eclipse.org/ui/2010/UIModel/application/ui/advanced" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" 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="1200" height="800"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_B_h_UEqVEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.0"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_tbnr0EqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.main" horizontal="true"> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_4NsHQEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.bggload"> | |||
| <children xsi:type="basic:PartStack" xmi:id="_7KNiwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partstack.bggloadconf" containerData="1000"> | |||
| <children xsi:type="basic:Part" xmi:id="_9ocfwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.part.resultconfig" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.LoadFromBggPart" label="Load IDs from BGG"/> | |||
| </children> | |||
| <children xsi:type="basic:PartStack" xmi:id="_7hQw0EqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partstack.bggresult" containerData="1000"> | |||
| <children xsi:type="basic:Part" xmi:id="_97XbwEqTEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.part.resulttable" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.BggResultPart" label="BGG Result"/> | |||
| </children> | |||
| </children> | |||
| <children xsi:type="basic:PartSashContainer" xmi:id="_AF1vQEqUEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.partsashcontainer.gamelist"> | |||
| <children xsi:type="basic:PartStack" xmi:id="_0MbRQEqTEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.partstack.gameslistconf"> | |||
| <children xsi:type="basic:Part" xmi:id="_-Mdy0EqTEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.part.gamesconfig" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.LoadThingDetailsPart" label="Load game details"/> | |||
| </children> | |||
| <children xsi:type="basic:PartStack" xmi:id="_CS1yUEqUEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.partstack.gameslist"> | |||
| <children xsi:type="basic:Part" xmi:id="_Ckm3wEqUEeqT5sxfmvJ5Tg" elementId="de.wt.bgg.ui.part.gamestable" contributionURI="bundleclass://xyz.veronie.bgg.ui/xyz.veronie.bgg.ui.parts.ThingListPart" label="Games list"/> | |||
| </children> | |||
| </children> | |||
| </children> | |||
| <children xsi:type="advanced:Area" xmi:id="_8nEs4EqUEeqT5sxfmvJ5Tg" elementId="xyz.veronie.bgg.ui.area.status" containerData="100" label="Status"/> | |||
| </children> | |||
| <mainMenu xmi:id="_wtXeQEs0EeqGDvPDavxXPQ" elementId="org.eclipse.ui.main.menu"/> | |||
| </children> | |||
| <addons xmi:id="_Lw_ZsUqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/> | |||
| <addons xmi:id="_Lw_ZskqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/> | |||
| <addons xmi:id="_Lw_Zs0qSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/> | |||
| <addons xmi:id="_Lw_ZtEqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/> | |||
| <addons xmi:id="_Lw_ZtUqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/> | |||
| <addons xmi:id="_Lw_ZtkqSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/> | |||
| <addons xmi:id="_Lw_Zt0qSEeqT5sxfmvJ5Tg" elementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/> | |||
| </application:Application> | |||
| @@ -0,0 +1,21 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| public class AgeSourceFilter { | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label empty = new Label(parent, SWT.LEFT); | |||
| empty.setText("not implemented yet"); | |||
| empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| parent.layout(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,6 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| /// this represents a result of bgg "things" | |||
| public class BggResult { | |||
| } | |||
| @@ -0,0 +1,160 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import java.util.HashMap; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.events.FocusEvent; | |||
| import org.eclipse.swt.events.FocusListener; | |||
| import org.eclipse.swt.events.SelectionAdapter; | |||
| import org.eclipse.swt.events.SelectionEvent; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Button; | |||
| import org.eclipse.swt.widgets.Combo; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| enum FilterState { | |||
| IS(0), ISNOT(1), IGNORE(2); | |||
| private int state; | |||
| private FilterState(int state) { | |||
| this.state = state; | |||
| } | |||
| public int get() { | |||
| return this.state; | |||
| } | |||
| } | |||
| enum UserFlag { | |||
| OWN("owned"), | |||
| PREVIOUSLY_OWNED("previously owned"), | |||
| FOR_TRADE("for trade"), | |||
| WANTED("wanted"), | |||
| WTP("want to play"), | |||
| WTB("want to buy"), | |||
| WISHLIST("on wishlist"), | |||
| PREORDERED("preordered"); | |||
| private String flag; | |||
| private UserFlag(String flag) { | |||
| this.flag = flag; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.flag; | |||
| } | |||
| } | |||
| /// These are the controls to retrieve thing IDs for a given BGG user | |||
| /// Filters can be set for the state of the thing in the user's collection | |||
| /// (i.e. owned, previously owned, wishlist, etc.) | |||
| public class BggUserSourceFilter { | |||
| // TODO: have to protect this static because threading? | |||
| private static String user = ""; | |||
| private static HashMap<UserFlag, FilterState> flags = new HashMap<UserFlag, FilterState>() { | |||
| private static final long serialVersionUID = 1L; | |||
| { | |||
| put(UserFlag.OWN, FilterState.IS); | |||
| put(UserFlag.PREVIOUSLY_OWNED, FilterState.ISNOT); | |||
| put(UserFlag.FOR_TRADE, FilterState.IGNORE); | |||
| put(UserFlag.WANTED, FilterState.IGNORE); | |||
| put(UserFlag.WTP, FilterState.IGNORE); | |||
| put(UserFlag.WTB, FilterState.IGNORE); | |||
| put(UserFlag.WISHLIST, FilterState.IGNORE); | |||
| put(UserFlag.PREORDERED, FilterState.IGNORE); | |||
| }}; | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(4, false); | |||
| parent.setLayout(filterLayout); | |||
| Label lblUser = new Label(parent, SWT.LEFT); | |||
| lblUser.setText("User name: "); | |||
| lblUser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Combo cbUserName = new Combo(parent, SWT.DROP_DOWN); | |||
| cbUserName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| cbUserName.addSelectionListener(new SelectionAdapter() { | |||
| public void widgetDefaultSelected(SelectionEvent e) { | |||
| setUser(cbUserName.getText()); | |||
| System.out.println("set user to '" + getUser() + "'"); | |||
| } | |||
| }); | |||
| cbUserName.addFocusListener(new FocusListener() { | |||
| @Override | |||
| public void focusLost(FocusEvent e) { | |||
| setUser(cbUserName.getText()); | |||
| } | |||
| @Override | |||
| public void focusGained(FocusEvent e) { | |||
| // nothing | |||
| } | |||
| }); | |||
| Button btEditUsers = new Button(parent, SWT.PUSH); | |||
| btEditUsers.setText("edit users"); | |||
| btEditUsers.setEnabled(false); | |||
| btEditUsers.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| // TODO: implement edit users | |||
| Label infoLabel = new Label(parent, SWT.LEFT); | |||
| infoLabel.setText("Select which flags are used as filter. Filters follow 'AND' rule."); | |||
| GridData gdInfo = new GridData(SWT.FILL, SWT.FILL, true, false); | |||
| gdInfo.horizontalSpan = 4; | |||
| infoLabel.setLayoutData(gdInfo); | |||
| makeFilter(parent, UserFlag.OWN); | |||
| makeFilter(parent, UserFlag.WTP); | |||
| makeFilter(parent, UserFlag.PREVIOUSLY_OWNED); | |||
| makeFilter(parent, UserFlag.WTB); | |||
| makeFilter(parent, UserFlag.FOR_TRADE); | |||
| makeFilter(parent, UserFlag.WISHLIST); | |||
| makeFilter(parent, UserFlag.WANTED); | |||
| makeFilter(parent, UserFlag.PREORDERED); | |||
| parent.layout(); | |||
| } | |||
| /// Create a control for a filter. | |||
| // Filters are tri-state: include iff has flag, include iff it does not have the flag, | |||
| // don't care if it has that flag. | |||
| // TODO: create a three-way toggle button instead. | |||
| private static void makeFilter(Composite parent, UserFlag key) { | |||
| Combo filterCombo = new Combo(parent, SWT.READ_ONLY); | |||
| filterCombo.add("is"); | |||
| filterCombo.add("is not"); | |||
| filterCombo.add("ignored"); | |||
| filterCombo.select(flags.get(key).get()); | |||
| filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Label filterLabel = new Label(parent, SWT.LEFT); | |||
| filterLabel.setText(key.toString()); | |||
| filterLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| } | |||
| public static String getUser() { | |||
| return user; | |||
| } | |||
| public static void setUser(String user) { | |||
| BggUserSourceFilter.user = user; | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.events.FocusEvent; | |||
| import org.eclipse.swt.events.FocusListener; | |||
| import org.eclipse.swt.events.SelectionAdapter; | |||
| import org.eclipse.swt.events.SelectionEvent; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Combo; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| /// These are the controls to retrieve thing IDs for a given family ID | |||
| public class FamilySourceFilter { | |||
| private static int familyId; | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label lblFamily = new Label(parent, SWT.LEFT); | |||
| lblFamily.setText("Family ID: "); | |||
| lblFamily.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Combo cbFamilyId = new Combo(parent, SWT.DROP_DOWN); | |||
| cbFamilyId.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| cbFamilyId.addSelectionListener(new SelectionAdapter() { | |||
| public void widgetDefaultSelected(SelectionEvent e) { | |||
| setFamilyId(Integer.getInteger(cbFamilyId.getText())); | |||
| System.out.println("set geeklist id to '" + getFamilyId() + "'"); | |||
| } | |||
| }); | |||
| cbFamilyId.addFocusListener(new FocusListener() { | |||
| @Override | |||
| public void focusLost(FocusEvent e) { | |||
| setFamilyId(Integer.getInteger(cbFamilyId.getText())); | |||
| System.out.println("set geeklist id to '" + getFamilyId() + "'"); | |||
| } | |||
| @Override | |||
| public void focusGained(FocusEvent e) { | |||
| // nothing | |||
| } | |||
| }); | |||
| parent.layout(); | |||
| } | |||
| public static int getFamilyId() { | |||
| return familyId; | |||
| } | |||
| public static void setFamilyId(int familyId) { | |||
| FamilySourceFilter.familyId = familyId; | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.events.FocusEvent; | |||
| import org.eclipse.swt.events.FocusListener; | |||
| import org.eclipse.swt.events.SelectionAdapter; | |||
| import org.eclipse.swt.events.SelectionEvent; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Combo; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| /// These are the controls to retrieve thing IDs for a given family ID | |||
| public class GeeklistSourceFilter { | |||
| private static Integer geeklistId; | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label lblGeeklist = new Label(parent, SWT.LEFT); | |||
| lblGeeklist.setText("Geeklist ID: "); | |||
| lblGeeklist.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Combo cbGeeklistId = new Combo(parent, SWT.DROP_DOWN); | |||
| cbGeeklistId.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| cbGeeklistId.addSelectionListener(new SelectionAdapter() { | |||
| public void widgetDefaultSelected(SelectionEvent e) { | |||
| setGeeklistId(Integer.getInteger(cbGeeklistId.getText())); | |||
| System.out.println("set geeklist id to '" + getGeeklistId() + "'"); | |||
| } | |||
| }); | |||
| cbGeeklistId.addFocusListener(new FocusListener() { | |||
| @Override | |||
| public void focusLost(FocusEvent e) { | |||
| setGeeklistId(Integer.getInteger(cbGeeklistId.getText())); | |||
| System.out.println("set geeklist id to '" + getGeeklistId() + "'"); | |||
| } | |||
| @Override | |||
| public void focusGained(FocusEvent e) { | |||
| // nothing | |||
| } | |||
| }); | |||
| parent.layout(); | |||
| } | |||
| public static Integer getGeeklistId() { | |||
| return geeklistId; | |||
| } | |||
| public static void setGeeklistId(Integer geeklistId) { | |||
| GeeklistSourceFilter.geeklistId = geeklistId; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| public class RankSourceFilter { | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label empty = new Label(parent, SWT.LEFT); | |||
| empty.setText("not implemented yet"); | |||
| empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| parent.layout(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| public enum ResultAction { | |||
| ADD("add"), | |||
| REP("replace"), | |||
| SUB("subtract"), | |||
| AND("and"), | |||
| MIS("mis"); | |||
| private String name; | |||
| private ResultAction(String name) { | |||
| this.name = name; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| /// container for configuration of result download | |||
| public class ResultConfig { | |||
| // TODO: integrate different filters (or extend?) | |||
| private SourceFilter source; | |||
| private Subpage subpage; | |||
| private ResultAction action; | |||
| public SourceFilter getSource() { | |||
| return source; | |||
| } | |||
| public void setSource(SourceFilter source) { | |||
| this.source = source; | |||
| } | |||
| public Subpage getSubpage() { | |||
| return subpage; | |||
| } | |||
| public void setSubpage(Subpage subpage) { | |||
| this.subpage = subpage; | |||
| } | |||
| public ResultAction getAction() { | |||
| return action; | |||
| } | |||
| public void setAction(ResultAction action) { | |||
| this.action = action; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| public class SearchSourceFilter { | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label empty = new Label(parent, SWT.LEFT); | |||
| empty.setText("not implemented yet"); | |||
| empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| parent.layout(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,24 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| public enum SourceFilter { | |||
| BGG_USER("from BGG user"), //< by bgg user name (additional filters apply) | |||
| GEEKLIST("from geeklist"), //< by geeklist id | |||
| FAMILY("from family"), //< by family id | |||
| RANK("by rank"), //< filter by rank | |||
| YEAR("by year"), //< filter by year | |||
| AGE("by age"), //< by age (w.r.t. publishing date) | |||
| SEARCH("search"); //< more complex search by name and other filters | |||
| private String name; | |||
| private SourceFilter(String name) { | |||
| this.name = name; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return name; | |||
| } | |||
| } | |||
| @@ -1,86 +0,0 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Button; | |||
| import org.eclipse.swt.widgets.Combo; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Group; | |||
| import org.eclipse.swt.widgets.Label; | |||
| /// These are the controls to retrieve IDs for a given BGG user | |||
| /// Filters can be set for the state of the thing in the user's collection | |||
| /// (i.e. owned, previously owned, wishlist, etc.) | |||
| public class SourceFilterBggUser extends Composite { | |||
| public SourceFilterBggUser(final Composite parent, int style) { | |||
| super(parent, style); | |||
| Group gFilters = new Group(parent, SWT.SHADOW_ETCHED_IN); | |||
| gFilters.setText(""); | |||
| GridData gdFilters = new GridData(SWT.FILL, SWT.FILL, true, true); | |||
| gFilters.setLayoutData(gdFilters); | |||
| GridLayout filterLayout = new GridLayout(4, false); | |||
| gFilters.setLayout(filterLayout); | |||
| Label lblUser = new Label(gFilters, SWT.LEFT); | |||
| lblUser.setText("User name: "); | |||
| lblUser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Combo cbUserName = new Combo(gFilters, SWT.DROP_DOWN); | |||
| cbUserName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Button btEditUsers = new Button(gFilters, SWT.PUSH); | |||
| btEditUsers.setText("edit users"); | |||
| btEditUsers.setEnabled(false); | |||
| btEditUsers.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| // TODO: implement edit users | |||
| Label infoLabel = new Label(gFilters, SWT.LEFT); | |||
| infoLabel.setText("Select which flags are used as filter. Filters follow 'AND' rule."); | |||
| GridData gdInfo = new GridData(SWT.FILL, SWT.FILL, true, false); | |||
| gdInfo.horizontalSpan = 4; | |||
| infoLabel.setLayoutData(gdInfo); | |||
| makeFilter(gFilters, "owned", 1); | |||
| makeFilter(gFilters, "want to play", 2); | |||
| makeFilter(gFilters, "previously owned", 2); | |||
| makeFilter(gFilters, "want to buy", 2); | |||
| makeFilter(gFilters, "for trade", 0); | |||
| makeFilter(gFilters, "wishlist", 2); | |||
| makeFilter(gFilters, "wanted", 2); | |||
| makeFilter(gFilters, "preordered", 2); | |||
| this.requestLayout(); | |||
| } | |||
| /// Create a control for a filter. | |||
| // Filters are tristate: include iff has flag, include iff it does not have the flag, | |||
| // don't care if it has that flag. | |||
| // TODO: create a three-way toggle button instead. | |||
| private void makeFilter(Composite parent, String filterName, int defaultIdx) { | |||
| Combo filterCombo = new Combo(parent, SWT.READ_ONLY); | |||
| filterCombo.add("ignored"); | |||
| filterCombo.add("is"); | |||
| filterCombo.add("is not"); | |||
| filterCombo.select(defaultIdx); | |||
| filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Label filterLabel = new Label(parent, SWT.LEFT); | |||
| filterLabel.setText(filterName); | |||
| filterLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| } | |||
| public String toString() { | |||
| return "from BGG user"; | |||
| } | |||
| } | |||
| @@ -1,37 +0,0 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Combo; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Group; | |||
| import org.eclipse.swt.widgets.Label; | |||
| public class SourceFilterGeeklist extends Composite { | |||
| public SourceFilterGeeklist(final Composite parent, int style) { | |||
| super(parent, style); | |||
| Group gFilters = new Group(parent, SWT.SHADOW_ETCHED_IN); | |||
| gFilters.setText("Filters"); | |||
| GridData gdFilters = new GridData(SWT.FILL, SWT.FILL, true, true); | |||
| gFilters.setLayoutData(gdFilters); | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| gFilters.setLayout(filterLayout); | |||
| Label lblGeeklist = new Label(gFilters, SWT.LEFT); | |||
| lblGeeklist.setText("Geeklist ID: "); | |||
| lblGeeklist.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| Combo cbGeeklistId = new Combo(gFilters, SWT.DROP_DOWN); | |||
| cbGeeklistId.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| this.requestLayout(); | |||
| } | |||
| public String toString() { | |||
| return "from Geeklist"; | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| public enum Subpage { | |||
| BOARDGAMES("Board Games"), | |||
| RPG("RPGs"), | |||
| RPG_ITEMS("RPG Items"), | |||
| VIDEOGAMES("Video Games"), | |||
| ACCESSORIES("Accessories"); | |||
| private String name; | |||
| private Subpage(String name) { | |||
| this.name = name; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.name; | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package xyz.veronie.bgg.ui.contributions; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| public class YearSourceFilter { | |||
| public static void create(Composite parent, int style) { | |||
| GridLayout filterLayout = new GridLayout(2, false); | |||
| parent.setLayout(filterLayout); | |||
| Label empty = new Label(parent, SWT.LEFT); | |||
| empty.setText("not implemented yet"); | |||
| empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| parent.layout(); | |||
| } | |||
| } | |||
| @@ -3,6 +3,7 @@ package xyz.veronie.bgg.ui.parts; | |||
| import javax.annotation.PostConstruct; | |||
| import org.eclipse.swt.SWT; | |||
| import org.eclipse.swt.layout.GridData; | |||
| //import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Label; | |||
| @@ -11,9 +12,11 @@ public class BggResultPart { | |||
| @PostConstruct | |||
| public void createControls(Composite parent) { | |||
| //GridData tableGrid = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); | |||
| Label lblTable = new Label(parent, SWT.LEFT); | |||
| Composite main = new Composite(parent, SWT.FILL); | |||
| Label lblTable = new Label(main, SWT.LEFT); | |||
| lblTable.setText("I am a table"); | |||
| //lblTable.setLayoutData(tableGrid); | |||
| lblTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | |||
| } | |||
| } | |||
| @@ -19,73 +19,43 @@ import org.eclipse.swt.layout.GridData; | |||
| import org.eclipse.swt.layout.GridLayout; | |||
| import org.eclipse.swt.widgets.Button; | |||
| import org.eclipse.swt.widgets.Composite; | |||
| import org.eclipse.swt.widgets.Control; | |||
| import org.eclipse.swt.widgets.Display; | |||
| import org.eclipse.swt.widgets.Group; | |||
| import org.eclipse.swt.widgets.Label; | |||
| import xyz.veronie.bgg.ui.contributions.SourceFilterBggUser; | |||
| import xyz.veronie.bgg.ui.contributions.SourceFilterGeeklist; | |||
| import xyz.veronie.bgg.ui.contributions.AgeSourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.BggUserSourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.FamilySourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.GeeklistSourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.RankSourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.ResultAction; | |||
| import xyz.veronie.bgg.ui.contributions.SearchSourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.SourceFilter; | |||
| import xyz.veronie.bgg.ui.contributions.Subpage; | |||
| import xyz.veronie.bgg.ui.contributions.YearSourceFilter; | |||
| /// Has controls to download a list of thing IDs (+some meta info) from BGG. | |||
| /// There are different ways to configure which IDs to retrieve. | |||
| public class LoadFromBggPart { | |||
| private Composite parent; | |||
| private Composite filterComposite; //< current composite that is shown in filter area | |||
| /// show different filter controls depending on selection in cbSource ComboViewer | |||
| public void showFilter(IStructuredSelection selection) { | |||
| String elem = (String) selection.getFirstElement(); | |||
| // we already have the selected filter area in place, do nothing | |||
| if(filterComposite != null && filterComposite.toString() == elem) { | |||
| return; | |||
| } | |||
| // if we need a different filter area, dispose the old one before creating a new one | |||
| if(filterComposite != null) { | |||
| filterComposite.dispose(); | |||
| } | |||
| // now that we know the composite is either null or a different one from the one already shown, | |||
| // and the old one was disposed above, create the new one: | |||
| if(elem == "from BGG user") { | |||
| System.out.println("construct " + elem); | |||
| filterComposite = new SourceFilterBggUser(parent, SWT.FILL); | |||
| filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | |||
| parent.requestLayout(); | |||
| } else if (elem == "from geeklist") { | |||
| System.out.println("construct " + elem); | |||
| filterComposite = new SourceFilterGeeklist(parent, SWT.FILL); | |||
| filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); | |||
| parent.requestLayout(); | |||
| } else { | |||
| System.out.println("construct " + elem + " (not implemented yet, try another one)"); | |||
| } | |||
| } | |||
| public static Display getDisplay() { | |||
| Display display = Display.getCurrent(); | |||
| // may be null if outside the UI thread | |||
| if (display == null) | |||
| display = Display.getDefault(); | |||
| return display; | |||
| } | |||
| @PostConstruct | |||
| public void createControls(Composite parent) { | |||
| this.parent = parent; | |||
| Composite main = new Composite(parent, SWT.FILL); | |||
| main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| // TODO: where do I define this properly? child setting the layout of its parent doesn't feel right | |||
| GridLayout layout = new GridLayout(2, false); | |||
| parent.setLayout(layout); | |||
| main.setLayout(layout); | |||
| // contains configuration options for download of the bgg thing ID list | |||
| Group dlConfigGroup = new Group(parent, SWT.SHADOW_ETCHED_IN); | |||
| GridData configGrid = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL); | |||
| Group dlConfigGroup = new Group(main, SWT.SHADOW_ETCHED_IN); | |||
| GridData configGrid = new GridData(SWT.FILL, SWT.FILL, true, true); | |||
| dlConfigGroup.setText("Configure download..."); | |||
| dlConfigGroup.setLayoutData(configGrid); | |||
| @@ -94,38 +64,32 @@ public class LoadFromBggPart { | |||
| Label lblSource = new Label(dlConfigGroup, SWT.LEFT); | |||
| lblSource.setText("Source: "); | |||
| lblSource.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); | |||
| lblSource.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); | |||
| // choose the bgg data source | |||
| ComboViewer cbSource = new ComboViewer(dlConfigGroup, SWT.READ_ONLY); | |||
| cbSource.setContentProvider(ArrayContentProvider.getInstance()); | |||
| List<String> sources = Arrays.asList(new String[] { "from BGG user", "from geeklist", "from family", "by rank", "by year", "by age", "search"}); | |||
| List<SourceFilter> sources = Arrays.asList(new SourceFilter[] { | |||
| SourceFilter.BGG_USER, SourceFilter.GEEKLIST, SourceFilter.FAMILY, | |||
| SourceFilter.RANK, SourceFilter.YEAR, SourceFilter.AGE, SourceFilter.SEARCH }); | |||
| cbSource.setInput(sources); | |||
| // TODO: implement all the sources | |||
| cbSource.setSelection(new StructuredSelection(sources.get(0))); | |||
| cbSource.addSelectionChangedListener(new ISelectionChangedListener() { | |||
| @Override | |||
| public void selectionChanged(SelectionChangedEvent event) { | |||
| IStructuredSelection selection = (IStructuredSelection) event | |||
| .getSelection(); | |||
| if (selection.size() > 0) { | |||
| showFilter(selection); | |||
| } | |||
| } | |||
| }); | |||
| // choose the bgg sub-site | |||
| Label lblTopic = new Label(dlConfigGroup, SWT.LEFT); | |||
| lblTopic.setText("Subpage: "); | |||
| lblTopic.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); | |||
| lblTopic.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); | |||
| ComboViewer cbTopic = new ComboViewer(dlConfigGroup, SWT.READ_ONLY); | |||
| cbTopic.setContentProvider(ArrayContentProvider.getInstance()); | |||
| List<String> sites = Arrays.asList(new String[] { "Boardgames", "RPGs", "RPG Items", "Videogames", "Accessories" }); | |||
| List<Subpage> sites = Arrays.asList(new Subpage[] { | |||
| Subpage.BOARDGAMES, Subpage.RPG, Subpage.RPG_ITEMS, | |||
| Subpage.VIDEOGAMES, Subpage.ACCESSORIES }); | |||
| cbTopic.setInput(sites); | |||
| cbTopic.setSelection(new StructuredSelection(sites.get(0))); | |||
| @@ -133,23 +97,43 @@ public class LoadFromBggPart { | |||
| // choose action on result list | |||
| Label lblAct = new Label(dlConfigGroup, SWT.LEFT); | |||
| lblAct.setText("Action on result: "); | |||
| lblAct.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); | |||
| lblAct.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); | |||
| ComboViewer cbAct = new ComboViewer(dlConfigGroup, SWT.READ_ONLY); | |||
| cbAct.setContentProvider(ArrayContentProvider.getInstance()); | |||
| List<String> actions = Arrays.asList(new String[] { "add", "replace", "subtract", "AND", "Mis"}); | |||
| List<ResultAction> actions = Arrays.asList(new ResultAction[] { | |||
| ResultAction.ADD, ResultAction.REP, ResultAction.SUB, | |||
| ResultAction.AND, ResultAction.MIS }); | |||
| cbAct.setInput(actions); | |||
| cbAct.setSelection(new StructuredSelection(actions.get(0))); | |||
| // prepare area to display filter controls in | |||
| // filterArea = new Composite(parent, SWT.FILL); | |||
| // filterArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| showFilter((IStructuredSelection)cbSource.getSelection()); // set content to initial selection | |||
| // area to display filter controls in | |||
| Group gFilters = new Group(main, SWT.SHADOW_ETCHED_IN); | |||
| gFilters.setText(""); | |||
| gFilters.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| showFilter(gFilters, (IStructuredSelection)cbSource.getSelection()); // set content to initial selection | |||
| cbSource.addSelectionChangedListener(new ISelectionChangedListener() { // later, its content will be set via the dropdown | |||
| @Override | |||
| public void selectionChanged(SelectionChangedEvent event) { | |||
| IStructuredSelection selection = (IStructuredSelection) event | |||
| .getSelection(); | |||
| if (selection.size() > 0) { | |||
| // ASK: this is strange to me. Why is filterComposite known INSIDE a free function? | |||
| showFilter(gFilters, selection); | |||
| } | |||
| } | |||
| }); | |||
| Label empty = new Label(main, SWT.LEFT); | |||
| empty.setText(""); | |||
| empty.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); | |||
| // Start retrieval when download button is pushed | |||
| Button btDownload = new Button(parent, SWT.PUSH); | |||
| Button btDownload = new Button(main, SWT.PUSH); | |||
| // TODO: how do I locate icons? | |||
| try { | |||
| Image dlIcon = new Image(getDisplay(), | |||
| @@ -162,17 +146,83 @@ public class LoadFromBggPart { | |||
| btDownload.addSelectionListener(new SelectionAdapter() { | |||
| @Override | |||
| public void widgetSelected(SelectionEvent e) { | |||
| System.out.println("Called!"); | |||
| System.out.println("Downloading " + cbSource.getSelection().toString()); | |||
| IStructuredSelection selection = (IStructuredSelection) cbSource.getSelection(); | |||
| if(selection.size() == 0) return; | |||
| if(selection.getFirstElement() == SourceFilter.BGG_USER) { | |||
| if(BggUserSourceFilter.getUser().isEmpty()) { | |||
| System.out.println("Please enter a user name."); | |||
| return; | |||
| } | |||
| System.out.println("...for user '" + BggUserSourceFilter.getUser() + "'"); | |||
| } else if(selection.getFirstElement() == SourceFilter.GEEKLIST) { | |||
| System.out.println("...for geeklist id '" + GeeklistSourceFilter.getGeeklistId() + "'"); | |||
| } else if(selection.getFirstElement() == SourceFilter.FAMILY) { | |||
| System.out.println("...for family id '" + FamilySourceFilter.getFamilyId() + "'"); | |||
| } | |||
| } | |||
| }); | |||
| btDownload.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); | |||
| main.pack(); | |||
| } | |||
| /// show different filter controls depending on selection in cbSource ComboViewer | |||
| public void showFilter(Composite parent, IStructuredSelection selection) { | |||
| SourceFilter elem = (SourceFilter) selection.getFirstElement(); | |||
| // clean up | |||
| for(Control child : parent.getChildren()) { | |||
| child.dispose(); | |||
| } | |||
| // create a new filter area based on selection: | |||
| switch(elem) { | |||
| case BGG_USER: | |||
| System.out.println("construct " + elem); | |||
| BggUserSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case GEEKLIST: | |||
| System.out.println("construct " + elem); | |||
| GeeklistSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case FAMILY: | |||
| System.out.println("construct " + elem); | |||
| FamilySourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case RANK: | |||
| RankSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case YEAR: | |||
| YearSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case AGE: | |||
| AgeSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| case SEARCH: | |||
| SearchSourceFilter.create(parent, SWT.FILL); | |||
| break; | |||
| default: | |||
| System.out.println("construct " + elem + " (not implemented yet, try another one)"); | |||
| } | |||
| } | |||
| public static Display getDisplay() { | |||
| Display display = Display.getCurrent(); | |||
| // may be null if outside the UI thread | |||
| if (display == null) | |||
| display = Display.getDefault(); | |||
| return display; | |||
| } | |||
| // DISPOSE images! | |||
| } | |||