diff --git a/.project b/.project
new file mode 100644
index 0000000..3d4dd9d
--- /dev/null
+++ b/.project
@@ -0,0 +1,11 @@
+
+
+ BggToolAnother
+
+
+
+
+
+
+
+
diff --git a/xyz.veronie.bgg.ui/Application.e4xmi b/xyz.veronie.bgg.ui/Application.e4xmi
index 095ce25..9ca2f6e 100644
--- a/xyz.veronie.bgg.ui/Application.e4xmi
+++ b/xyz.veronie.bgg.ui/Application.e4xmi
@@ -1,34 +1,34 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/AgeSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/AgeSourceFilter.java
new file mode 100644
index 0000000..66ae1b9
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/AgeSourceFilter.java
@@ -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();
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggResult.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggResult.java
new file mode 100644
index 0000000..9838433
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggResult.java
@@ -0,0 +1,6 @@
+package xyz.veronie.bgg.ui.contributions;
+
+/// this represents a result of bgg "things"
+public class BggResult {
+
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggUserSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggUserSourceFilter.java
new file mode 100644
index 0000000..ef8162d
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggUserSourceFilter.java
@@ -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 flags = new HashMap() {
+ 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;
+ }
+
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/FamilySourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/FamilySourceFilter.java
new file mode 100644
index 0000000..f21b3cc
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/FamilySourceFilter.java
@@ -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;
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/GeeklistSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/GeeklistSourceFilter.java
new file mode 100644
index 0000000..dca0a98
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/GeeklistSourceFilter.java
@@ -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;
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/RankSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/RankSourceFilter.java
new file mode 100644
index 0000000..9f4f94d
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/RankSourceFilter.java
@@ -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();
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java
new file mode 100644
index 0000000..46d2a52
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java
@@ -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;
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultConfig.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultConfig.java
new file mode 100644
index 0000000..62e5c6e
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultConfig.java
@@ -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;
+ }
+
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SearchSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SearchSourceFilter.java
new file mode 100644
index 0000000..752bb15
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SearchSourceFilter.java
@@ -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();
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java
new file mode 100644
index 0000000..463ab52
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java
@@ -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;
+ }
+
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterBggUser.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterBggUser.java
deleted file mode 100644
index c939996..0000000
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterBggUser.java
+++ /dev/null
@@ -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";
- }
-}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterGeeklist.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterGeeklist.java
deleted file mode 100644
index cf249f6..0000000
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilterGeeklist.java
+++ /dev/null
@@ -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";
- }
-}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subpage.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subpage.java
new file mode 100644
index 0000000..e4c1930
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subpage.java
@@ -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;
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/YearSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/YearSourceFilter.java
new file mode 100644
index 0000000..bdd84c3
--- /dev/null
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/YearSourceFilter.java
@@ -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();
+ }
+}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java
index 51fee13..16b5111 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/BggResultPart.java
@@ -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));
}
}
diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java
index 1fcec72..2e1e1b7 100644
--- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java
+++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/LoadFromBggPart.java
@@ -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 sources = Arrays.asList(new String[] { "from BGG user", "from geeklist", "from family", "by rank", "by year", "by age", "search"});
+ List 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 sites = Arrays.asList(new String[] { "Boardgames", "RPGs", "RPG Items", "Videogames", "Accessories" });
+ List 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 actions = Arrays.asList(new String[] { "add", "replace", "subtract", "AND", "Mis"});
+ List 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!
}