- fixed the link in CollectionSelectionDialog and InstitutionSelectionDialog to...
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 3 Sep 2013 10:30:01 +0000 (10:30 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 3 Sep 2013 10:30:01 +0000 (10:30 +0000)
   - found strange bug in org.eclipse.swt.widgets.Link described in Ticket #3691

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/AbstractMenuPreferences.java
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/CollectionSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java

index f78483bd64ade4007c5559700ee8bb91f2b0d4d3..8eb85ef25e9967d6d34e2aa52d4ddaf962f8880f 100644 (file)
@@ -12,7 +12,6 @@ package eu.etaxonomy.taxeditor.preference.menu;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.core.commands.Command;
@@ -25,7 +24,6 @@ import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.viewers.CheckStateChangedEvent;
 import org.eclipse.jface.viewers.CheckboxTableViewer;
 import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -39,11 +37,9 @@ import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.internal.commands.Parameter;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
index 242af03207e4efce790bf86f87526b2d13f52f03..95a87cf5211b2cac8862c27141dcf26204e0d64c 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * 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.
 */
@@ -47,8 +47,8 @@ import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
@@ -61,19 +61,19 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmBase> extends
                FilteredItemsSelectionDialog implements IConversationEnabled {
 
-       private ConversationHolder conversation;
+       private final ConversationHolder conversation;
 
        protected List<UuidAndTitleCache<T>> model;
-       private Set<T> transientCdmObjects = new HashSet<T>();
-       private String settings;        
-       
+       private final Set<T> transientCdmObjects = new HashSet<T>();
+       private final String settings;
+
        protected T cdmBaseToBeFiltered;
-       
+
        /**
         * <p>Constructor for AbstractFilteredCdmResourceSelectionDialog.</p>
         *
         * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
-        * @param conversation 
+        * @param conversation
         * @param title a {@link java.lang.String} object.
         * @param multi a boolean.
         * @param settings a {@link java.lang.String} object.
@@ -85,29 +85,29 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                setTitle(title);
                setMessage("Use * for wildcard, or ? to see all entries");
                this.settings = settings;
-               
+
                this.conversation = conversation;
-               
+
                init();
-               
+
                initModel();
-               
+
                String objectTitle = getTitle(cdmObject);
                if (objectTitle != null) {
                        setInitialPattern(objectTitle);
                }
-               
+
                setListLabelProvider(createListLabelProvider());
                setDetailsLabelProvider(createDetailsLabelProvider());
-               
+
                setSelectionHistory(new ResourceSelectionHistory());
        }
-       
+
        /**
         * By default, we are returning the standard list label provider
-        * 
-        * Override in subclasses if you want different behavior 
-        * 
+        *
+        * Override in subclasses if you want different behavior
+        *
         * @return
         */
        protected ILabelProvider createDetailsLabelProvider() {
@@ -115,7 +115,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        }
 
        /**
-        * 
+        *
         * @return
         */
        protected ILabelProvider createListLabelProvider() {
@@ -127,9 +127,9 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * Will run before initModel()
         */
        protected void init() {
-               
+
        }
-       
+
        /**
         * <p>getSelectionFromDialog</p>
         *
@@ -140,18 +140,18 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        protected static <TYPE extends CdmBase> TYPE getSelectionFromDialog(AbstractFilteredCdmResourceSelectionDialog<TYPE> dialog) {
                //dialog.setInitialPattern("");
                int result = dialog.open();
-               
+
                if (result == Window.CANCEL) {
                        return null;
                }
-               
+
                UUID uuid = dialog.getSelectedUuidAndTitleCache().getUuid();
                if(uuid == null){
                        return null;
-               }       
+               }
                return dialog.getCdmObjectByUuid(uuid);
        }
-       
+
        /**
         * Check if object was created during the life of this dialog. If not,
         * retrieve it from the CdmStore.
@@ -167,7 +167,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                }
                return getPersistentObject(cdmUuid);
        }
-       
+
        /**
         * <p>getPersistentObject</p>
         *
@@ -204,16 +204,16 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                if(cdmObject == null){
                        return "";
                }
-               
+
                if (cdmObject instanceof IIdentifiableEntity) {
-                       return ((IIdentifiableEntity) cdmObject).getTitleCache();                       
+                       return ((IIdentifiableEntity) cdmObject).getTitleCache();
                }
-               
+
                throw new IllegalArgumentException("Generic method only" +
                                " supports cdmObject of type IIdentifiableEntity." +
                                " Please implement specific method in subclass.");
        }
-       
+
 
        /** {@inheritDoc} */
        @Override
@@ -222,7 +222,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                filterExcludedObjects();
                super.refresh();
        }
-       
+
        /**
         * <p>initModel</p>
         */
@@ -243,7 +243,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        public boolean equalsFilter(ItemsFilter filter) {
                                return false;
                        }
-                       
+
                        @Override
                        public boolean isConsistentItem(Object item) {
                                return false;
@@ -259,10 +259,10 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                                }
                                return text != null ? matches(text) : false;
                        }
-                       
+
                };
        }
-       
+
 
        /**
         * Set the filter input to the Agent's title cache
@@ -270,33 +270,33 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @param cdmObject a T object.
         */
        protected void setPattern(T cdmObject) {
-               // FilteredSelection does some very tricky caching to make sure it 
-               // runs with high performance. 
+               // FilteredSelection does some very tricky caching to make sure it
+               // runs with high performance.
                // This works for most use cases, but we want to change the model while the dialog is open
                // and all the clever caching prevents the content provider from knowing that the model has changed
-               // I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient 
+               // I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
                // way to solve the problem.
                try {
                        Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
                        lastCompletedFilter.setAccessible(true);
                        lastCompletedFilter.set(this, null);
                } catch (SecurityException e) {
-                       StoreUtil.error(getClass(), e);
+                       AbstractUtility.error(getClass(), e);
                } catch (NoSuchFieldException e) {
-                       StoreUtil.error(getClass(), e);
+                       AbstractUtility.error(getClass(), e);
                } catch (IllegalArgumentException e) {
-                       StoreUtil.error(getClass(), e);
+                       AbstractUtility.error(getClass(), e);
                } catch (IllegalAccessException e) {
-                       StoreUtil.error(getClass(), e);
+                       AbstractUtility.error(getClass(), e);
                }
-               
-               // this also is not the nicest way to do it. 
+
+               // this also is not the nicest way to do it.
                // I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
                // once it was opened. Am I doing it wrong?
                String pattern = getTitle(cdmObject);
                ((Text) getPatternControl()).setText(pattern);
        }
-       
+
        /* (non-Javadoc)
        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
        */
@@ -306,7 +306,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
                throws CoreException {
                try {
-                       if(model != null){                              
+                       if(model != null){
                                progressMonitor.beginTask("Looking for entities", model.size());
                                for(UuidAndTitleCache<T> element : model){
                                        contentProvider.add(element, itemsFilter);
@@ -316,7 +316,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                                        progressMonitor.worked(1);
                                }
                        }else{
-                               StoreUtil.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
+                               AbstractUtility.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
                        }
                }
                finally {
@@ -354,7 +354,8 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        @Override
        protected Comparator getItemsComparator() {
                return new Comparator<UuidAndTitleCache>() {
-                       public int compare(UuidAndTitleCache entity1,
+                       @Override
+            public int compare(UuidAndTitleCache entity1,
                                        UuidAndTitleCache entity2) {
                                Collator collator = Collator.getInstance();
                                return collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
@@ -370,7 +371,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        protected IStatus validateItem(Object item) {
                return Status.OK_STATUS;
        }
-       
+
        /**
         * <p>getSelectedUuidAndTitleCache</p>
         *
@@ -380,7 +381,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                Object[] result = getResult();
                return result[0] == null ? null : (UuidAndTitleCache) result[0];
        }
-       
+
        /**
         * <p>Getter for the field <code>settings</code>.</p>
         *
@@ -392,9 +393,9 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                }
                return settings;
        }
-       
+
        /**
-        * 
+        *
         * @author n.hoffmann
         * @created Oct 19, 2009
         * @version 1.0
@@ -403,39 +404,42 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
            /*
            * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
                */
-               protected Object restoreItemFromMemento(IMemento element) {
+               @Override
+        protected Object restoreItemFromMemento(IMemento element) {
                        return element.getString("resource"); //$NON-NLS-1$
                }
                /*
                 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
                 *      org.eclipse.ui.IMemento)
                 */
-               protected void storeItemToMemento(Object item, IMemento element) {
+               @Override
+        protected void storeItemToMemento(Object item, IMemento element) {
                        element.putString("resource", item.toString()); //$NON-NLS-1$
                }
        }
-       
+
        /**
         * <p>getNewWizardLinkText</p>
         *
         * @return a {@link java.lang.String} object.
         */
        protected abstract String getNewWizardLinkText();
-       
+
        /**
         * <p>getNewEntityWizard</p>
-        * @param parameter 
+        * @param parameter
         * @return a {@link eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard} object.
         */
        protected abstract AbstractNewEntityWizard getNewEntityWizard(String parameter);
-       
+
        public class FilteredCdmResourceLabelProvider extends LabelProvider {
-               public String getText(Object element) {
+               @Override
+        public String getText(Object element) {
                        if (element == null) {
                                return null;
                        }
                        return ((UuidAndTitleCache) element).getTitleCache();
-               }                       
+               }
        };
 
        /* (non-Javadoc)
@@ -444,33 +448,34 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        /** {@inheritDoc} */
        @Override
        protected Control createExtendedContentArea(Composite parent) {
-               if(getNewWizardLinkText() != null){
+               String newWizardLinkText = getNewWizardLinkText();
+        if(newWizardLinkText != null){
                        Link link = new Link(parent, SWT.NONE);
-                       link.setText(getNewWizardLinkText());
+                       link.setText(newWizardLinkText);
                        link.addSelectionListener(getNewWizardLinkSelectionListener());
                        return link;
                }
                return null;
        }
-       
+
        protected SelectionListener getNewWizardLinkSelectionListener(){
                return new SelectionAdapter() {
-                       
+
                        /* (non-Javadoc)
                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
                         */
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-                               
+
                                AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
                                wizard.init(null, null);
                                WizardDialog dialog = new WizardDialog(getShell(), wizard);
                                int status = dialog.open();
-                               
+
                                if (status == IStatus.OK) {
-                                       
+
                                        T entity = (T) wizard.getEntity();
-                                       
+
 //                                     addObjectToModel(teamOrPerson);
                                        refresh();
                                        setPattern(entity);
@@ -479,34 +484,36 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        }
                };
        }
-       
+
        /**
         * <p>getConversationHolder</p>
         *
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
         */
-       public ConversationHolder getConversationHolder() {
+       @Override
+    public ConversationHolder getConversationHolder() {
                return conversation;
        }
-       
+
        /** {@inheritDoc} */
-       public void update(CdmDataChangeMap changeEvents) {}
+       @Override
+    public void update(CdmDataChangeMap changeEvents) {}
 
        /**
-        * Don't want to add for example a taxon or synonym to itself 
-        * so filter the list to remove the taxon in question 
+        * Don't want to add for example a taxon or synonym to itself
+        * so filter the list to remove the taxon in question
         * (<code>cdmBaseToBeFiltered</code>)
         * so it is not available in the filtered list.
         */
        private void filterExcludedObjects() {
                if (model != null && cdmBaseToBeFiltered != null) {
-                       
+
                        UuidAndTitleCache uuidAndTitleCacheToRemove = null;
-                                               
+
                        for (UuidAndTitleCache uuidAndTitleCache : model){
                                if ((cdmBaseToBeFiltered.getUuid()).equals(uuidAndTitleCache.getUuid())) {
                                        uuidAndTitleCacheToRemove = uuidAndTitleCache;
-                               }                               
+                               }
                        }
                        model.remove(uuidAndTitleCacheToRemove);
                }
index 02ef9358356afab0b44f5058b78ad24ae51e4f6f..15f0798b25937fa5056197f24ee664759f5e7ff4 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * 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.
 */
@@ -30,7 +30,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class CollectionSelectionDialog extends
                AbstractFilteredCdmResourceSelectionDialog<Collection> {
-       
+
        /**
         * <p>select</p>
         *
@@ -44,7 +44,7 @@ public class CollectionSelectionDialog extends
                                "Choose Collection", false, CollectionSelectionDialog.class.getCanonicalName(), collection);
                return getSelectionFromDialog(dialog);
        }
-       
+
        /**
         * <p>Constructor for FilteredCollectionSelectionDialog.</p>
         *
@@ -85,7 +85,7 @@ public class CollectionSelectionDialog extends
        /** {@inheritDoc} */
        @Override
        protected String getNewWizardLinkText() {
-               return "Click link to create a new <A>Collection</A>.";
+        return String.format("Click link to create a new <a>%1s</a>", "Collection ");
        }
 
        /* (non-Javadoc)
@@ -97,5 +97,5 @@ public class CollectionSelectionDialog extends
                return new NewCollectionWizard();
        }
 
-       
+
 }
index a76039c7e2ba9a65aff2617a4268c94890b481a7..9312db0b6cc1f1f52610d915cf76ada41357d4fe 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * 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.
 */
@@ -35,7 +35,7 @@ public class InstitutionSelectionDialog extends
                                "Choose Institution", false, TeamSelectionDialog.class.getCanonicalName(), institution);
                return getSelectionFromDialog(dialog);
        }
-       
+
        /**
         * @param shell
         * @param conversation
@@ -56,7 +56,7 @@ public class InstitutionSelectionDialog extends
        @Override
        protected Institution getPersistentObject(UUID uuid) {
                AgentBase agentBase = CdmStore.getService(IAgentService.class).load(uuid);
-               
+
                if(agentBase instanceof Institution){
                        return (Institution) agentBase;
                }
@@ -76,7 +76,7 @@ public class InstitutionSelectionDialog extends
         */
        @Override
        protected String getNewWizardLinkText() {
-               return "Create a new <A>Institution</A>.";
+               return "Create a new <a>Institution</a>.";
        }
 
        /* (non-Javadoc)