diff --git a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF index b30ea9f..aef5ead 100644 --- a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF +++ b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF @@ -12,6 +12,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.17.0", org.eclipse.e4.ui.di;bundle-version="1.2.700", org.eclipse.e4.core.di.extensions;bundle-version="0.15.400", javax.annotation;bundle-version="1.2.0", - org.eclipse.jface;bundle-version="3.18.0" + org.eclipse.jface;bundle-version="3.18.0", + org.eclipse.e4.core.services;bundle-version="2.2.100", + org.eclipse.osgi.services;bundle-version="3.8.0", + javax.inject;bundle-version="1.0.0" Import-Package: org.eclipse.e4.ui.model.application.descriptor.basic, org.eclipse.e4.ui.model.application.ui.basic diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/BggResult.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/BggResult.java index 6a86859..e69c5f6 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/BggResult.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/BggResult.java @@ -1,6 +1,6 @@ package xyz.veronie.bgg.data; -/// This class contains and handles the result table for initial BGG result +/// This class contains and handles the result table for BGG things public class BggResult { } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/EventConstants.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/EventConstants.java new file mode 100644 index 0000000..031f336 --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/EventConstants.java @@ -0,0 +1,17 @@ +package xyz.veronie.bgg.data; + +public interface EventConstants { + + String TOPIC_CONFIG_CHANGED = "CONFIG_CHANGED/*"; + + String TOPIC_FILTER_CHANGED = "CONFIG_CHANGED/FILTER"; + + String TOPIC_SUBTYPE_CHANGED = "CONFIG_CHANGED/SUBTYPE"; + + String TOPIC_USERFLAG_CHANGED = "CONFIG_CHANGED/USERFLAG"; + + String TOPIC_ACTION_CHANGED = "CONFIG_CHANGED/ACTION"; + + String TOPIC_USER_CHANGED = "CONFIG_CHANGED/USER"; + +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/FilterFlagState.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/FilterFlagState.java new file mode 100644 index 0000000..8844b6e --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/FilterFlagState.java @@ -0,0 +1,15 @@ +package xyz.veronie.bgg.data; + +public enum FilterFlagState { + IS(0), ISNOT(1), IGNORE(2); + + private int state; + + private FilterFlagState(int state) { + this.state = state; + } + + public int get() { + return this.state; + } +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultAction.java similarity index 80% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultAction.java index 46d2a52..12739e9 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultAction.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultAction.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.data; public enum ResultAction { ADD("add"), diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfig.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfig.java new file mode 100644 index 0000000..b915c45 --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfig.java @@ -0,0 +1,20 @@ +package xyz.veronie.bgg.data; + +import java.util.HashMap; + +/// DTO / container for configuration of result download +public class ResultConfig { + // TODO: integrate different filters (or extend?) + + public HashMap subTypes; + public ResultAction action; + public SourceFilter source; + + public String user; + public HashMap userFlags; + + public Integer geeklistId; + public Integer familyId; + // TODO: add others + +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfigManager.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfigManager.java new file mode 100644 index 0000000..3c852b9 --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/ResultConfigManager.java @@ -0,0 +1,59 @@ +package xyz.veronie.bgg.data; + + +import javax.inject.Inject; + +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.di.UIEventTopic; + +public class ResultConfigManager { + + private ResultConfig resultConfig = new ResultConfig(); + + @Inject + @Optional + private void subscribeTopicSourceFilterChanged + (@UIEventTopic(EventConstants.TOPIC_FILTER_CHANGED) + SourceFilter source) { + getResultConfig().source = source; + } + + @Inject + @Optional + private void subscribeTopicSubtypesChanged + (@UIEventTopic(EventConstants.TOPIC_SUBTYPE_CHANGED) + Subtype subtype, Boolean checked) { + getResultConfig().subTypes.put(subtype, checked); + } + + @Inject + @Optional + private void subscribeTopicUserChanged + (@UIEventTopic(EventConstants.TOPIC_USER_CHANGED) + String user) { + System.out.println("set user to '" + user + "'"); + getResultConfig().user = user; + } + + @Inject + @Optional + private void subscribeTopicUserFlagChanged + (@UIEventTopic(EventConstants.TOPIC_USERFLAG_CHANGED) + UserFlag flag, FilterFlagState state) { + getResultConfig().userFlags.put(flag, state); + } + + @Inject + @Optional + private void subscribeTopicResultActionChanged + (@UIEventTopic(EventConstants.TOPIC_ACTION_CHANGED) + ResultAction action) { + getResultConfig().action = action; + } + + public ResultConfig getResultConfig() { + return resultConfig; + } + + +} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/SourceFilter.java similarity index 89% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/SourceFilter.java index 463ab52..03f4573 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/SourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.data; public enum SourceFilter { diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subtype.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/Subtype.java similarity index 91% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subtype.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/Subtype.java index 0822cff..ded73b8 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/Subtype.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/Subtype.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.data; public enum Subtype { BOARDGAME("Board games", "boardgame"), diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/UserFlag.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/UserFlag.java new file mode 100644 index 0000000..4984d62 --- /dev/null +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/data/UserFlag.java @@ -0,0 +1,24 @@ +package xyz.veronie.bgg.data; + +public 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; + } +} 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 deleted file mode 100644 index 9838433..0000000 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggResult.java +++ /dev/null @@ -1,6 +0,0 @@ -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/ResultConfig.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultConfig.java deleted file mode 100644 index a214334..0000000 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ResultConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -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 Subtype subpage; - private ResultAction action; - - public SourceFilter getSource() { - return source; - } - public void setSource(SourceFilter source) { - this.source = source; - } - public Subtype getSubpage() { - return subpage; - } - public void setSubpage(Subtype 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/AgeSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/AgeSourceFilter.java similarity index 90% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/AgeSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/AgeSourceFilter.java index 66ae1b9..0d470d1 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/AgeSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/AgeSourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; 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/filters/BggUserSourceFilter.java similarity index 67% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggUserSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java index ef8162d..771406b 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/BggUserSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java @@ -1,7 +1,10 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import java.util.HashMap; +import javax.inject.Inject; + +import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; @@ -14,65 +17,36 @@ import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import xyz.veronie.bgg.data.EventConstants; +import xyz.veronie.bgg.data.FilterFlagState; +import xyz.veronie.bgg.data.UserFlag; + + -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() { + @Inject + private IEventBroker eventBroker; + + private 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); + put(UserFlag.OWN, FilterFlagState.IS); + put(UserFlag.PREVIOUSLY_OWNED, FilterFlagState.ISNOT); + put(UserFlag.FOR_TRADE, FilterFlagState.IGNORE); + put(UserFlag.WANTED, FilterFlagState.IGNORE); + put(UserFlag.WTP, FilterFlagState.IGNORE); + put(UserFlag.WTB, FilterFlagState.IGNORE); + put(UserFlag.WISHLIST, FilterFlagState.IGNORE); + put(UserFlag.PREORDERED, FilterFlagState.IGNORE); }}; - public static void create(Composite parent, int style) { + public void create(Composite parent, int style) { GridLayout filterLayout = new GridLayout(4, false); parent.setLayout(filterLayout); @@ -86,7 +60,6 @@ public class BggUserSourceFilter { cbUserName.addSelectionListener(new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { setUser(cbUserName.getText()); - System.out.println("set user to '" + getUser() + "'"); } }); cbUserName.addFocusListener(new FocusListener() { @@ -134,27 +107,26 @@ public class BggUserSourceFilter { // 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) { + private 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)); + // TODO: add listener - send a CONFIG_CHANGED event when something changes 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; + public void setUser(String user) { + if(eventBroker != null) { + eventBroker.post(EventConstants.TOPIC_USER_CHANGED, user); + } else { + System.out.println("null???"); + } } } 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/filters/FamilySourceFilter.java similarity index 94% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/FamilySourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java index f21b3cc..cf46f08 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/FamilySourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; 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/filters/GeeklistSourceFilter.java similarity index 95% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/GeeklistSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java index dca0a98..47faa0c 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/GeeklistSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; 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/filters/RankSourceFilter.java similarity index 90% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/RankSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/RankSourceFilter.java index 9f4f94d..d0364f5 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/RankSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/RankSourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; 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/filters/SearchSourceFilter.java similarity index 90% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SearchSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/SearchSourceFilter.java index 752bb15..7cdaaab 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/SearchSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/SearchSourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ThingFilterGroup.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/ThingFilterGroup.java similarity index 72% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ThingFilterGroup.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/ThingFilterGroup.java index 650d8cb..b61e103 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/ThingFilterGroup.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/ThingFilterGroup.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import java.util.HashMap; @@ -9,13 +9,15 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; +import xyz.veronie.bgg.data.Subtype; + public class ThingFilterGroup { private HashMap buttons; public void create(Composite parent) { Group gSubtype = new Group(parent, SWT.LEFT); gSubtype.setText("Subtypes"); - gSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); + gSubtype.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); gSubtype.setLayout(new GridLayout(1, false)); buttons = new HashMap(); @@ -23,13 +25,14 @@ public class ThingFilterGroup { for (Subtype st : Subtype.values()) { Button bb = new Button(gSubtype, SWT.CHECK); bb.setText(st.toString()); + bb.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); if(st == Subtype.BOARDGAME) { // initially, only boardgame is checked - bb.setEnabled(true); + bb.setSelection(true); } else { - bb.setEnabled(false); + bb.setSelection(false); } - bb.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + // TODO: add listener to buttons. Send event with checked subtypes when something changes. buttons.put(st, bb); } } 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/filters/YearSourceFilter.java similarity index 90% rename from xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/YearSourceFilter.java rename to xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/YearSourceFilter.java index bdd84c3..c7ece46 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/contributions/YearSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/YearSourceFilter.java @@ -1,4 +1,4 @@ -package xyz.veronie.bgg.ui.contributions; +package xyz.veronie.bgg.ui.filters; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; 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 16b5111..a8b5baf 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 @@ -8,11 +8,12 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import xyz.veronie.bgg.data.ResultConfigManager; + public class BggResultPart { @PostConstruct public void createControls(Composite parent) { - Composite main = new Composite(parent, SWT.FILL); Label lblTable = new Label(main, SWT.LEFT); 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 eab4a14..65e65a7 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 @@ -24,17 +24,17 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; -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.Subtype; -import xyz.veronie.bgg.ui.contributions.ThingFilterGroup; -import xyz.veronie.bgg.ui.contributions.YearSourceFilter; +import xyz.veronie.bgg.data.ResultAction; +import xyz.veronie.bgg.data.ResultConfigManager; +import xyz.veronie.bgg.data.SourceFilter; +import xyz.veronie.bgg.ui.filters.AgeSourceFilter; +import xyz.veronie.bgg.ui.filters.BggUserSourceFilter; +import xyz.veronie.bgg.ui.filters.FamilySourceFilter; +import xyz.veronie.bgg.ui.filters.GeeklistSourceFilter; +import xyz.veronie.bgg.ui.filters.RankSourceFilter; +import xyz.veronie.bgg.ui.filters.SearchSourceFilter; +import xyz.veronie.bgg.ui.filters.ThingFilterGroup; +import xyz.veronie.bgg.ui.filters.YearSourceFilter; @@ -42,11 +42,16 @@ import xyz.veronie.bgg.ui.contributions.YearSourceFilter; /// There are different ways to configure which IDs to retrieve. public class LoadFromBggPart { + // TODO: figure out how to make sure this is a singleton + private ResultConfigManager resultConfigManager; + LoadFromBggPart() { + resultConfigManager = new ResultConfigManager(); + } + @PostConstruct public void createControls(Composite parent) { - Composite main = new Composite(parent, SWT.FILL); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); @@ -82,6 +87,10 @@ public class LoadFromBggPart { // choose the bgg sub-site + Label lblSubtype = new Label(dlConfigGroup, SWT.LEFT); + lblSubtype.setText("Subtypes: "); + lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); + ThingFilterGroup gSubtypes = new ThingFilterGroup(); gSubtypes.create(dlConfigGroup); @@ -143,11 +152,12 @@ public class LoadFromBggPart { if(selection.size() == 0) return; if(selection.getFirstElement() == SourceFilter.BGG_USER) { - if(BggUserSourceFilter.getUser().isEmpty()) { + String user = resultConfigManager.getResultConfig().user; + if(user == null || user.isEmpty()) { System.out.println("Please enter a user name."); return; } - System.out.println("...for user '" + BggUserSourceFilter.getUser() + "'"); + System.out.println("...for user '" + user + "'"); } else if(selection.getFirstElement() == SourceFilter.GEEKLIST) { System.out.println("...for geeklist id '" + GeeklistSourceFilter.getGeeklistId() + "'"); } else if(selection.getFirstElement() == SourceFilter.FAMILY) { @@ -156,8 +166,6 @@ public class LoadFromBggPart { } }); btDownload.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false)); - - main.pack(); @@ -177,7 +185,8 @@ public class LoadFromBggPart { switch(elem) { case BGG_USER: System.out.println("construct " + elem); - BggUserSourceFilter.create(parent, SWT.FILL); + BggUserSourceFilter f = new BggUserSourceFilter(); + f.create(parent, SWT.FILL); break; case GEEKLIST: System.out.println("construct " + elem);