diff --git a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF index 2987afd..38494a4 100644 --- a/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF +++ b/xyz.veronie.bgg.ui/META-INF/MANIFEST.MF @@ -21,6 +21,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: javax.annotation;version="1.0.0";resolution:=optional, javax.inject;version="1.0.0", org.eclipse.e4.core.commands, + org.eclipse.e4.core.contexts;version="1.7.0", org.eclipse.e4.ui.model.application.descriptor.basic, org.eclipse.e4.ui.model.application.ui.basic Automatic-Module-Name: de.wt.secondtry diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java index 50fd5d8..6ec3f55 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/BggUserSourceFilter.java @@ -1,41 +1,128 @@ package xyz.veronie.bgg.ui.filters; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; import javax.inject.Inject; -import org.eclipse.e4.core.di.annotations.Creatable; import org.eclipse.e4.core.services.events.IEventBroker; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; 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; import xyz.veronie.bgg.result.ResultConfigManager; -import xyz.veronie.bgg.ui.filters.composites.BggUserSourceComposite; -import xyz.veronie.bgg.ui.helpers.BatLayouts; - +import xyz.veronie.bgg.types.EventConstants; +import xyz.veronie.bgg.types.Subtype; +import xyz.veronie.bgg.types.UserFlag; +import xyz.veronie.bgg.ui.filters.composites.FilterFlagComposite; -/// 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.) -@Creatable public class BggUserSourceFilter { - + @Inject private IEventBroker eventBroker; @Inject private ResultConfigManager configManager; + + @PostConstruct + public void postConstruct(Composite parent) { + Composite main = new Composite(parent, SWT.FILL); + main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + main.setLayout(new GridLayout(1, false)); + + Composite topRowComposite = new Composite(main, SWT.NONE); + topRowComposite.setLayout(new GridLayout(5, false)); + topRowComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1)); + + Label lblUserName = new Label(topRowComposite, SWT.NONE); + lblUserName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblUserName.setText("User name:"); + + ComboViewer comboViewerUserName = new ComboViewer(topRowComposite, SWT.NONE); + Combo cbUserName = comboViewerUserName.getCombo(); + cbUserName.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + setUser(cbUserName.getText()); + } + }); + GridData gd_cbUserName = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); + gd_cbUserName.widthHint = 100; + cbUserName.setLayoutData(gd_cbUserName); + cbUserName.setText(configManager.getResultConfig().user); - public void create(Composite parent, int style) { + + new Label(topRowComposite, SWT.NONE); + + Label lblSubtype = new Label(topRowComposite, SWT.NONE); + lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblSubtype.setText("Subtypes:"); + + ComboViewer comboViewerSubtypes = new ComboViewer(topRowComposite, SWT.NONE); + Combo cbSubtypes = comboViewerSubtypes.getCombo(); + cbSubtypes.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + comboViewerSubtypes.setContentProvider(new ArrayContentProvider()); + comboViewerSubtypes.setInput(getSubtypes()); + comboViewerSubtypes.setSelection(new StructuredSelection(configManager.getResultConfig().subtype)); + comboViewerSubtypes.addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + eventBroker.send(EventConstants.TOPIC_SUBTYPE_CHANGED, selection.getFirstElement()); + } + }); - Composite mainCompo = new Composite(parent, SWT.FILL); - GridLayout gl_mainCompo = new GridLayout(5, false); - BatLayouts.applyZeroSpacing(gl_mainCompo); - mainCompo.setLayout(gl_mainCompo); - mainCompo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - new BggUserSourceComposite(mainCompo, SWT.NONE, eventBroker, configManager); + Composite centerComposite = new Composite(main, SWT.NONE); + centerComposite.setLayout(new GridLayout(1, false)); + centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); +// centerComposite.setLayout(new FillLayout(SWT.VERTICAL)); + + Label infoLabel = new Label(centerComposite, 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); + infoLabel.setLayoutData(gdInfo); - mainCompo.pack(); + new FilterFlagComposite(centerComposite, UserFlag.OWN, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.PREORDERED, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.WISHLIST, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.WTB, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.WTP, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.WANT, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.PREVIOUSLY_OWNED, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.PLAYED, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.TRADE, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.RATED, configManager, eventBroker); + new FilterFlagComposite(centerComposite, UserFlag.COMMENT, configManager, eventBroker); + parent.pack(); parent.layout(true, true); } + + + private void setUser(String user) { + if(eventBroker != null) { + eventBroker.post(EventConstants.TOPIC_USER_CHANGED, user); + } else { + System.out.println("setGeeklistId: eventBroker is null."); + } + } + public List getSubtypes() { + List subtypes = new ArrayList(); + for (Subtype st : Subtype.values()) { + subtypes.add(st); + } + return subtypes; + } + } diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java index 1880b02..87d63d8 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/FamilySourceFilter.java @@ -3,6 +3,7 @@ package xyz.veronie.bgg.ui.filters; import java.util.ArrayList; import java.util.List; +import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.e4.core.di.annotations.Creatable; @@ -41,7 +42,8 @@ public class FamilySourceFilter { private StyledText confLabel; private Combo cbFamilyId; - public void create(Composite parent, int style) { + @PostConstruct + public void postConstruct(Composite parent) { Composite mainCompo = new Composite(parent, SWT.FILL); GridLayout gl_mainCompo = new GridLayout(2, false); BatLayouts.applyZeroSpacing(gl_mainCompo); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java index 9a5b01d..ea66648 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/GeeklistSourceFilter.java @@ -1,5 +1,6 @@ package xyz.veronie.bgg.ui.filters; +import javax.annotation.PostConstruct; import javax.inject.Inject; import org.eclipse.e4.core.di.annotations.Creatable; @@ -32,7 +33,8 @@ public class GeeklistSourceFilter { private StyledText confLabel; private Combo cbGeeklistId; - public void create(Composite parent, int style) { + @PostConstruct + public void postConstruct(Composite parent) { Composite mainCompo = new Composite(parent, SWT.FILL); GridLayout gl_mainCompo = new GridLayout(2, false); BatLayouts.applyZeroSpacing(gl_mainCompo); diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/composites/BggUserSourceComposite.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/composites/BggUserSourceComposite.java deleted file mode 100644 index c1e6438..0000000 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/filters/composites/BggUserSourceComposite.java +++ /dev/null @@ -1,136 +0,0 @@ -package xyz.veronie.bgg.ui.filters.composites; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.e4.core.services.events.IEventBroker; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ComboViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -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; - -import xyz.veronie.bgg.result.ResultConfigManager; -import xyz.veronie.bgg.types.EventConstants; -import xyz.veronie.bgg.types.Subtype; -import xyz.veronie.bgg.types.UserFlag; - -public class BggUserSourceComposite extends Composite { - - private IEventBroker eventBroker; - - /** - * Create the composite. - * @param parent - * @param style - */ - public BggUserSourceComposite(Composite parent, int style, - IEventBroker eventBroker, ResultConfigManager configManager) - { - super(parent, style); - this.eventBroker = eventBroker; - - Composite main = new Composite(parent, SWT.FILL); - main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - main.setLayout(new GridLayout(1, false)); - - Composite topRowComposite = new Composite(main, SWT.NONE); - topRowComposite.setLayout(new GridLayout(5, false)); - topRowComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1)); - - Label lblUserName = new Label(topRowComposite, SWT.NONE); - lblUserName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblUserName.setText("User name:"); - - ComboViewer comboViewerUserName = new ComboViewer(topRowComposite, SWT.NONE); - Combo cbUserName = comboViewerUserName.getCombo(); - cbUserName.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - setUser(cbUserName.getText()); - } - }); - GridData gd_cbUserName = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); - gd_cbUserName.widthHint = 100; - cbUserName.setLayoutData(gd_cbUserName); - cbUserName.setText(configManager.getResultConfig().user); - - - new Label(topRowComposite, SWT.NONE); - - Label lblSubtype = new Label(topRowComposite, SWT.NONE); - lblSubtype.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - lblSubtype.setText("Subtypes:"); - - ComboViewer comboViewerSubtypes = new ComboViewer(topRowComposite, SWT.NONE); - Combo cbSubtypes = comboViewerSubtypes.getCombo(); - cbSubtypes.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - comboViewerSubtypes.setContentProvider(new ArrayContentProvider()); - comboViewerSubtypes.setInput(getSubtypes()); - comboViewerSubtypes.setSelection(new StructuredSelection(configManager.getResultConfig().subtype)); - comboViewerSubtypes.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - eventBroker.send(EventConstants.TOPIC_SUBTYPE_CHANGED, selection.getFirstElement()); - } - }); - - - Composite centerComposite = new Composite(main, SWT.NONE); - centerComposite.setLayout(new GridLayout(1, false)); - centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); -// centerComposite.setLayout(new FillLayout(SWT.VERTICAL)); - - Label infoLabel = new Label(centerComposite, 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); - infoLabel.setLayoutData(gdInfo); - - new FilterFlagComposite(centerComposite, UserFlag.OWN, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.PREORDERED, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.WISHLIST, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.WTB, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.WTP, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.WANT, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.PREVIOUSLY_OWNED, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.PLAYED, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.TRADE, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.RATED, configManager, eventBroker); - new FilterFlagComposite(centerComposite, UserFlag.COMMENT, configManager, eventBroker); - - this.pack(); - } - - - private void setUser(String user) { - if(eventBroker != null) { - eventBroker.post(EventConstants.TOPIC_USER_CHANGED, user); - } else { - System.out.println("setGeeklistId: eventBroker is null."); - } - } - - public List getSubtypes() { - List subtypes = new ArrayList(); - for (Subtype st : Subtype.values()) { - subtypes.add(st); - } - return subtypes; - } - - - @Override - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } -} diff --git a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/FetchPart.java b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/FetchPart.java index 5b798c3..04c9cb4 100644 --- a/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/FetchPart.java +++ b/xyz.veronie.bgg.ui/src/xyz/veronie/bgg/ui/parts/FetchPart.java @@ -7,6 +7,9 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.inject.Inject; +import org.eclipse.e4.core.contexts.ContextInjectionFactory; +import org.eclipse.e4.core.contexts.EclipseContextFactory; +import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.events.IEventBroker; import org.eclipse.e4.ui.model.application.MApplication; import org.eclipse.e4.ui.model.application.ui.basic.MPart; @@ -15,13 +18,15 @@ import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; 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.wb.swt.ResourceManager; import org.eclipse.wb.swt.SWTResourceManager; @@ -44,14 +49,12 @@ public class FetchPart { @Inject private ResultConfigManager configManager; - // inject all source filter composites - @Inject private BggUserSourceFilter bggUserSourceFilter; - @Inject private GeeklistSourceFilter geeklistSourceFilter; - @Inject private FamilySourceFilter familySourceFilter; - @Inject private IEventBroker eventBroker; + @Inject + private IEclipseContext context; + @Inject private MApplication application; @@ -74,6 +77,16 @@ public class FetchPart { private Composite main; private Composite filterComposite; + private Composite userFilterPage; + + private Composite familyPage; + + private StackLayout filterLayout; + + private Composite geeklistPage; + + private Composite centerComposite; + @Inject public FetchPart() { @@ -106,47 +119,26 @@ public class FetchPart { btnGeeklist = new Button(buttonRow, SWT.NONE); btnGeeklist.setImage(ResourceManager.getPluginImage("xyz.veronie.bgg.ui", "icons/noun_List_60x60.png")); - - - btnBggUser.addMouseListener(new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - selectFilter(SourceFilter.BGG_USER); - } - }); - btnFamily.addMouseListener(new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - selectFilter(SourceFilter.FAMILY); - } - }); - - btnGeeklist.addMouseListener(new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - selectFilter(SourceFilter.GEEKLIST); - } - }); - - Composite centerComposite = new Composite(main, SWT.NONE); - centerComposite.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); + centerComposite = new Composite(main, SWT.NONE); + centerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); GridLayout gl_centerComposite = new GridLayout(1, false); BatLayouts.applyStandardSpacing(gl_centerComposite); centerComposite.setLayout(gl_centerComposite); + + createFilterComposites(centerComposite); - filterComposite = new Composite(centerComposite, SWT.NONE); - filterComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); - filterComposite.setBackgroundMode(SWT.INHERIT_FORCE); - filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - GridLayout gl_filterComposite = new GridLayout(1, false); - BatLayouts.applyStandardSpacing(gl_filterComposite); - filterComposite.setLayout(gl_filterComposite); + // init filter using config manager + SourceFilter source = configManager.getResultConfig().source; + selectSource(source); - + createApplyToResultRow(); + } + + private void createApplyToResultRow() { Composite applyComposite = new Composite(main, SWT.NONE); GridLayout gl_applyComposite = new GridLayout(5, false); BatLayouts.applyStandardSpacing(gl_applyComposite); @@ -202,75 +194,110 @@ public class FetchPart { fetchEntries(ResultAction.SUBTRACT); } }); - - // init filter using config manager - SourceFilter source = configManager.getResultConfig().source; - selectFilter(source); - showFilter(filterComposite, source); - - } - private void selectFilter(SourceFilter source) { - configManager.getResultConfig().source = source; + private void createFilterComposites(Composite parent) { + + filterComposite = new Composite(parent, SWT.NONE); + filterComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); + filterComposite.setBackgroundMode(SWT.INHERIT_FORCE); + filterLayout = new StackLayout(); + filterComposite.setLayout(filterLayout); + filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + userFilterPage = new Composite(filterComposite, SWT.FILL); + GridLayout gl_userFilter = new GridLayout(2, false); + BatLayouts.applyZeroSpacing(gl_userFilter); + userFilterPage.setLayout(gl_userFilter); + userFilterPage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + IEclipseContext userFilterCtx = EclipseContextFactory.create(); + userFilterCtx.set(Composite.class, userFilterPage); // parent + ContextInjectionFactory.make(BggUserSourceFilter.class, context, userFilterCtx); + btnBggUser.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + selectSource(SourceFilter.BGG_USER); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + + }); + + + + familyPage = new Composite(filterComposite, SWT.FILL); + GridLayout gl_familyFilter = new GridLayout(2, false); + BatLayouts.applyZeroSpacing(gl_familyFilter); + familyPage.setLayout(gl_familyFilter); + familyPage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + IEclipseContext familyFilterCtx = EclipseContextFactory.create(); + familyFilterCtx.set(Composite.class, familyPage); // parent + ContextInjectionFactory.make(FamilySourceFilter.class, context, familyFilterCtx);; + btnFamily.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + selectSource(SourceFilter.FAMILY); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + + }); + + + geeklistPage = new Composite(filterComposite, SWT.FILL); + GridLayout gl_geeklistFilter = new GridLayout(2, false); + BatLayouts.applyZeroSpacing(gl_geeklistFilter); + geeklistPage.setLayout(gl_geeklistFilter); + geeklistPage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + IEclipseContext geeklistFilterCtx = EclipseContextFactory.create(); + geeklistFilterCtx.set(Composite.class, geeklistPage); // parent + ContextInjectionFactory.make(GeeklistSourceFilter.class, context, geeklistFilterCtx); + btnGeeklist.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + selectSource(SourceFilter.GEEKLIST); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + + }); + } + + private void selectSource(SourceFilter source) { switch(source) { - default: case BGG_USER: - btnBggUser.setFocus(); + filterLayout.topControl = userFilterPage; btnBggUser.setBackground(BatColors.getButtonBgColor()); btnFamily.setBackground(null); btnGeeklist.setBackground(null); break; case FAMILY: - btnFamily.setFocus(); + filterLayout.topControl = familyPage; btnBggUser.setBackground(null); btnFamily.setBackground(BatColors.getButtonBgColor()); btnGeeklist.setBackground(null); break; case GEEKLIST: - btnGeeklist.setFocus(); + filterLayout.topControl = geeklistPage; btnBggUser.setBackground(null); btnFamily.setBackground(null); btnGeeklist.setBackground(BatColors.getButtonBgColor()); break; } - showFilter(filterComposite, source); + + filterComposite.pack(); + centerComposite.layout(true,true); eventBroker.send(EventConstants.TOPIC_SOURCE_CHANGED, source); } - - - /// show different filter controls depending on selection in cbSource ComboViewer - private void showFilter(Composite parent, SourceFilter source) { - // clean up - for(Control child : parent.getChildren()) { - child.dispose(); - } - - // create a new filter area based on selection: - switch(source) { - default: - case BGG_USER: - System.out.println("construct " + source); - bggUserSourceFilter.create(parent, SWT.FILL); - break; - case GEEKLIST: - System.out.println("construct " + source); - geeklistSourceFilter.create(parent, SWT.FILL); - break; - case FAMILY: - System.out.println("construct " + source); - familySourceFilter.create(parent, SWT.FILL); - break; - } - main.pack(); - main.layout(true, true); - } - - private void fetchEntries(ResultAction action) { Object fetchId = getFetchId(); if(fetchId == null) return;