Makes user defined areas available. Fixes issues that stem from the refactoring.
authorn.hoffmann <n.hoffmann@localhost>
Wed, 2 Mar 2011 14:41:23 +0000 (14:41 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 2 Mar 2011 14:41:23 +0000 (14:41 +0000)
taxeditor-editor/plugin.xml
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java
taxeditor-navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java
taxeditor-printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/wizard/SelectServiceWizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/ui/dialogs/filteredSelection/NamedAreaSelectionDialog.java

index 542554cf40a3a7cbc52f5c328cc5fc84caf402d1..4f506c9cda8be9e37b53f1a81b4e917b0c6e36d9 100644 (file)
                style="push">
             <parameter
                   name="org.eclipse.ui.views.showView.viewId"
-                  value="eu.etaxonomy.taxeditor.editor.view.description">
+                  value="eu.etaxonomy.taxeditor.editor.view.descriptive">
             </parameter>
          </command>
          <command
          </separator>
       </menuContribution>
       <menuContribution
-            locationURI="popup:eu.etaxonomy.taxeditor.editor.view.description">
+            locationURI="popup:eu.etaxonomy.taxeditor.editor.view.descriptive">
          <command
                commandId="eu.etaxonomy.taxeditor.description.commands.adddescription"
                label="New Descriptive Data"
index 0c6ed7b160bf56a54ed4890072ad69fd16c41eda..49d8a37abb5afc02b5ee7c744558df059cc0694e 100644 (file)
@@ -102,15 +102,13 @@ public class NavigationUtil extends AbstractUtility{
                }
        }
        
-       public static void openEditor(Object selectedObject){
-               if (selectedObject instanceof UuidAndTitleCache){
-                       Class type = ((UuidAndTitleCache) selectedObject).getType();
-                       if(type == Taxon.class || type == Synonym.class){
-                               try {
-                                       EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
-                               } catch (PartInitException e) {
-                                       NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
-                               }
+       public static void openEditor(UuidAndTitleCache selectedObject){
+               Class type = ((UuidAndTitleCache) selectedObject).getType();
+               if(type == Taxon.class || type == Synonym.class){
+                       try {
+                               EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
+                       } catch (PartInitException e) {
+                               NavigationUtil.error(NavigationUtil.class, "Error opening the editor", e);
                        }
                }
        }
index 98f26996ba61f7773fa9dde9c42987b1ecc2764c..814219f49733e303951c0ccadaa576f9a34013ea 100644 (file)
@@ -24,9 +24,8 @@ import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
 import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
 import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
 
@@ -67,13 +66,15 @@ public class EditHandler extends AbstractHandler implements IHandler{
                                        protected IStatus run(IProgressMonitor monitor) {
                                                for(final Object selectedObject : structuredSelection.toArray()){
                                                        
-                                                       Display.getDefault().asyncExec(new Runnable(){
-
-                                                               public void run() {
-                                                                       NavigationUtil.openEditor(selectedObject);
-                                                               }
-                                                               
-                                                       });
+                                                       if(selectedObject instanceof TaxonNode){
+                                                               Display.getDefault().asyncExec(new Runnable(){
+       
+                                                                       public void run() {
+                                                                               NavigationUtil.openEditor((TaxonNode) selectedObject);
+                                                                       }
+                                                                       
+                                                               });
+                                                       }
                                                }
                                                return Status.OK_STATUS;
                                        }
index 34cfb4f3d821b5139bf15e51290b4acb08ab7c2e..10643417aba98555509e127bab2d8293bd2e99ca 100644 (file)
 
 package eu.etaxonomy.taxeditor.printpublisher.wizard;
 
+import java.lang.reflect.InvocationTargetException;
 import java.net.MalformedURLException;
 
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -25,6 +28,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
 import eu.etaxonomy.cdm.print.PublishConfigurator;
+import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 
@@ -156,11 +160,27 @@ public class SelectServiceWizardPage extends AbstractPublishWizardPage {
        @Override
        public boolean canFlipToNextPage() {
                if(isPageComplete()){
-                       SelectTaxaWizardPage selectTaxaPage = (SelectTaxaWizardPage) getWizard().getPage(AbstractPublishWizard.PAGE_TAXA);                      
-                       selectTaxaPage.refresh();
-                       
-                       SelectFeatureTreeWizardPage selectFeatureTreePage = (SelectFeatureTreeWizardPage) getWizard().getPage(AbstractPublishWizard.PAGE_FEATURETREE);          
-                       selectFeatureTreePage.refresh();
+                       try {
+                               getContainer().run(false, false, new IRunnableWithProgress() {
+                                       
+                                       @Override
+                                       public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                                                       InterruptedException {
+                                               getConfigurator().setProgressMonitor(CdmProgressMonitorAdapter.CreateMonitor(monitor));
+                                               
+                                               SelectTaxaWizardPage selectTaxaPage = (SelectTaxaWizardPage) getWizard().getPage(AbstractPublishWizard.PAGE_TAXA);                      
+                                               selectTaxaPage.refresh();
+                                               
+                                               SelectFeatureTreeWizardPage selectFeatureTreePage = (SelectFeatureTreeWizardPage) getWizard().getPage(AbstractPublishWizard.PAGE_FEATURETREE);          
+                                               selectFeatureTreePage.refresh();
+                                               
+                                       }
+                               });
+                       } catch (InvocationTargetException e) {
+                               PrintUtil.error(getClass(), e);
+                       } catch (InterruptedException e) {
+                               PrintUtil.error(getClass(), e);
+                       }
                        
                        return true;
                }
index a9279b4852de4677dee946a9204c8579e9591336..1deb9a06c6696eb147dae7a8696ce68c590fbf73 100644 (file)
@@ -13,6 +13,7 @@ package eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.UUID;
 
@@ -44,68 +45,30 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class NamedAreaSelectionDialog extends
                AbstractFilteredCdmResourceSelectionDialog<NamedArea> {
 
-       private class IncludeTdwgAreaAction extends Action {
-               /**
-                * Creates a new instance of the class.
-                */
-               public IncludeTdwgAreaAction() {
-                       super("TDWG Areas", IAction.AS_CHECK_BOX);
-               }
-
-               public void run() {
-                       if(isChecked()){
-                               selectedVocabularies.add(VocabularyEnum.TdwgArea);
-                       }else{
-                               selectedVocabularies.remove(VocabularyEnum.TdwgArea);
-                       }
-                       
-                       initModel();
-               }
-       }
-       
-       private class IncludeWaterbodyOrCountryAction extends Action {
-               /**
-                * Creates a new instance of the class.
-                */
-               public IncludeWaterbodyOrCountryAction() {
-                       super("Waterbody Or Country", IAction.AS_CHECK_BOX);
-               }
+       private class IncludeNamedAreaVocabulary extends Action {
+               private TermVocabulary<NamedArea> vocabulary;
 
-               public void run() {
-                       if(isChecked()){
-                               selectedVocabularies.add(VocabularyEnum.WaterbodyOrCountry);
-                       }else{
-                               selectedVocabularies.remove(VocabularyEnum.WaterbodyOrCountry);
-                       }
-                       
-                       initModel();
-               }
-       }
-       
-       private class IncludeContinentAction extends Action {
                /**
                 * Creates a new instance of the class.
                 */
-               public IncludeContinentAction() {
-                       super("Continent", IAction.AS_CHECK_BOX);
+               public IncludeNamedAreaVocabulary(TermVocabulary<NamedArea> vocabulary) {
+                       super(vocabulary.getTitleCache(), IAction.AS_CHECK_BOX);
+                       this.vocabulary = vocabulary;
                }
-
-               public void run() {
+               
+               public void run(){
                        if(isChecked()){
-                               selectedVocabularies.add(VocabularyEnum.Continent);
+                               selectedVocabularies.add(vocabulary);
                        }else{
-                               selectedVocabularies.remove(VocabularyEnum.Continent);
+                               selectedVocabularies.remove(vocabulary);
                        }
                        
                        initModel();
                }
        }
        
-       private Collection<VocabularyEnum> selectedVocabularies;
+       private Collection<TermVocabulary<NamedArea>> selectedVocabularies = new ArrayList<TermVocabulary<NamedArea>>();
        
-       private IncludeTdwgAreaAction includeTdwgAreaAction;
-       private IncludeWaterbodyOrCountryAction includeWaterbodyOrCountryAction;
-       private IncludeContinentAction includeContinentAction;
        
        /**
         * Creates a filtered selection dialog to select a named area.
@@ -142,25 +105,22 @@ public class NamedAreaSelectionDialog extends
                                
                super.fillViewMenu(menuManager);
                
-               includeTdwgAreaAction = new IncludeTdwgAreaAction();
-               menuManager.add(includeTdwgAreaAction);
-               includeTdwgAreaAction.setChecked(true);
+               List<TermVocabulary<NamedArea>> vocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
+               vocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
                
-               includeWaterbodyOrCountryAction = new IncludeWaterbodyOrCountryAction();
-               menuManager.add(includeWaterbodyOrCountryAction);
-               includeWaterbodyOrCountryAction.setChecked(true);
-               
-               includeContinentAction = new IncludeContinentAction();
-               menuManager.add(includeContinentAction);
-               includeContinentAction.setChecked(true);
+               for(TermVocabulary<NamedArea> vocabulary : vocabularies){
+                       IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
+                       menuManager.add(action);
+                       action.setChecked(true);
+               }
        }
        
-       
        /** {@inheritDoc} */
        @Override
        protected NamedArea getPersistentObject(UUID uuid) {
-               for(VocabularyEnum selectedVocabulary : selectedVocabularies){
-                       TermVocabulary vocabulary = CdmStore.getService(IVocabularyService.class).getVocabulary(selectedVocabulary);
+               for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
                        for(Object object : vocabulary.getTerms()){
                                CdmBase cdmBaseObject = (CdmBase) object;
                                if(uuid.equals(cdmBaseObject.getUuid())){
@@ -174,11 +134,10 @@ public class NamedAreaSelectionDialog extends
        /** {@inheritDoc} */
        @Override
        protected void init() {
-               // testing 
-               selectedVocabularies = new HashSet<VocabularyEnum>();
-               selectedVocabularies.add(VocabularyEnum.TdwgArea);
-               selectedVocabularies.add(VocabularyEnum.WaterbodyOrCountry);
-               selectedVocabularies.add(VocabularyEnum.Continent);
+               selectedVocabularies = CdmStore.getService(IVocabularyService.class).listByTermClass(NamedArea.class, null, null, null, null);
+               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.TdwgArea));
+               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.WaterbodyOrCountry));
+               selectedVocabularies.add(CdmStore.getService(IVocabularyService.class).getVocabulary(VocabularyEnum.Continent));
        }
 
        /** {@inheritDoc} */
@@ -186,8 +145,7 @@ public class NamedAreaSelectionDialog extends
        protected void initModel() {
                
                Set<NamedArea> terms = new HashSet<NamedArea>();
-               for(VocabularyEnum vocabularyEnum : selectedVocabularies){
-                       TermVocabulary vocabulary = (TermVocabulary) HibernateProxyHelper.deproxy(CdmStore.getService(IVocabularyService.class).getVocabulary(vocabularyEnum));
+               for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
                        terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
                }