Transfering workplace to new machine
authorn.hoffmann <n.hoffmann@localhost>
Tue, 4 Oct 2011 08:37:01 +0000 (08:37 +0000)
committern.hoffmann <n.hoffmann@localhost>
Tue, 4 Oct 2011 08:37:01 +0000 (08:37 +0000)
eu.etaxonomy.taxeditor.cdmlib/.classpath
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/SimpleSelectionProvider.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmEditorViewPart.java

index 4143a5c44367878cdc596395f03fadf377d46832..fd4178ae5cb58c38c24ba9860e81ba666e9da525 100644 (file)
@@ -3,7 +3,7 @@
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-commons-3.0.9-SNAPSHOT.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-ext-3.0.9-SNAPSHOT.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-io-3.0.9-SNAPSHOT.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.9-SNAPSHOT.jar" sourcepath="/Users/n.hoffmann/.m2/repository/eu/etaxonomy/cdmlib-model/3.0.9-SNAPSHOT/cdmlib-model-3.0.9-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.9-SNAPSHOT.jar" sourcepath="/Users/n.hoffmann/.m2/repository/eu/etaxonomy/cdmlib-persistence/3.0.9-SNAPSHOT/cdmlib-persistence-3.0.9-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.0.9-SNAPSHOT.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.9-SNAPSHOT.jar"/>
index 3621107b92f8835dcc57daad413901f9e5de1522..122844fb908652cb7b70943ff4502abe27a3e461 100644 (file)
@@ -1,11 +1,11 @@
 /**
-* Copyright (C) 2007 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.
-*/
+ * Copyright (C) 2007 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.editor;
 
@@ -40,16 +40,18 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 
 /**
- *
- * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs for
- *  "Descriptions", "Concepts", "Geography", etc.
- *
+ * 
+ * Generates the tabbed editor with <code>TaxonNameEditor</code> on top and tabs
+ * for "Descriptions", "Concepts", "Geography", etc.
+ * 
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 15.05.2008
  * @version 1.0
  */
-public class MultiPageTaxonEditor extends FormEditor implements IConversationEnabled, IPostOperationEnabled, IDirtyMarkableSelectionProvider, IPartContentHasDetails { 
+public class MultiPageTaxonEditor extends FormEditor implements
+               IConversationEnabled, IPostOperationEnabled,
+               IDirtyMarkableSelectionProvider, IPartContentHasDetails {
 
        /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.taxon"{trunked}</code> */
        public static final String ID = "eu.etaxonomy.taxeditor.editor.taxon";
@@ -61,24 +63,28 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
        private IUndoContext undoContext;
 
        private TaxonEditorInput input;
-       
+
        /**
-        * <p>Constructor for MultiPageTaxonEditor.</p>
+        * <p>
+        * Constructor for MultiPageTaxonEditor.
+        * </p>
         */
        public MultiPageTaxonEditor() {
-               super();                
+               super();
                undoContext = new UndoContext();
        }
-       
+
        /** {@inheritDoc} */
        @Override
        public void dispose() {
                conversation.unregisterForDataStoreChanges(this);
                conversation.close();
-               super.dispose();                
+               super.dispose();
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
         */
        /** {@inheritDoc} */
@@ -87,88 +93,103 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
                input = (TaxonEditorInput) getEditorInput();
                conversation = input.getConversationHolder();
                conversation.registerForDataStoreChanges(this);
-               
+
                try {
-                       addPage(Page.NAME.getIndex(), new TaxonNameEditor(this), getEditorInput());
-//                     setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
-                       
+                       addPage(Page.NAME.getIndex(), new TaxonNameEditor(this),
+                                       getEditorInput());
+                       // setPageText(Page.NAME.getIndex(), Page.NAME.getTitle());
+
                        // TODO lazy create
-//                     addPage(Page.DESCRIPTIVE.getIndex(), new TaxonDescriptionTreeEditor(this), getEditorInput());
-//                     setPageText(Page.DESCRIPTIVE.getIndex(), Page.DESCRIPTIVE.getTitle());
-                       
-//                     EditorUtil.showPropertySheet();
-                                       
+                       // addPage(Page.DESCRIPTIVE.getIndex(), new
+                       // TaxonDescriptionTreeEditor(this), getEditorInput());
+                       // setPageText(Page.DESCRIPTIVE.getIndex(),
+                       // Page.DESCRIPTIVE.getTitle());
+
+                       // EditorUtil.showPropertySheet();
+
                } catch (PartInitException e) {
                        EditorUtil.error(getClass(), e);
                }
        }
-       
-       
+
        /** {@inheritDoc} */
        @Override
        public void doSave(IProgressMonitor monitor) {
                monitor.beginTask("Saving Editor", 4);
-               try{
-                       if( ! conversation.isBound()){
+               try {
+                       if (!conversation.isBound()) {
                                conversation.bind();
                        }
                        monitor.worked(1);
-                       
-                       for(IEditorPart editorPage : getPages()){
-                               if(editorPage instanceof TaxonNameEditor){
-                                       if(((TaxonNameEditor) editorPage).checkForEmptyNames()){
-                                               MessageDialog.openWarning(EditorUtil.getShell(), "No Name Specified", "An attempt was made to save a taxon or synonym with " +
-                                               "an empty name. Operation was cancelled.");
+
+                       for (IEditorPart editorPage : getPages()) {
+                               if (editorPage instanceof TaxonNameEditor) {
+                                       if (((TaxonNameEditor) editorPage).checkForEmptyNames()) {
+                                               MessageDialog
+                                                               .openWarning(
+                                                                               EditorUtil.getShell(),
+                                                                               "No Name Specified",
+                                                                               "An attempt was made to save a taxon or synonym with "
+                                                                                               + "an empty name. Operation was cancelled.");
                                                return;
                                        }
                                }
-       
+
                                editorPage.doSave(monitor);
                                monitor.worked(1);
                        }
-                       
+
                        // commit the conversation and start a new transaction immediately
                        conversation.commit(true);
                        monitor.worked(1);
-                       
+
                        this.setDirty(false);
                        monitor.worked(1);
-               }catch(Exception e){
-                       EditorUtil.errorDialog("An error occurred while saving", getClass(), "An error occurred while saving the editor. Please close and reopen the taxon again.", e);
+               } catch (Exception e) {
+                       setFocus();
+                       EditorUtil
+                                       .errorDialog(
+                                                       "An error occurred while saving",
+                                                       getClass(),
+                                                       "An error occurred while saving the editor. Please close and reopen the taxon again.",
+                                                       e);
                        disableEditor();
-               }finally{
+               } finally {
                        monitor.done();
                }
        }
 
-
        private void disableEditor() {
-               for(IMultiPageTaxonEditorPage editorPage : getPages()){
+               for (IMultiPageTaxonEditorPage editorPage : getPages()) {
                        editorPage.setDisabled();
                }
                setDirty(false);
-               getSite().getSelectionProvider().setSelection(new StructuredSelection());
-               getSite().setSelectionProvider(null);
        }
 
        private void setDirty(boolean dirty) {
                this.dirty = dirty;
                firePropertyChange(PROP_DIRTY);
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.part.MultiPageEditorPart#isDirty()
         */
        /**
-        * <p>isDirty</p>
-        *
+        * <p>
+        * isDirty
+        * </p>
+        * 
         * @return a boolean.
         */
        public boolean isDirty() {
                return dirty;
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.forms.editor.FormEditor#editorDirtyStateChanged()
         */
        /** {@inheritDoc} */
@@ -177,16 +198,18 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
                dirty = true;
                super.editorDirtyStateChanged();
        }
-       
-       
+
        /**
         * {@inheritDoc}
-        *
-        * Checks whether nested editors are calling <code>firePropertyChange(PROP_DIRTY)</code>
-        * to signal an edit has taken place before passing property change along to
+        * 
+        * Checks whether nested editors are calling
+        * <code>firePropertyChange(PROP_DIRTY)</code> to signal an edit has taken
+        * place before passing property change along to
         * <code>super.handlePropertyChange(int propertyId)</code>.
         */
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.part.MultiPageEditorPart#handlePropertyChange(int)
         */
        protected void handlePropertyChange(int propertyId) {
@@ -195,10 +218,11 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
                }
                super.handlePropertyChange(propertyId);
        }
-       
+
        /** {@inheritDoc} */
        @Override
-       public void doSaveAs() {}
+       public void doSaveAs() {
+       }
 
        /** {@inheritDoc} */
        @Override
@@ -208,129 +232,148 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
 
        /** {@inheritDoc} */
        @Override
-       public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-               
+       public void init(IEditorSite site, IEditorInput input)
+                       throws PartInitException {
+
                if (!(input instanceof TaxonEditorInput))
                        throw new PartInitException(
                                        "Invalid Input: Must be TaxonEditorInput");
-               
+
                this.input = (TaxonEditorInput) input;
 
-//             try {
-//                     // Listen for name changes, 
-//                     //  change tab for this taxon editor accordingly
-//                     getTaxon().addPropertyChangeListener("name",
-//                                     new PropertyChangeListener() {
-//                                             public void propertyChange(PropertyChangeEvent e) {
-//                                                     setPartName();
-//                                             }
-//                                     });
-//             } catch (NullPointerException e) {
-//                     EditorUtil.warn(getClass(), "Caught an NPE while initing an editor. This is most " +
-//                                     "likely due to the unsuccesful attempt to restore the former " +
-//                                     "state of the application. We ignore this because the workbench " +
-//                                     "will simply be reset.");
-//             }
+               // try {
+               // // Listen for name changes,
+               // // change tab for this taxon editor accordingly
+               // getTaxon().addPropertyChangeListener("name",
+               // new PropertyChangeListener() {
+               // public void propertyChange(PropertyChangeEvent e) {
+               // setPartName();
+               // }
+               // });
+               // } catch (NullPointerException e) {
+               // EditorUtil.warn(getClass(),
+               // "Caught an NPE while initing an editor. This is most " +
+               // "likely due to the unsuccesful attempt to restore the former " +
+               // "state of the application. We ignore this because the workbench " +
+               // "will simply be reset.");
+               // }
                setPartName();
-               
+
                super.init(site, input);
        }
-               
-    /**
-     * Calls <code>MultiPageEditorPart.setPartName(String partName)</code>
-     *  with text appropriate to the state of the taxon: any taxon that has
-     *  been saved will by necessity have a name to display; a new taxon
-     *  should display "New taxon" in the editor tab.
-     */
-    protected void setPartName() {
-        
-       String partName = null;
-       TaxonNameBase<?, ?> name = getTaxon().getName();
-       
-       if (name != null) {
-               partName = name.getTitleCache();
-       }
-       
-       if (partName == null || partName.equals("")) {
-               partName = ("New taxon");
-       }
-
-        setPartName(partName);
-    }
-    
-    /**
-     * {@inheritDoc}
-     *
-     * Editor pages call this in their postOperation to notify the MultiPageTaxonEditor
-     * of unsaved changes
-     */
-    public void changed(Object element) {
-//     setDirty(true);
+
+       /**
+        * Calls <code>MultiPageEditorPart.setPartName(String partName)</code> with
+        * text appropriate to the state of the taxon: any taxon that has been saved
+        * will by necessity have a name to display; a new taxon should display
+        * "New taxon" in the editor tab.
+        */
+       protected void setPartName() {
+
+               String partName = null;
+               TaxonNameBase<?, ?> name = getTaxon().getName();
+
+               if (name != null) {
+                       partName = name.getTitleCache();
+               }
+
+               if (partName == null || partName.equals("")) {
+                       partName = ("New taxon");
+               }
+
+               setPartName(partName);
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * Editor pages call this in their postOperation to notify the
+        * MultiPageTaxonEditor of unsaved changes
+        */
+       public void changed(Object element) {
+               // setDirty(true);
                dirty = true;
                super.editorDirtyStateChanged();
-               if(element instanceof TaxonBase){
+               if (element instanceof TaxonBase) {
                        TaxonNameEditor page = (TaxonNameEditor) getPage(Page.NAME);
-                       AbstractGroupedContainer container = page.getContainer((TaxonBase) element);
-                       if(container != null){
+                       AbstractGroupedContainer container = page
+                                       .getContainer((TaxonBase) element);
+                       if (container != null) {
                                container.refresh();
                        }
                }
-    }
-    
-    /**
-     * The accepted taxon that is the input for this editor
-     *
-     * @return the accepted taxon
-     */
-    public Taxon getTaxon(){
-       return input.getTaxon();
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
-     */
+       }
+
+       /**
+        * The accepted taxon that is the input for this editor
+        * 
+        * @return the accepted taxon
+        */
+       public Taxon getTaxon() {
+               return input.getTaxon();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
+        * ()
+        */
        /**
-        * <p>getConversationHolder</p>
-        *
-        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+        * <p>
+        * getConversationHolder
+        * </p>
+        * 
+        * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *         object.
         */
        public ConversationHolder getConversationHolder() {
                return conversation;
        }
-       
+
        /**
-        * <p>setConversationHolder</p>
-        *
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+        * <p>
+        * setConversationHolder
+        * </p>
+        * 
+        * @param conversation
+        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *            object.
         */
-       public void setConversationHolder(ConversationHolder conversation){
+       public void setConversationHolder(ConversationHolder conversation) {
                this.conversation = conversation;
        }
 
-
        /**
-        * <p>Getter for the field <code>undoContext</code>.</p>
-        *
-        * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+        * <p>
+        * Getter for the field <code>undoContext</code>.
+        * </p>
+        * 
+        * @return a {@link org.eclipse.core.commands.operations.IUndoContext}
+        *         object.
         */
        public IUndoContext getUndoContext() {
                return undoContext;
        }
 
        /**
-        * <p>Setter for the field <code>undoContext</code>.</p>
-        *
-        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+        * <p>
+        * Setter for the field <code>undoContext</code>.
+        * </p>
+        * 
+        * @param undoContext
+        *            a {@link org.eclipse.core.commands.operations.IUndoContext}
+        *            object.
         */
        public void setUndoContext(IUndoContext undoContext) {
                this.undoContext = undoContext;
        }
-       
+
        /** {@inheritDoc} */
        @Override
-       public void setFocus(){
-               //logger.warn("Setting focus to editor");
+       public void setFocus() {
+               // logger.warn("Setting focus to editor");
                // bind the conversation
                getConversationHolder().bind();
                // pass focus to the active editor page
@@ -339,94 +382,111 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
 
        /*
         * (non-Javadoc)
-        * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
+        * 
+        * @see
+        * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostCrudObserver#update(eu
+        * .etaxonomy.cdm.persistence.hibernate.CdmCrudEvent)
         */
        /** {@inheritDoc} */
        public void update(CdmDataChangeMap events) {
-               if(dataChangeBehavior == null){
-                       dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(this);
+               if (dataChangeBehavior == null) {
+                       dataChangeBehavior = new MultiPageTaxonEditorDataChangeBehaviour(
+                                       this);
                }
-               
+
                DataChangeBridge.handleDataChange(events, dataChangeBehavior);
        }
 
-
        /*
         * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation()
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.store.operations.IPostOperationEnabled#postOperation
+        * ()
         */
        /** {@inheritDoc} */
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                setDirty(true);
-               
-               for(IEditorPart editor : this.getPages()){
+
+               for (IEditorPart editor : this.getPages()) {
                        if (editor instanceof IPostOperationEnabled) {
-                               ((IPostOperationEnabled) editor).postOperation(objectAffectedByOperation);
+                               ((IPostOperationEnabled) editor)
+                                               .postOperation(objectAffectedByOperation);
                        } else {
-                               EditorUtil.warn(getClass(), "postOperation not enabled for editor " + editor);
+                               EditorUtil.warn(getClass(),
+                                               "postOperation not enabled for editor " + editor);
                        }
                }
-               EditorUtil.warn(getClass(), "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
-               
+               EditorUtil
+                               .warn(getClass(),
+                                               "postOperation called on MultiPageTaxonEditor. Can you make it more specific?");
+
                return false;
        }
-       
+
        /**
         * Returns an <code>IEditorPart</code> implementation by type
-        *
-        * @param page the page type
-        * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage} object.
+        * 
+        * @param page
+        *            the page type
+        * @return a {@link eu.etaxonomy.taxeditor.editor.IMultiPageTaxonEditorPage}
+        *         object.
         */
-       public IMultiPageTaxonEditorPage getPage(Page page){
-               for(IEditorPart editor : this.getPages()){
-                       if(editor.getClass().equals(page.getClazz())){
-                               return (IMultiPageTaxonEditorPage) editor;
-                       }
+       public IMultiPageTaxonEditorPage getPage(Page page) {
+               for (IEditorPart editor : this.getPages()) {
+                       if (editor.getClass().equals(page.getClazz())) {
+                               return (IMultiPageTaxonEditorPage) editor;
+                       }
                }
                return null;
        }
-       
+
        /**
         * Return a list of <code>AbstractTaxonEditor</code>s registered with this
         * <code>MultiPageTaxonEditor</code>.
-        *
+        * 
         * @return a {@link java.util.List} object.
         */
-       public List<IMultiPageTaxonEditorPage> getPages(){
+       public List<IMultiPageTaxonEditorPage> getPages() {
                ArrayList<IMultiPageTaxonEditorPage> editors = new ArrayList<IMultiPageTaxonEditorPage>();
-               for(int i = 0; i < this.getPageCount(); i++){
-                       
-                       editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
+               for (int i = 0; i < this.getPageCount(); i++) {
+
+                       editors.add((IMultiPageTaxonEditorPage) this.getEditor(i));
                }
                return editors;
        }
-       
+
        /**
         * Refreshes a certain page of the MultipageTaxonEditor
-        *
-        * @param page a {@link eu.etaxonomy.taxeditor.editor.Page} object.
+        * 
+        * @param page
+        *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
         * @return a boolean.
         */
-       public boolean redraw(Page page){
+       public boolean redraw(Page page) {
                return redraw(page, true);
        }
-       
+
        /**
-        * Refreshes a certain page of the MultipageTaxonEditor and
-        * sets focus to that page
-        *
-        * @param page a {@link eu.etaxonomy.taxeditor.editor.Page} object.
-        * @param focus a boolean.
+        * Refreshes a certain page of the MultipageTaxonEditor and sets focus to
+        * that page
+        * 
+        * @param page
+        *            a {@link eu.etaxonomy.taxeditor.editor.Page} object.
+        * @param focus
+        *            a boolean.
         * @return a boolean.
         */
-       public boolean redraw(Page page, boolean focus){
+       public boolean redraw(Page page, boolean focus) {
                IMultiPageTaxonEditorPage editorPage = getPage(page);
                return editorPage != null && editorPage.redraw(focus);
        }
 
        /**
-        * <p>onComplete</p>
-        *
+        * <p>
+        * onComplete
+        * </p>
+        * 
         * @return a boolean.
         */
        public boolean onComplete() {
@@ -434,29 +494,34 @@ public class MultiPageTaxonEditor extends FormEditor implements IConversationEna
        }
 
        /**
-        * Reloads the data for this 
+        * Reloads the data for this
         */
        public void reload() {
-               if(isDirty()){
-                       EditorUtil.warningDialog("Editor has unsaved data", getClass(), "This editor can not be " +
-                                       "refreshed because it contains unsaved data. Refreshing " +
-                                       "this editor would discard the changes. Please save this editor, " +
-                                       "close and reopen it manually in order to get the latest content");
-               }else{
+               if (isDirty()) {
+                       EditorUtil
+                                       .warningDialog(
+                                                       "Editor has unsaved data",
+                                                       getClass(),
+                                                       "This editor can not be "
+                                                                       + "refreshed because it contains unsaved data. Refreshing "
+                                                                       + "this editor would discard the changes. Please save this editor, "
+                                                                       + "close and reopen it manually in order to get the latest content");
+               } else {
                        TaxonEditorInput input = (TaxonEditorInput) getEditorInput();
-                       
+
                        UUID uuid = input.getTaxonNode().getUuid();
-                       
+
                        conversation.clear();
-                       
+
                        try {
                                TaxonEditorInput newInput = TaxonEditorInput.NewInstance(uuid);
                                setInput(newInput);
-                               for(IMultiPageTaxonEditorPage editorPart : getPages()){
+                               for (IMultiPageTaxonEditorPage editorPart : getPages()) {
                                        editorPart.redraw();
                                }
                        } catch (Exception e) {
-                               EditorUtil.errorDialog("Error refreshing editor", getClass(), "Could not refresh this editor", e);
+                               EditorUtil.errorDialog("Error refreshing editor", getClass(),
+                                               "Could not refresh this editor", e);
                        }
                }
        }
index 31ac83f1e1aa1e68529bb651acdc6b9d4a352334..a1c38a7db597cc9d69136574534ffa9080e4f643 100644 (file)
@@ -9,9 +9,11 @@
 
 package eu.etaxonomy.taxeditor.editor;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.eclipse.core.runtime.IProgressMonitor;
 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.util.SafeRunnable;
@@ -32,7 +34,7 @@ import org.eclipse.swt.widgets.Display;
  */
 public class SimpleSelectionProvider implements ISelectionProvider {
 
-       private ListenerList selectionChangedListeners = new ListenerList();
+       private Set<ISelectionChangedListener> selectionChangedListeners = new HashSet<ISelectionChangedListener>();
        private ISelection selection;
        private Job job;
        
@@ -84,7 +86,9 @@ public class SimpleSelectionProvider implements ISelectionProvider {
                
                // cancel previous selection setting
                if(job != null){
-                       job.cancel();
+                       if(job.getState() != Job.NONE){
+                               job.cancel();
+                       }
                        job = null;
                }
                
@@ -101,7 +105,7 @@ public class SimpleSelectionProvider implements ISelectionProvider {
                                                display.asyncExec(new Runnable() {
                                         
                                                        public void run() {
-                                                               fireSelectionChanged(selectionChangedEvent);
+                                                               SimpleSelectionProvider.this.fireSelectionChanged(selectionChangedEvent);
                                                        }
                                                });
                                        }
@@ -119,12 +123,10 @@ public class SimpleSelectionProvider implements ISelectionProvider {
 
        private void fireSelectionChanged(final SelectionChangedEvent event) {
                
-               Object[] listeners = selectionChangedListeners.getListeners();
-               for (int i = 0; i < listeners.length; ++i) {
-                       final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
+               for (final ISelectionChangedListener listener : selectionChangedListeners) {
                        SafeRunnable.run(new SafeRunnable() {
                                public void run() {
-                                       l.selectionChanged(event);
+                                       listener.selectionChanged(event);
                                }
                        });
                }
index 8499008725edae40d637ca4521f0d6e9b621a89a..85d93d9f296756ae33702033ed9c779641af5e2d 100644 (file)
@@ -98,7 +98,7 @@ public class TaxonNameEditor extends EditorPart implements
        private ManagedForm managedForm;
        private ScrolledForm scrolledForm;
        private Composite parent;
-       private ISelectionProvider selectionProvider;
+       private ISelectionProvider simpleSelectionProvider;
 
        private final MultiPageTaxonEditor editor;
 
@@ -191,7 +191,12 @@ public class TaxonNameEditor extends EditorPart implements
                                if (input instanceof AbstractGroupedContainer) {
                                        selection = ((AbstractGroupedContainer) input).getData();
                                        getSite().getSelectionProvider().setSelection(new StructuredSelection(selection));
+                               }else if(input == null){
+                                       selection = null;
+                                       getSite().getSelectionProvider().setSelection(new StructuredSelection());
                                }
+                               
+                               
                                return super.setInput(input);
                        }
                };
@@ -493,8 +498,8 @@ public class TaxonNameEditor extends EditorPart implements
                setSite(site);
                setInput(input);
 
-               selectionProvider = new SimpleSelectionProvider();
-               getSite().setSelectionProvider(selectionProvider);
+               simpleSelectionProvider = new SimpleSelectionProvider();
+               getSite().setSelectionProvider(simpleSelectionProvider);
        }
 
        /**
@@ -918,36 +923,6 @@ public class TaxonNameEditor extends EditorPart implements
                }
                
                // send an empty selection to the current provider
-               selectionProvider.setSelection(new StructuredSelection());
-               
-               // decide on the new selection provider
-               
-               ISelectionProvider newSelectionProvider = enabled ? selectionProvider : new ISelectionProvider() {
-                       
-                       @Override
-                       public void setSelection(ISelection selection) {
-                               
-                       }
-                       
-                       @Override
-                       public void removeSelectionChangedListener(
-                                       ISelectionChangedListener listener) {
-                               
-                       }
-                       
-                       @Override
-                       public ISelection getSelection() {
-                               return null;
-                       }
-                       
-                       @Override
-                       public void addSelectionChangedListener(ISelectionChangedListener listener) {
-                               
-                       }
-               };
-               
-               getSite().setSelectionProvider(newSelectionProvider);
-               
-               System.out.println("SELECTION PROVIDER" + getSite().getSelectionProvider());
+               getManagedForm().setInput(null);
        }
 }
index e75e6d1adcad0b36d45751d15351721503ebf43f..afa592fa171aa06f0426f840532ede686655fd36 100644 (file)
@@ -33,10 +33,6 @@ public abstract class AbstractCdmEditorViewPart extends AbstractCdmViewPart {
 
                super.createPartControl(parent);
 
-               // show viewer if there is an open editor
-               // if(getEditor() != null){
-               // showViewer(getEditor(), new StructuredSelection(getInitialInput()));
-               // }
        }
 
        /**