Removing calls of deprecated methods
authorn.hoffmann <n.hoffmann@localhost>
Wed, 20 Apr 2011 09:09:47 +0000 (09:09 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 20 Apr 2011 09:09:47 +0000 (09:09 +0000)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/ClassificationSelectionDialog.java

index 486682689e3a88d2e7b39671a2864587f41d82a0..5483e7ab77bb56622e624ca600b0a4dfd5fd1f18 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* 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.navigation.navigator;
 
@@ -42,67 +42,79 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * Taxonomic tree implementation using Common Navigator Framework.
- *
+ * 
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 02.06.2009
  * @version 1.0
  */
-public class TaxonNavigator extends CommonNavigator implements IPostOperationEnabled, IConversationEnabled{
+public class TaxonNavigator extends CommonNavigator implements
+               IPostOperationEnabled, IConversationEnabled {
 
-       /** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.navig"{trunked}</code> */
+       /**
+        * Constant
+        * <code>ID="eu.etaxonomy.taxeditor.navigation.navig"{trunked}</code>
+        */
        public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator"; //$NON-NLS-1$
 
-       /** Constant <code>OPEN_COMMAND_ID="eu.etaxonomy.taxeditor.navigation.comma"{trunked}</code> */
+       /**
+        * Constant
+        * <code>OPEN_COMMAND_ID="eu.etaxonomy.taxeditor.navigation.comma"{trunked}</code>
+        */
        public static final String OPEN_COMMAND_ID = "eu.etaxonomy.taxeditor.navigation.command.editSelection";
-       
+
        private static final String TREE_PATH = "treepath";
 
        private static final String TREE_PATHS = "treepaths";
 
        private ConversationHolder conversation;
-       
+
        private String partNameCache;
 
        private IDataChangeBehavior dataChangeBehavior;
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.navigator.CommonNavigator#getInitialInput()
         */
        /** {@inheritDoc} */
        @Override
        protected IAdaptable getInitialInput() {
-               if(CdmStore.isActive()){
-                       // TODO when closing and reopening the taxon navigator 
-                       // we do not preserve state. Closing the view, in contrary to closing the whole application
+               if (CdmStore.isActive()) {
+                       // TODO when closing and reopening the taxon navigator
+                       // we do not preserve state. Closing the view, in contrary to
+                       // closing the whole application
                        // should be handled by the state manager too
-                                               
+
                        return new Root(conversation);
                }
                return new EmptyRoot();
        }
-       
+
        /** {@inheritDoc} */
-       public void init(IViewSite site)
-                       throws PartInitException {
+       @Override
+       public void init(IViewSite site) throws PartInitException {
                super.init(site);
                init();
        }
-       
+
        /**
-        * <p>init</p>
+        * <p>
+        * init
+        * </p>
         */
-       public void init(){
-               if(CdmStore.isActive() && conversation == null){
+       public void init() {
+               if (CdmStore.isActive() && conversation == null) {
                        conversation = CdmStore.createConversation();
                        conversation.registerForDataStoreChanges(TaxonNavigator.this);
                }
        }
-       
+
        /**
         * Refresh this navigators viewer
         */
-       public void refresh(){
+       public void refresh() {
                getConversationHolder().bind();
                getCommonViewer().refresh();
        }
@@ -110,15 +122,19 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
        /**
         * Removes all content
         */
-       public void clear(){
+       public void clear() {
                getCommonViewer().setInput(new EmptyRoot());
        }
-       
+
        /**
-        * <p>restore</p>
-        *
-        * @param memento a {@link org.eclipse.ui.IMemento} object.
-        * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+        * <p>
+        * restore
+        * </p>
+        * 
+        * @param memento
+        *            a {@link org.eclipse.ui.IMemento} object.
+        * @param monitor
+        *            a {@link org.eclipse.core.runtime.IProgressMonitor} object.
         */
        public void restore(IMemento memento, IProgressMonitor monitor) {
                if (memento == null) {
@@ -128,21 +144,24 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
                int mementoWork = 0;
                Set<TreePath> treePaths = new HashSet<TreePath>();
                IMemento[] treePathMementos = null;
-               
+
                IMemento treePathsMemento = memento.getChild(TREE_PATHS);
-               
+
                if (treePathsMemento != null) {
                        treePathMementos = treePathsMemento.getChildren(TREE_PATH);
                        mementoWork = treePathMementos.length;
                }
-               // begin the monitor with steps for all tree paths and steps for creating 
-               // conversation s.o., refreshing the tree and setting the paths 
-               IProgressMonitor subProgressMonitor = NavigationUtil.getSubProgressMonitor(monitor, 1); 
-               
-               subProgressMonitor.beginTask("Restoring Taxon Navigator", 1 + mementoWork + 5);
+               // begin the monitor with steps for all tree paths and steps for
+               // creating
+               // conversation s.o., refreshing the tree and setting the paths
+               IProgressMonitor subProgressMonitor = NavigationUtil
+                               .getSubProgressMonitor(monitor, 1);
+
+               subProgressMonitor.beginTask("Restoring Taxon Navigator",
+                               1 + mementoWork + 5);
                subProgressMonitor.subTask("Restoring Taxon Navigator");
                subProgressMonitor.worked(1);
-               
+
                conversation = CdmStore.createConversation();
                subProgressMonitor.worked(1);
                conversation.registerForDataStoreChanges(TaxonNavigator.this);
@@ -151,12 +170,11 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
                subProgressMonitor.worked(1);
                getCommonViewer().refresh();
                subProgressMonitor.worked(1);
-               
-               
-               
+
                if (treePathMementos != null && treePathMementos.length > 0) {
                        for (IMemento treePathMemento : treePathMementos) {
-                               TreePath treePath = createTreePathFromString(treePathMemento.getID());
+                               TreePath treePath = createTreePathFromString(treePathMemento
+                                               .getID());
                                if (!subProgressMonitor.isCanceled() && treePath != null) {
                                        treePaths.add(treePath);
                                        subProgressMonitor.worked(1);
@@ -164,7 +182,8 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
                        }
                }
                if (treePaths.size() > 0) {
-                       TaxonNavigator.this.getCommonViewer().setExpandedTreePaths(treePaths.toArray(new TreePath[0]));
+                       TaxonNavigator.this.getCommonViewer().setExpandedTreePaths(
+                                       treePaths.toArray(new TreePath[0]));
                        subProgressMonitor.worked(1);
                }
                subProgressMonitor.done();
@@ -177,48 +196,58 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
        private TreePath createTreePathFromString(String string) {
 
                List<CdmBase> pathList = new ArrayList<CdmBase>();
-               
-               if(string.length() == 0) return null; 
-               
+
+               if (string.length() == 0)
+                       return null;
+
                for (String uuid : string.split(" ")) {
-                       CdmBase cdmBaseObject = CdmStore.getService(IClassificationService.class).getTaxonNodeByUuid(UUID.fromString(uuid));
+                       CdmBase cdmBaseObject = CdmStore.getService(
+                                       IClassificationService.class).getTaxonNodeByUuid(
+                                       UUID.fromString(uuid));
                        if (cdmBaseObject == null) {
                                // is this a tree uuid?
-                               cdmBaseObject = CdmStore.getService(IClassificationService.class).getClassificationByUuid(UUID.fromString(uuid));
-                               
-                               if(cdmBaseObject == null) return null;
+                               cdmBaseObject = CdmStore.getService(
+                                               IClassificationService.class).load(
+                                               UUID.fromString(uuid));
+
+                               if (cdmBaseObject == null)
+                                       return null;
                        }
                        pathList.add(cdmBaseObject);
                }
                return new TreePath(pathList.toArray());
        }
 
-
        /** {@inheritDoc} */
        @Override
        public void saveState(IMemento aMemento) {
                //
        }
-       
+
        /**
-        * <p>saveTreeState</p>
-        *
-        * @param memento a {@link org.eclipse.ui.IMemento} object.
-        * @param progressMonitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+        * <p>
+        * saveTreeState
+        * </p>
+        * 
+        * @param memento
+        *            a {@link org.eclipse.ui.IMemento} object.
+        * @param progressMonitor
+        *            a {@link org.eclipse.core.runtime.IProgressMonitor} object.
         */
        public void saveTreeState(IMemento memento, IProgressMonitor progressMonitor) {
                if (memento == null) {
                        return;
                }
-               IProgressMonitor monitor = NavigationUtil.getSubProgressMonitor(progressMonitor, 1);    
-               
+               IProgressMonitor monitor = NavigationUtil.getSubProgressMonitor(
+                               progressMonitor, 1);
+
                super.saveState(memento);
-               
+
                memento = memento.createChild(TREE_PATHS);
                TreePath[] treePaths = this.getCommonViewer().getExpandedTreePaths();
-               
+
                monitor.beginTask("Saving Taxon Navigator State", treePaths.length);
-               
+
                for (TreePath treePath : treePaths) {
                        int pathLength = treePath.getSegmentCount();
                        String path = "";
@@ -226,49 +255,66 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
                                Object segment = treePath.getSegment(i);
                                if (segment instanceof CdmBase) {
                                        path += ((CdmBase) segment).getUuid().toString() + " ";
-                                       monitor.worked(1);                              
+                                       monitor.worked(1);
                                } else {
-                                       NavigationUtil.warn(getClass(), "Non-taxon tree path segment " + segment);
+                                       NavigationUtil.warn(getClass(),
+                                                       "Non-taxon tree path segment " + segment);
                                }
                        }
                        memento.createChild(TREE_PATH, path.trim());
                }
                monitor.done();
-       }       
+       }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
+       /*
+        * (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.
         */
+       @Override
        public ConversationHolder getConversationHolder() {
                return conversation;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
+        * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
         */
        /** {@inheritDoc} */
+       @Override
        public void update(CdmDataChangeMap changeEvents) {
-               if(dataChangeBehavior == null){
+               if (dataChangeBehavior == null) {
                        dataChangeBehavior = new TaxonNavigatorDataChangeBehavior(this);
                }
-               
+
                DataChangeBridge.handleDataChange(changeEvents, dataChangeBehavior);
        }
-       
+
        /** {@inheritDoc} */
+       @Override
        public String getFrameToolTipText(Object element) {
                if (element instanceof Root) {
                        return "Taxonomic Tree";
                }
                return super.getFrameToolTipText(element);
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.part.WorkbenchPart#dispose()
         */
        /** {@inheritDoc} */
@@ -276,79 +322,102 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
        public void dispose() {
                super.dispose();
                dataChangeBehavior = null;
-               if(conversation != null){
+               if (conversation != null) {
                        conversation.unregisterForDataStoreChanges(this);
                }
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.navigator.CommonNavigator#setFocus()
         */
        /** {@inheritDoc} */
        @Override
        public void setFocus() {
-               //logger.warn("Setting focus to navigator");
+               // logger.warn("Setting focus to navigator");
                super.setFocus();
-               if(getConversationHolder() != null){
+               if (getConversationHolder() != null) {
                        getConversationHolder().bind();
                }
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation
+        * (eu.etaxonomy.cdm.model.common.CdmBase)
         */
        /** {@inheritDoc} */
+       @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                // nothing to do here
                return true;
        }
 
        /**
-        * <p>save</p>
-        *
-        * @param memento a {@link org.eclipse.ui.IMemento} object.
-        * @param monitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+        * <p>
+        * save
+        * </p>
+        * 
+        * @param memento
+        *            a {@link org.eclipse.ui.IMemento} object.
+        * @param monitor
+        *            a {@link org.eclipse.core.runtime.IProgressMonitor} object.
         */
        public void save(IMemento memento, IProgressMonitor monitor) {
                saveTreeState(memento, monitor);
-               if(conversation != null){
+               if (conversation != null) {
                        conversation.unregisterForDataStoreChanges(this);
                        conversation = null;
                }
        }
-       
+
        /** {@inheritDoc} */
        @Override
        protected void handleDoubleClick(DoubleClickEvent anEvent) {
-               
-               ICommandService commandService = (ICommandService)getSite().getService(ICommandService.class);
-               
-               Command command = commandService.getCommand(OPEN_COMMAND_ID); 
-               if(command.isEnabled()) {
-                       IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class);
+
+               ICommandService commandService = (ICommandService) getSite()
+                               .getService(ICommandService.class);
+
+               Command command = commandService.getCommand(OPEN_COMMAND_ID);
+               if (command.isEnabled()) {
+                       IHandlerService handlerService = (IHandlerService) getSite()
+                                       .getService(IHandlerService.class);
                        try {
                                handlerService.executeCommand(OPEN_COMMAND_ID, null);
                        } catch (NotDefinedException e) {
-                               throw new RuntimeException("Could not find open command: " + OPEN_COMMAND_ID);
+                               throw new RuntimeException("Could not find open command: "
+                                               + OPEN_COMMAND_ID);
                        } catch (Exception e) {
-                               NavigationUtil.error(getClass(), "An exception occured while trying to open a selection", e);
+                               NavigationUtil
+                                               .error(getClass(),
+                                                               "An exception occured while trying to open a selection",
+                                                               e);
                        }
                }
-               // If the double click is passed up to the super-class it will expand/collapse trees.
+               // If the double click is passed up to the super-class it will
+               // expand/collapse trees.
                // We do not want that
-               //super.handleDoubleClick(anEvent);
+               // super.handleDoubleClick(anEvent);
        }
 
        /**
-        * <p>onComplete</p>
-        *
+        * <p>
+        * onComplete
+        * </p>
+        * 
         * @return a boolean.
         */
+       @Override
        public boolean onComplete() {
                return true;
        }
-       
-       /* (non-Javadoc)
+
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean)
         */
        /** {@inheritDoc} */
@@ -356,11 +425,11 @@ public class TaxonNavigator extends CommonNavigator implements IPostOperationEna
        public void showBusy(boolean busy) {
                super.showBusy(busy);
                getCommonViewer().getControl().setEnabled(!busy);
-               if(busy){
+               if (busy) {
                        partNameCache = getPartName();
                        setPartName("Loading datasources");
-               }else{
-                       if(partNameCache != null){
+               } else {
+                       if (partNameCache != null) {
                                setPartName(partNameCache);
                        }
                }
index e2c05bb616ac11e16c28926ffe6217df646f2a11..63b5e457f9b1fa952664f6a843e0c8bf05d1e5c0 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* 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.ui.dialogs.filteredSelection;
 
@@ -23,45 +23,67 @@ import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
- * <p>FilteredClassificationSelectionDialog class.</p>
- *
+ * <p>
+ * FilteredClassificationSelectionDialog class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created Sep 21, 2009
  * @version 1.0
  */
 public class ClassificationSelectionDialog extends
                AbstractFilteredCdmResourceSelectionDialog<Classification> {
-               
+
        /**
-        * <p>select</p>
-        *
-        * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+        * <p>
+        * select
+        * </p>
+        * 
+        * @param shell
+        *            a {@link org.eclipse.swt.widgets.Shell} object.
+        * @param conversation
+        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *            object.
         * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
         */
-       public static Classification select(Shell shell, ConversationHolder conversation) {
-               ClassificationSelectionDialog dialog = new ClassificationSelectionDialog(shell, conversation,
-                               "Choose a Classification", false, "", null);
+       public static Classification select(Shell shell,
+                       ConversationHolder conversation) {
+               ClassificationSelectionDialog dialog = new ClassificationSelectionDialog(
+                               shell, conversation, "Choose a Classification", false, "", null);
                return getSelectionFromDialog(dialog);
        }
-       
+
        /**
-        * <p>Constructor for FilteredClassificationSelectionDialog.</p>
-        *
-        * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
-        * @param title a {@link java.lang.String} object.
-        * @param multi a boolean.
-        * @param settings a {@link java.lang.String} object.
-        * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        * @param classification a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
+        * <p>
+        * Constructor for FilteredClassificationSelectionDialog.
+        * </p>
+        * 
+        * @param shell
+        *            a {@link org.eclipse.swt.widgets.Shell} object.
+        * @param title
+        *            a {@link java.lang.String} object.
+        * @param multi
+        *            a boolean.
+        * @param settings
+        *            a {@link java.lang.String} object.
+        * @param conversation
+        *            a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
+        *            object.
+        * @param classification
+        *            a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
         */
-       protected ClassificationSelectionDialog(Shell shell, ConversationHolder conversation, String title,
-                       boolean multi, String settings, Classification classification) {
+       protected ClassificationSelectionDialog(Shell shell,
+                       ConversationHolder conversation, String title, boolean multi,
+                       String settings, Classification classification) {
                super(shell, conversation, title, multi, settings, classification);
        }
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
+        * (org.eclipse.swt.widgets.Composite)
         */
        /** {@inheritDoc} */
        @Override
@@ -69,22 +91,31 @@ public class ClassificationSelectionDialog extends
                return null;
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog
+        * #getPersistentObject(java.util.UUID)
         */
        /** {@inheritDoc} */
        @Override
        protected Classification getPersistentObject(UUID cdmUuid) {
-               return CdmStore.getService(IClassificationService.class).getClassificationByUuid(cdmUuid);
+               return CdmStore.getService(IClassificationService.class).load(cdmUuid);
        }
 
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#initModel()
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog
+        * #initModel()
         */
        /** {@inheritDoc} */
        @Override
        protected void initModel() {
-               model = CdmStore.getService(IClassificationService.class).getUuidAndTitleCache();
+               model = CdmStore.getService(IClassificationService.class)
+                               .getUuidAndTitleCache();
        }
 
        /** {@inheritDoc} */