- added id to entity selection dialogs (#4799)
authorPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 May 2015 07:04:04 +0000 (07:04 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Tue, 26 May 2015 07:04:04 +0000 (07:04 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/TaxonomicEditorGeneralPreferences.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java

index c34d4b7e0f3e6ed5f26fdda6f0c443cdaefff8d9..337849c0f206aaca2beced51edfbcfd21d351468 100644 (file)
@@ -50,6 +50,11 @@ public interface IPreferenceKeys {
         */
        public static final String SHOW_DEBUG_INFORMATION = "eu.etaxonomy.taxeditor.showDebugInformation";
 
+       /**
+        * Whether to show UUID and database id in the supplemental data view.
+        */
+       public static final String SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG = "eu.etaxonomy.taxeditor.showIdInEntitySelectionDiaolog";
+
        /**
         *
         */
@@ -91,7 +96,7 @@ public interface IPreferenceKeys {
        public static final String SORT_RANKS_HIERARCHICHALLY = "eu.etaxonomy.taxeditor.menus.sortRanksHierarchichally";
        /** Constant <code>SORT_NODES_NATURALL="eu.etaxonomy.taxeditor.menus.sortNodesN"{trunked}</code> */
        public static final String SORT_NODES_NATURALLY = "eu.etaxonomy.taxeditor.menus.sortNodesNaturally";
-       
+
        /**
         * Whether multilanguage text fields should be editable in multiple languages.
         */
index 08a1a367308c19c7c7334415fbdc312c69a4cb93..cae829782409e61fa6bb5b1322e280d6342512a8 100644 (file)
@@ -40,6 +40,9 @@ public class TaxonomicEditorGeneralPreferences extends
                addField(new BooleanFieldEditor(IPreferenceKeys.SHOW_DEBUG_INFORMATION,
                                "Show UUID and object ID in supplemental data view.",
                                getFieldEditorParent()));
+               addField(new BooleanFieldEditor(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG,
+                       "Show object id in entity selection dialogs.",
+                       getFieldEditorParent()));
                addField(new BooleanFieldEditor(
                                IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE,
                                "Should expand sections when data is available (Details View). This might make the Editor slow.",
index dcb689d0ef5de5a1a93250d8aaeea96d768468f9..b70352309f56e6dee40ba63e35cfd9eb6219163a 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.
 */
@@ -49,6 +49,8 @@ import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
@@ -66,14 +68,14 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        protected List<UuidAndTitleCache<T>> model;
        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 +87,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 +117,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        }
 
        /**
-        * 
+        *
         * @return
         */
        protected ILabelProvider createListLabelProvider() {
@@ -127,9 +129,9 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * Will run before initModel()
         */
        protected void init() {
-               
+
        }
-       
+
        /**
         * <p>getSelectionFromDialog</p>
         *
@@ -140,18 +142,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 +169,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                }
                return getPersistentObject(cdmUuid);
        }
-       
+
        /**
         * <p>getPersistentObject</p>
         *
@@ -204,16 +206,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 +224,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                filterExcludedObjects();
                super.refresh();
        }
-       
+
        /**
         * <p>initModel</p>
         */
@@ -243,7 +245,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 +261,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,11 +272,11 @@ 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");
@@ -289,14 +291,14 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                } catch (IllegalAccessException e) {
                        MessagingUtils.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 +308,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);
@@ -371,7 +373,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        protected IStatus validateItem(Object item) {
                return Status.OK_STATUS;
        }
-       
+
        /**
         * <p>getSelectedUuidAndTitleCache</p>
         *
@@ -381,7 +383,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>
         *
@@ -393,9 +395,9 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                }
                return settings;
        }
-       
+
        /**
-        * 
+        *
         * @author n.hoffmann
         * @created Oct 19, 2009
         * @version 1.0
@@ -417,29 +419,34 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        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 {
                @Override
                public String getText(Object element) {
                        if (element == null) {
                                return null;
                        }
-                       return ((UuidAndTitleCache) element).getTitleCache();
-               }                       
+                       UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache) element;
+                       String titleCache = uuidAndTitleCache.getTitleCache();
+                       if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_DEBUG_INFORMATION)){
+                           titleCache += " ["+uuidAndTitleCache.getId()+"]";
+                       }
+            return titleCache;
+               }
        };
 
        /* (non-Javadoc)
@@ -457,10 +464,10 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                }
                return null;
        }
-       
+
        protected SelectionListener getNewWizardLinkSelectionListener(){
                return new SelectionAdapter() {
-                       
+
                        /* (non-Javadoc)
                         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
                         */
@@ -487,7 +494,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        }
                };
        }
-       
+
        /**
         * <p>getConversationHolder</p>
         *
@@ -497,26 +504,26 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        public ConversationHolder getConversationHolder() {
                return conversation;
        }
-       
+
        /** {@inheritDoc} */
        @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);
                }