e4 migration of selection dialogs
authorKatja Luther <k.luther@bgbm.org>
Tue, 21 Nov 2017 12:28:48 +0000 (13:28 +0100)
committerKatja Luther <k.luther@bgbm.org>
Tue, 21 Nov 2017 12:28:48 +0000 (13:28 +0100)
33 files changed:
eu.etaxonomy.taxeditor.store/icons/funnel-exclamation-icon.png [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/icons/funnel-icon.png [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AmplificationSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ClassificationSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/CollectionSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/DerivedUnitSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ExtReferenceSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FieldUnitSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FilterDialog.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GroupSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/MediaSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NameSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorTeamSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PersonSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PolytomousKeySelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PrimerSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/RightsSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SearchDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionViewMenu.java [new file with mode: 0755]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonBaseSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TeamSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/UserSelectionDialog.java

diff --git a/eu.etaxonomy.taxeditor.store/icons/funnel-exclamation-icon.png b/eu.etaxonomy.taxeditor.store/icons/funnel-exclamation-icon.png
new file mode 100755 (executable)
index 0000000..e5c5720
Binary files /dev/null and b/eu.etaxonomy.taxeditor.store/icons/funnel-exclamation-icon.png differ
diff --git a/eu.etaxonomy.taxeditor.store/icons/funnel-icon.png b/eu.etaxonomy.taxeditor.store/icons/funnel-icon.png
new file mode 100755 (executable)
index 0000000..1f69604
Binary files /dev/null and b/eu.etaxonomy.taxeditor.store/icons/funnel-icon.png differ
index 04d580ab813df7b0552b67f6f6043ee4924d8c01..c579a01b4a05b36ccc22961df2519528b322592e 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
 import java.text.Collator;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
@@ -33,9 +34,8 @@ import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
@@ -228,6 +228,9 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
     protected void fillContentProvider(IProgressMonitor progressMonitor)
                throws CoreException {
                try {
+                   if (model == null){
+                       model = new ArrayList<UuidAndTitleCache<T>>();
+                   }
                        if(model != null){
                            if (progressMonitor != null){
                                progressMonitor.beginTask("Looking for entities", model.size());
@@ -250,6 +253,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                                }
                                this.refresh();
                        }else{
+
                                MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
                        }
                }
@@ -348,7 +352,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         *
         * @return a {@link java.lang.String} object.
         */
-       protected abstract String getNewWizardLinkText();
+       protected abstract String[] getNewWizardText();
 
        /**
         * <p>getNewEntityWizard</p>
@@ -377,19 +381,34 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        */
        /** {@inheritDoc} */
 
+//     @Override
+//    protected Control createExtendedContentArea(Composite parent) {
+//             String newWizardLinkText = getNewWizardLinkText();
+////        if(newWizardLinkText != null){
+////            newButton1 = this.createButton(this.getShell(), new_id, newWizardLinkText, false);
+////
+////            newButton1.addSelectionListener(getNewWizardLinkSelectionListener());
+////                   return newButton1;
+////           }
+//             return null;
+//     }
+
        @Override
-    protected Control createExtendedContentArea(Composite parent) {
-               String newWizardLinkText = getNewWizardLinkText();
-        if(newWizardLinkText != null){
-                       Link link = new Link(parent, SWT.NONE);
-                       link.setText(newWizardLinkText);
-                       link.addSelectionListener(getNewWizardLinkSelectionListener());
-                       return link;
-               }
-               return null;
-       }
+    protected void createButtonsForButtonBar(Composite parent) {
+           String[] newButtonText = getNewWizardText();
+           if (newButtonText!= null){
+               this.newButton1 = createButton(parent, this.new_id, newButtonText[0], false);
+               newButton1.addSelectionListener(getNewWizardButtonSelectionListener());
+               if (newButtonText.length > 1){
+                   newButton2 = createButton(parent, this.new_id2, newButtonText[1], false);
+                   newButton2.addSelectionListener(getNewWizardButtonSelectionListener());
+               }
+           }
+
+        super.createButtonsForButtonBar(parent);
+    }
 
-       protected SelectionListener getNewWizardLinkSelectionListener(){
+       protected SelectionListener getNewWizardButtonSelectionListener(){
                return new SelectionAdapter() {
 
                        /* (non-Javadoc)
@@ -397,8 +416,13 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                         */
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-
-                           AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
+                           Object source = e.getSource();
+                           String text = null;
+                           if (source instanceof Button){
+                               Button sourceButton = (Button) source;
+                               text = sourceButton.getText();
+                           }
+                           AbstractNewEntityWizard wizard = getNewEntityWizard(text);
                            if(wizard!=null){
                                wizard.init(null, null);
                                if(wizard.getEntity() != null) {
@@ -457,4 +481,8 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        model.remove(uuidAndTitleCacheToRemove);
                }
        }
+       @Override
+       void createFilterButton(Composite searchAndFilter){
+           //as default no filter button available
+       }
 }
index 4816ddaa74433ec898a2a7bf0dd9ab5403ba7388..142c82ed6a10159ba18eb884a94af5bcbafbb912 100644 (file)
@@ -41,11 +41,11 @@ public class AgentSelectionDialog extends
        /**
         *
         */
-       protected static final String PERSON = "Person";
+       protected static final String PERSON = "new Person";
        /**
         *
         */
-       protected static final String TEAM = "Team";
+       protected static final String TEAM = "new Team";
 
        protected static boolean selectTeamMember;
 
@@ -124,19 +124,26 @@ public class AgentSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
+           String[] result;
                if (this.selectTeamMember){
-                       return String.format("Create a new <a>%1s</a>", PERSON);
+                   result = new String[1];
+                   result[0] = PERSON;
+
+               }else{
+                   result = new String[2];
+            result[0] = PERSON;
+            result[1] = TEAM;
                }
-               return String.format("Create a new <a>%1s</a> or <a>%2s</a>", TEAM, PERSON);
+               return result;
        }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkSelectionListener()
         */
        @Override
-       protected SelectionListener getNewWizardLinkSelectionListener() {
-               return super.getNewWizardLinkSelectionListener();
+       protected SelectionListener getNewWizardButtonSelectionListener() {
+               return super.getNewWizardButtonSelectionListener();
        }
 
        /** {@inheritDoc} */
index ae6b5bca8cca0f7cc177d3f2323d872c211e22a9..d43fbe1a9f8de8eea816ada97287806f5431a7a5 100644 (file)
@@ -82,7 +82,9 @@ AbstractFilteredCdmResourceSelectionDialog<Amplification> {
 
     /** {@inheritDoc} */
     @Override
-    protected String getNewWizardLinkText() {
-        return String.format("Create a new <a>%1s</a>", "Amplification ");
+    protected String[] getNewWizardText() {
+        String[] result = new String[1];
+        result[0] = "Amplification";
+        return result;
     }
 }
index a699eac75720baf664130141382a78c6f45ae0f5..86f9b1d636744b40cdaf2a57fd1e0c81ce3260e6 100644 (file)
@@ -11,7 +11,6 @@ package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
 import java.util.UUID;
 
-import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
@@ -79,18 +78,18 @@ public class ClassificationSelectionDialog extends
                super(shell, conversation, title, multi, settings, classification);
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
-        * (org.eclipse.swt.widgets.Composite)
-        */
-       /** {@inheritDoc} */
-       @Override
-       protected Control createExtendedContentArea(Composite parent) {
-               return null;
-       }
+//     /*
+//      * (non-Javadoc)
+//      *
+//      * @see
+//      * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
+//      * (org.eclipse.swt.widgets.Composite)
+//      */
+//     /** {@inheritDoc} */
+//     @Override
+//     protected Control createExtendedContentArea(Composite parent) {
+//             return null;
+//     }
 
        /*
         * (non-Javadoc)
@@ -137,7 +136,7 @@ public class ClassificationSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
                return null;
        }
 }
index 52ad42e4dc1c5833a3d7fe4456e1ccfc9c5bd7f3..8d0a345b5f94642571d743f962f9e49098b077ce 100644 (file)
@@ -83,8 +83,8 @@ public class CollectionSelectionDialog extends
         */
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-        return String.format("Create a new <a>%1s</a>", "Collection ");
+       protected String[] getNewWizardText() {
+        return new String[]{ "Collection "};
        }
 
        /* (non-Javadoc)
index 2907566c340b415b2287272489dcceb911507193..56d3dd2cc284511568fa60ff5d651b2b7da305be 100644 (file)
@@ -90,7 +90,7 @@ public class DerivedUnitSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Unit ");
+       protected String[] getNewWizardText() {
+               return new String[]{ "Unit "};
        }
 }
index 0d06603bb4aefcec33abd750ba5c0ec1ebb5741b..0175b320ec9f81dbcfb77a893a5eff652614af43 100755 (executable)
@@ -250,8 +250,8 @@ public class ExtReferenceSelectionDialog extends
 
         /** {@inheritDoc} */
         @Override
-        protected String getNewWizardLinkText() {
-            return String.format("Create a new <a>%1s</a>", "Reference ");
+        protected String[] getNewWizardText() {
+            return new String[]{"Reference "};
         }
 
     }
index 4ffb2a844f292202a689e39d28d49f64185df1a7..d3ff2dca8e54a241fc09501a80a87afbf2acfe92 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -36,7 +36,7 @@ public class FeatureSelectionDialog extends
                                "Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
                return getSelectionFromDialog(dialog);
        }
-       
+
        /**
         * @param shell
         * @param conversation
@@ -53,27 +53,27 @@ public class FeatureSelectionDialog extends
 
        @Override
        protected Feature getPersistentObject(UUID uuid) {
-               
+
                DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
-               
+
                if(term instanceof Feature){
                        return (Feature) term;
                }
-               
+
                return null;
        }
 
        @Override
        protected void search() {
                List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
-               
+
                List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
-               
+
                for(Feature feature : features){
                        UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
                        featureUuidAndTitleCache.add(uuidAndTitleCache);
                }
-               
+
                model =  featureUuidAndTitleCache;
        }
 
@@ -81,7 +81,7 @@ public class FeatureSelectionDialog extends
         * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
                return null;
        }
 
index 68100a5d4d1002eb09e9e1a3f0d0a8a360c5a394..643b67792f41a74c19200ca90b3febec98f6c7ef 100644 (file)
@@ -13,14 +13,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
@@ -71,37 +63,37 @@ public class FeatureTreeSelectionDialog extends
                }
        }
 
-       /** {@inheritDoc} */
-       @Override
-       protected Control createExtendedContentArea(Composite parent) {
-               Link link = new Link(parent, SWT.NONE);
-               link.setText(getNewWizardLinkText());
-               link.addListener (SWT.Selection, new Listener () {
-                       @Override
-            public void handleEvent(Event event) {
-
-                           InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
-                               int status = input.open();
-                               if (status == IStatus.OK) {
-                                   String label = input.getValue();
-                                   if(label!=null){
-                                       FeatureTree featureTree = FeatureTree.NewInstance();
-                                       featureTree.setTitleCache(label, false);
-                                       CdmStore.getService(IFeatureTreeService.class).save(featureTree);
-                                   UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
-                                   model.add(uuidAndTitleCache);
-                                   setPattern(featureTree);
-                                   }
-                               }
-                       }
-               });
-               return link;
-       }
+//     /** {@inheritDoc} */
+//     @Override
+//     protected Control createExtendedContentArea(Composite parent) {
+//             Link link = new Link(parent, SWT.NONE);
+//             link.setText(getNewWizardLinkText());
+//             link.addListener (SWT.Selection, new Listener () {
+//                     @Override
+//            public void handleEvent(Event event) {
+//
+//                         InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
+//                             int status = input.open();
+//                             if (status == IStatus.OK) {
+//                                 String label = input.getValue();
+//                                 if(label!=null){
+//                                     FeatureTree featureTree = FeatureTree.NewInstance();
+//                                     featureTree.setTitleCache(label, false);
+//                                     CdmStore.getService(IFeatureTreeService.class).save(featureTree);
+//                                 UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
+//                                 model.add(uuidAndTitleCache);
+//                                 setPattern(featureTree);
+//                                 }
+//                             }
+//                     }
+//             });
+//             return link;
+//     }
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>" , "Feature tree ");
+       protected String[] getNewWizardText() {
+               return new String[]{ "Feature tree "};
        }
 
 
index 66afa64d9d9292e84af0fbb8e3b281281dc8e0ad..b0ba469c59b0c43c1afda92ec707abcec3d9e5ae 100644 (file)
@@ -97,7 +97,7 @@ public class FieldUnitSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Field Unit ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Field Unit "};
        }
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FilterDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FilterDialog.java
new file mode 100755 (executable)
index 0000000..eb402ed
--- /dev/null
@@ -0,0 +1,121 @@
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+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.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 21.11.2017
+ *
+ */
+public class FilterDialog extends Dialog {
+
+    List<TermVocabulary> vocabularies = new ArrayList<TermVocabulary>();
+
+    List<TermVocabulary> selectedVocabularies = new ArrayList<TermVocabulary>();
+
+    Object preferenceId;
+
+    /**
+     * @param parentShell
+     */
+    protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies) {
+        super(parentShell);
+        vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+        this.preferenceId = preferenceId;
+        List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
+        this.selectedVocabularies = selectedVocabularies;
+
+    }
+
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        Composite dialogArea = new Composite(parent, SWT.NULL);
+        dialogArea.setLayout(new GridLayout(1, false));
+        for (TermVocabulary voc: vocabularies){
+            Button btnCheckButton = new Button(dialogArea, SWT.CHECK);
+            btnCheckButton.setText(voc.getLabel());
+            btnCheckButton.setData(voc);
+            if (selectedVocabularies.contains(voc)){
+                btnCheckButton.setSelection(true);
+            }else {
+                btnCheckButton.setSelection(false);
+            }
+
+            btnCheckButton.addSelectionListener(new SelectionListener(){
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                   if (btnCheckButton.getSelection()){
+                       Object obj = btnCheckButton.getData();
+                       if (!selectedVocabularies.contains(btnCheckButton.getData())){
+                           selectedVocabularies.add((TermVocabulary)btnCheckButton.getData());
+                       }
+                   }else{
+                       if (selectedVocabularies.contains(btnCheckButton.getData())){
+                           selectedVocabularies.remove(btnCheckButton.getData());
+                       }
+                   }
+
+                }
+
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                    // TODO Auto-generated method stub
+
+                }
+
+            });
+        }
+
+        GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+        gd_table.heightHint = 231;
+        gd_table.widthHint = 543;
+
+        return dialogArea;
+
+    }
+
+    @Override
+    protected void okPressed(){
+        for (TermVocabulary voc: vocabularies){
+            if (selectedVocabularies.contains(voc)){
+                PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), false);
+            } else{
+                PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), true);
+            }
+        }
+        super.okPressed();
+    }
+
+    private String getPrefKey(TermVocabulary vocabulary){
+        return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceId;
+    }
+
+}
index a2f128385c87f1999cd2f0582cba1e8bf2fc5cdf..418d9d37c0fb9588595e80fc8069a1e6ac2f0490 100644 (file)
@@ -64,7 +64,7 @@ public class GrantedAuthoritySelectionDialog extends  AbstractFilteredCdmResource
                model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
 
                for(GrantedAuthorityImpl authority : authorities){
-                       
+
                        model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
                }
        }
@@ -73,8 +73,8 @@ public class GrantedAuthoritySelectionDialog extends  AbstractFilteredCdmResource
         * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "GrantedAuthority ");
+       protected String[] getNewWizardText() {
+               return new String[]{"GrantedAuthority "};
        }
 
        @Override
index 5ba527cb15423c9de3dfc33099bb68f9d2386d4a..9ad65a941b53eea119c668ee5b2f66125c4096e4 100644 (file)
@@ -69,8 +69,8 @@ public class GroupSelectionDialog extends
         * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Group ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Group "};
        }
 
        /* (non-Javadoc)
index 92beece521a527e33664c9df6dbd1db7b6e26e20..b3ab56ff9df2e025c155a36ee11bb6f532861c51 100644 (file)
@@ -74,8 +74,8 @@ public class InstitutionSelectionDialog extends
         * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Institution ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Institution "};
        }
 
        /* (non-Javadoc)
index 26a245aa9e2400ff58ff0ec9f9379258b138effd..bde77b2ed0d5d3e78467b0313fff0ac648c63e16 100644 (file)
@@ -81,7 +81,7 @@ AbstractFilteredCdmResourceSelectionDialog<Media> {
 
     /** {@inheritDoc} */
     @Override
-    protected String getNewWizardLinkText() {
-        return "";
+    protected String[] getNewWizardText() {
+        return null;
     }
 }
index f23baf1d9b37320be59ec876c63594c3b214ed79..92b8278858cc83410f9061d3312a60954ed65851 100644 (file)
@@ -68,7 +68,7 @@ public class NameSelectionDialog extends AbstractFilteredCdmResourceSelectionDia
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Name ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Name "};
        }
 }
index 28b0d05c30cf85069b86ab0b7af8ce2472577164..d4801afb24d7f2e282cad14e71105e5ba92240b0 100644 (file)
@@ -16,11 +16,16 @@ import java.util.UUID;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.wb.swt.ResourceManager;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.ITermService;
@@ -62,18 +67,12 @@ public class NamedAreaSelectionDialog extends
                        }
                        PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
                        search();
-                       try {
-                fillContentProvider(null);
-            } catch (CoreException coreException) {
-                // TODO Auto-generated catch block
-                coreException.printStackTrace();
-            }
                }
        }
 
        protected List<TermVocabulary> selectedVocabularies;
     protected ArrayList<TermVocabulary> preselectedVocabularies;
-    private Object preferenceID;
+
 
 
        /**
@@ -103,34 +102,40 @@ public class NamedAreaSelectionDialog extends
                        TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
                        preselectedVocabularies.add(preselectedVocabulary);
                }
-               List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
-               for(TermVocabulary vocabulary:selectedVocabularies){
+
+
+               selectedVocabularies = createSelectedVocabularies();;
+//             search;//re-init to consider pre-selected vocabularies
+       }
+
+    private List<TermVocabulary> createSelectedVocabularies() {
+        List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>();
+        for(TermVocabulary vocabulary:selectedVocabularies){
                        if(preselectedVocabularies.contains(vocabulary)
                                        || !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
                                tempSelectedVocabularies.add(vocabulary);
                        }
                }
-               selectedVocabularies = tempSelectedVocabularies;
-//             search;//re-init to consider pre-selected vocabularies
-       }
+        return tempSelectedVocabularies;
+    }
 
        /** {@inheritDoc} */
-       @Override
-       protected void fillViewMenu(IMenuManager menuManager) {
-
-//             super.fillViewMenu(menuManager);
-
-               for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
-                       IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
-                       menuManager.add(action);
-                       if(preselectedVocabularies.contains(vocabulary)) {
-                           action.setChecked(true);
-                       }
-                       else{
-                               action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
-                       }
-               }
-       }
+//     @Override
+//     protected void fillViewMenu(IMenuManager menuManager) {
+//
+////           super.fillViewMenu(menuManager);
+//
+//             for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
+//                     IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
+//                     menuManager.add(action);
+//                     if(preselectedVocabularies.contains(vocabulary)) {
+//                         action.setChecked(true);
+//                     }
+//                     else{
+//                             action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
+//                     }
+//             }
+//     }
 
        private String getPrefKey(TermVocabulary vocabulary){
                return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
@@ -175,7 +180,12 @@ public class NamedAreaSelectionDialog extends
         }else{
             model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
         }
-
+       try {
+           fillContentProvider(null);
+        } catch (CoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
 //             Set<NamedArea> terms = new HashSet<NamedArea>();
 //             for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
 //                     terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
@@ -192,11 +202,11 @@ public class NamedAreaSelectionDialog extends
 //             }
        }
 
-       /** {@inheritDoc} */
-       @Override
-       protected Control createExtendedContentArea(Composite parent) {
-               return null;
-       }
+//     /** {@inheritDoc} */
+//     @Override
+//     protected Control createExtendedContentArea(Composite parent) {
+//             return null;
+//     }
 
        /** {@inheritDoc} */
        @Override
@@ -218,7 +228,54 @@ public class NamedAreaSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
                return null;
        }
+
+       @Override
+    void createFilterButton(Composite searchAndFilter)
+           {
+            filterButton = new Button(searchAndFilter, SWT.NONE);
+//            filterButton.setText("Filter");
+            filterButton.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/funnel-icon.png"));
+//            SelectionListener filterSelectionListener = new FilterSelectionListener(preferenceID, this);
+            filterButton.addSelectionListener(new SelectionListener(){
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+
+                        Object source = e.getSource();
+                        String text = null;
+                        if (source instanceof Button){
+                            Shell shell = ((Button)source).getShell();
+                            Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies);
+                            if(dialog!=null){
+                                dialog.open();
+                            }
+                            createSelectedVocabularies();
+                        }
+
+
+
+
+                }
+
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                    // TODO Auto-generated method stub
+
+                }
+
+
+            });
+
+        }
+
+    /**
+     *
+     */
+    public void setSelectedVocabularies() {
+        // TODO Auto-generated method stub
+
+    }
+
 }
index 625fd0617f988392382f832c1ed2b66d77f66fc1..70f55de3b750a2f12e4e6a9056589a2f8e2cba5b 100644 (file)
@@ -71,8 +71,8 @@ public class NomenclaturalAuthorTeamSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Team ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Team "};
        }
 
        /** {@inheritDoc} */
index f1e8a3b9f8ab508b688ce8fe0c8bfcc9d0f445d7..ef78670016de7f5563b1c2b3a3c9e938e827676a 100644 (file)
@@ -87,7 +87,7 @@ public class PersonSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Person ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Person"};
        }
 }
index b4852d810f5edf4a7484234a5ec1e366ad4cee9c..25b24b4d80c267bfbea0e022bfbc98242b26c368 100644 (file)
@@ -67,7 +67,7 @@ public class PolytomousKeySelectionDialog extends
         * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
                return null;
        }
 
index 50c2e9437610b151065591c7b50201607af9a1d6..3a45434ce237e2ae6adbbf1d698cebeb69a4fb7b 100644 (file)
@@ -82,7 +82,7 @@ AbstractFilteredCdmResourceSelectionDialog<Primer> {
 
     /** {@inheritDoc} */
     @Override
-    protected String getNewWizardLinkText() {
-        return String.format("Create a new <a>%1s</a>", "Primer ");
+    protected String[] getNewWizardText() {
+        return new String[]{"Primer "};
     }
 }
index f91c1c8d56839425332d32a2582c29b63efb5654..6a592342f470744c67b68a9f764efa016b897eb5 100644 (file)
@@ -158,8 +158,8 @@ public class ReferenceSelectionDialog extends AbstractFilteredCdmResourceSelecti
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Reference ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Reference "};
        }
 
 }
index 1198a7aefd00785c64a50fce6e64038a914f91d2..65572cabe0abf4a016f29c0df4d0592a1c6cb072 100755 (executable)
@@ -64,8 +64,8 @@ public class RightsSelectionDialog extends AbstractFilteredCdmResourceSelectionD
      * {@inheritDoc}
      */
     @Override
-    protected String getNewWizardLinkText() {
-        // TODO Auto-generated method stub
+    protected String[] getNewWizardText() {
+
         return null;
     }
 
index 2aae223f3afbe95f64bcaf6144c04b66eaca8936..d34098d0253f9160e81668e0d8d23abba5d34ae0 100755 (executable)
@@ -17,9 +17,6 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -27,7 +24,6 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.ListenerList;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.LegacyActionTools;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.dialogs.Dialog;
@@ -54,8 +50,6 @@ import org.eclipse.swt.accessibility.AccessibleAdapter;
 import org.eclipse.swt.accessibility.AccessibleEvent;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.TraverseEvent;
 import org.eclipse.swt.events.TraverseListener;
 import org.eclipse.swt.graphics.Color;
@@ -65,21 +59,19 @@ import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 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.Event;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
 import org.eclipse.ui.IWorkbenchPreferenceConstants;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
-import org.eclipse.ui.handlers.IHandlerService;
 import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
 import org.eclipse.ui.internal.WorkbenchImages;
 import org.eclipse.ui.internal.WorkbenchMessages;
@@ -101,6 +93,11 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
         private TableViewer list;
         private Text searchField;
         private String title;
+        protected Button newButton1;
+
+
+        protected Button newButton2;
+        protected Button filterButton;
         private StructuredSelection currentSelection;
 
         // message to show user
@@ -112,8 +109,12 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
         private final RefreshCacheJob refreshCacheJob;
 
         private ToolBar toolBar;
-        private ToolItem toolItem;
         private MenuManager menuManager;
+
+        protected Object preferenceID;
+
+        protected final int new_id = 4;
+        protected final int new_id2 = 5;
         // Need to keep our own list of listeners
         private final ListenerList listeners = new ListenerList();
 
@@ -126,6 +127,7 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
             contentProvider = new ContentProvider();
             refreshCacheJob = new RefreshCacheJob();
 
+
         }
 
 
@@ -144,7 +146,15 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
 
             final Label headerLabel = createHeader(container);
 
-            searchField = new Text(container, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
+            Composite searchAndFilter = new Composite(container, container.getStyle());
+//            GridData gd_searchAndFilter = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+            GridData gd_searchAndFilter =new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+//            gd_searchAndFilter.widthHint = 576;
+            searchAndFilter.setLayoutData(gd_searchAndFilter);
+            GridLayout searchAndFilterLayout = new GridLayout();
+            searchAndFilterLayout.numColumns = 2;
+            searchAndFilter.setLayout(searchAndFilterLayout);
+            searchField = new Text(searchAndFilter, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
             searchField.getAccessible().addAccessibleListener(new AccessibleAdapter() {
                 @Override
                 public void getName(AccessibleEvent e) {
@@ -164,12 +174,15 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
                     }
                 }
             });
-            gd_1 = new GridData(GridData.FILL_HORIZONTAL);
-            gd_1.horizontalIndent = 2;
-            gd_1.horizontalAlignment = SWT.CENTER;
-            gd_1.widthHint = 575;
+            gd_1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+
+//            gd_1.horizontalIndent = 2;
+//            gd_1.horizontalAlignment = SWT.CENTER;
+//            gd_1.grabExcessHorizontalSpace = true;
+//            gd_1.widthHint = 500;
             searchField.setLayoutData(gd_1);
 
+            createFilterButton(searchAndFilter);
             setList(new TableViewer(container,  SWT.SINGLE
                     | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
 
@@ -191,11 +204,15 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
                     okPressed();
                 }
             });
-            createExtendedContentArea(container);
+//            createExtendedContentArea(container);
+            new Label(container, SWT.NONE);
 
             return container;
         }
 
+
+        abstract void createFilterButton(Composite searchAndFilter) ;
+
         protected abstract void search();
 
         /**
@@ -205,7 +222,7 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
          *            parent to create the dialog widgets in
          * @return an extra content area
          */
-        protected abstract Control createExtendedContentArea(Composite parent);
+//        protected abstract Control createExtendedContentArea(Composite parent);
 
         /**
          * Sets the title for this dialog.
@@ -225,7 +242,7 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
          */
         private Label createHeader(Composite parent) {
             Composite header = new Composite(parent, SWT.NONE);
-            GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
+            GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
             gd_header.widthHint = 575;
             header.setLayoutData(gd_header);
 
@@ -234,9 +251,7 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
             layout.marginWidth = 0;
             layout.marginHeight = 0;
             header.setLayout(layout);
-
-            createViewMenu(header);
-
+            new Label(header, SWT.NONE);
             Label headerLabel = new Label(header, SWT.NONE);
             headerLabel.setText((getMessage() != null && getMessage().trim()
                     .length() > 0) ? getMessage()
@@ -256,8 +271,6 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
             gd_headerLabel.verticalAlignment = SWT.BOTTOM;
             gd_headerLabel.minimumHeight = 10;
             headerLabel.setLayoutData(gd_headerLabel);
-            new Label(header, SWT.NONE);
-
             return headerLabel;
         }
 
@@ -285,78 +298,88 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
             }
             return itemsListLabelProvider;
         }
-        private void createViewMenu(Composite parent) {
-            toolBar = new ToolBar(parent, SWT.FLAT);
-            toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
-
-            GridData data = new GridData();
-            data.horizontalAlignment = GridData.END;
-            data.grabExcessHorizontalSpace = true;
-            toolBar.setLayoutData(data);
-
-//            toolBar.addMouseListener(new MouseAdapter() {
+//        private void createViewMenu(Composite parent) {
+//            toolBar = new ToolBar(parent, SWT.FLAT);
+//
+//            GridData data = new GridData();
+//            data.horizontalAlignment = GridData.END;
+//            data.grabExcessHorizontalSpace = true;
+//            toolBar.setLayoutData(data);
+//
+//            menuManager = new MenuManager();
+//
+//            fillViewMenu(menuManager);
+//
+//            IHandlerService service = PlatformUI.getWorkbench()
+//                    .getService(IHandlerService.class);
+//            IHandler handler = new AbstractHandler() {
 //                @Override
-//                public void mouseDown(MouseEvent e) {
+//                public Object execute(ExecutionEvent event) {
 //                    showViewMenu();
+//                    return null;
 //                }
-//            });
+//            };
+//        }
+
+//        /**
+//         * Fills the menu of the dialog.
+//         *
+//         * @param menuManager
+//         *            the menu manager
+//         */
+//        protected void fillViewMenu(IMenuManager menuManager) {
+//
+//        }
+
+//        private void showViewMenu() {
+//            Menu menu = menuManager.createContextMenu(getShell());
+//            Rectangle bounds = toolItem.getBounds();
+//            Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
+//            topLeft = toolBar.toDisplay(topLeft);
+//            menu.setLocation(topLeft.x, topLeft.y);
+//            menu.setVisible(true);
+//        }
 
-            toolItem.setImage(WorkbenchImages
-                    .getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
-            toolItem
-                    .setToolTipText(WorkbenchMessages.FilteredItemsSelectionDialog_menu);
-            toolItem.addSelectionListener(new SelectionAdapter() {
-                @Override
-                public void widgetSelected(SelectionEvent e) {
-                    showViewMenu();
-                }
-            });
+        public TableViewer getList() {
+            return list;
+        }
 
-            menuManager = new MenuManager();
+        public void setList(TableViewer list) {
+            this.list = list;
+            Table table = list.getTable();
+            GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+            gd_table.heightHint = 231;
+            gd_table.widthHint = 543;
+            table.setLayoutData(gd_table);
+        }
 
-            fillViewMenu(menuManager);
+        public Button getNewButton1() {
+            return newButton1;
+        }
 
-            IHandlerService service = PlatformUI.getWorkbench()
-                    .getService(IHandlerService.class);
-            IHandler handler = new AbstractHandler() {
-                @Override
-                public Object execute(ExecutionEvent event) {
-                    showViewMenu();
-                    return null;
-                }
-            };
+
+        public void setNewButton1(Button newButton1) {
+            this.newButton1 = newButton1;
         }
 
-        /**
-         * Fills the menu of the dialog.
-         *
-         * @param menuManager
-         *            the menu manager
-         */
-        protected void fillViewMenu(IMenuManager menuManager) {
 
+        public Button getNewButton2() {
+            return newButton2;
         }
 
-        private void showViewMenu() {
-            Menu menu = menuManager.createContextMenu(getShell());
-            Rectangle bounds = toolItem.getBounds();
-            Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
-            topLeft = toolBar.toDisplay(topLeft);
-            menu.setLocation(topLeft.x, topLeft.y);
-            menu.setVisible(true);
+
+        public void setNewButton2(Button newButton2) {
+            this.newButton2 = newButton2;
         }
 
-        public TableViewer getList() {
-            return list;
+
+        public Button getFilterButton() {
+            return filterButton;
         }
 
-        public void setList(TableViewer list) {
-            this.list = list;
-            Table table = list.getTable();
-            GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1);
-            gd_table.heightHint = 231;
-            gd_table.widthHint = 543;
-            table.setLayoutData(gd_table);
+
+        public void setFilterButton(Button filterButton) {
+            this.filterButton = filterButton;
         }
 
         /**
@@ -796,6 +819,8 @@ public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements
         return new Point(593, 399);
     }
 
+
+
 }
 
 
index 092af2aeca4ee8ddddaed34c2d3e2416ded5a5cb..93fc8e292834ee53c50bc3c93a7a77513bab772b 100644 (file)
@@ -171,4 +171,9 @@ public class SelectionDialogFactory {
                return null;
        }
 
+       public static <T extends ICdmBase> T getSelectionFromExtDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, ICdmFormElement parentElement){
+           return (T) ExtReferenceSelectionDialog.select(shell, conversation, null);
+       }
+
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionViewMenu.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionViewMenu.java
new file mode 100755 (executable)
index 0000000..aff7c08
--- /dev/null
@@ -0,0 +1,75 @@
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.util.List;
+
+import org.eclipse.e4.ui.di.AboutToShow;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ * @author k.luther
+ * @date 20.11.2017
+ *
+ */
+public class SelectionViewMenu {
+
+    public static final String COMMAND_ID = "taxeditor-selection.command.selectViewMenu"; //$NON-NLS-1$
+    public static final String COMMAND_PARAMETER_VOCABULARY = COMMAND_ID+".vocabulary"; //$NON-NLS-1$
+    public static final String COMMAND_PARAMETER_VOCABULARY_STATE = COMMAND_ID+".state"; //$NON-NLS-1$
+
+    @AboutToShow
+    public void aboutToShow(List<MMenuElement> items, List<TermVocabulary> vocabularies) {
+
+        MMenu menu = MMenuFactory.INSTANCE.createMenu();
+        menu.setLabel(Messages.SelectionViewMenu_selectVocabulary);
+        items.add(menu);
+        for(TermVocabulary<NamedArea> vocabulary: vocabularies){
+            createMenuItem(menu, vocabulary);
+        }
+    }
+
+
+    private void createMenuItem(MMenu menu, final TermVocabulary<NamedArea> vocabulary) {
+
+        MMenu subMenu = MMenuFactory.INSTANCE.createMenu();
+        subMenu.setLabel(String.format(Messages.SelectionViewMenu_SET_FLAG, vocabulary.getLabel()));
+        menu.getChildren().add(subMenu);
+
+        MHandledMenuItem subMenuItemYes = MMenuFactory.INSTANCE.createHandledMenuItem();
+        subMenuItemYes.setLabel(Messages.SelectionViewMenu_4_YES);
+        MCommand mCommandYes = MCommandsFactory.INSTANCE.createCommand();
+        mCommandYes.setElementId(COMMAND_ID);
+        //set params
+        subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY, vocabulary);
+        subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY_STATE, true);
+        subMenuItemYes.setCommand(mCommandYes);
+        subMenu.getChildren().add(subMenuItemYes);
+
+        MHandledMenuItem subMenuItemNo = MMenuFactory.INSTANCE.createHandledMenuItem();
+        subMenuItemNo.setLabel(Messages.SelectionViewMenu_NO);
+        MCommand mCommandNo = MCommandsFactory.INSTANCE.createCommand();
+        mCommandNo.setElementId(COMMAND_ID);
+//        //set params
+//        subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_TYPE, markerType);
+//        subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_STATE, false);
+//        subMenuItemNo.setCommand(mCommandNo);
+//        subMenu.getChildren().add(subMenuItemNo);
+    }
+}
index 5faeaaf0e8c88ac29ba614f16077962871f9e406..41766afde64a9574547a8890d41c62706eae04ca 100644 (file)
@@ -60,7 +60,7 @@ public class SpecimenOrObservationBaseSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
+       protected String[] getNewWizardText() {
+               return new String[]{"field unit/derived unit"};
        }
 }
index 7366d6b30cc20489e6a7591a24cfb196523b2f3a..2a3fa60e7864258db0cc1317aa0fd632df87cd5d 100644 (file)
@@ -93,7 +93,7 @@ public class TaxonBaseSelectionDialog extends AbstractFilteredCdmResourceSelecti
 
     /** {@inheritDoc} */
     @Override
-    protected String getNewWizardLinkText() {
-        return String.format("Create a new <a>%1s</a>", "Taxon ");
+    protected String[] getNewWizardText() {
+        return new String[]{"Taxon "};
     }
 }
index aff448056bc52c62a47b703ed86601f261c76044..73e8689d142474f7ed90a2b1ec61333115306ab8 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.UUID;
 
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
@@ -63,13 +64,16 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
                if(classification != null){
                        selectedClassification = classification;
                }
-               search();
+
+               fillClassifications();
+               createClassificationSelectionCombo(shell);
        }
 
        /** {@inheritDoc} */
        @Override
-       protected Control createExtendedContentArea(Composite parent) {
-               return createClassificationSelectionCombo(parent);
+       protected Control createDialogArea(Composite parent) {
+           Composite container = (Composite) super.createDialogArea(parent);
+               return createClassificationSelectionCombo(container);
        }
 
        /*
@@ -134,7 +138,22 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
         }
 
 
-               if(classifications == null){
+//             fillClassifications();
+               if (pattern == null || pattern.equals("?")){
+                   model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), null, null);
+               }else{
+                   model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
+               }
+               try {
+            fillContentProvider(null);
+        } catch (CoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+       }
+
+    private void fillClassifications() {
+        if(classifications == null){
                        classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
                        Collections.sort(classifications, new Comparator<Classification>() {
 
@@ -156,12 +175,7 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
                            selectedClassification = this.cdmBaseToBeFiltered.getClassification();
                        }
                }
-               if (pattern == null || pattern.equals("?")){
-                   model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(),  limitOfInitialElements, pattern);
-               }else{
-                   model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(),  null, null);
-               }
-       }
+    }
 
        /** {@inheritDoc} */
        @Override
@@ -171,7 +185,7 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
+       protected String[] getNewWizardText() {
                return null;
        }
 
@@ -181,7 +195,9 @@ public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelecti
                selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
 
 //             refresh();
-               setPattern(null);
+               if (getSearchField().getText() != null){
+                   search();
+               }
        }
 
        /** {@inheritDoc} */
index 13d0b98b09e81dca7d0914663c128fdc79f1a208..a338b9528f1807ca8211c7e0af5b05e7ebddb1bb 100644 (file)
@@ -78,8 +78,8 @@ public class TeamSelectionDialog extends
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Team ");
+       protected String[] getNewWizardText() {
+               return new String[]{"Team "};
        }
 
        /** {@inheritDoc} */
index f2e4bbe5c5e44482c4fefbd9c81c5ccbe89b8392..e19be41f9b55351d1221fcae1da318748b625ac8 100644 (file)
@@ -75,8 +75,8 @@ public class UserSelectionDialog extends
         * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
         */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "User ");
+       protected String[] getNewWizardText() {
+               return new String[]{"User"};
        }
 
        /* (non-Javadoc)