From e21fd1fd371611f87d90d3a36abb73154c4ef6aa Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Wed, 2 Mar 2011 14:41:23 +0000 Subject: [PATCH] Makes user defined areas available. Fixes issues that stem from the refactoring. --- taxeditor-editor/plugin.xml | 4 +- .../taxeditor/navigation/NavigationUtil.java | 16 ++-- .../navigator/handler/EditHandler.java | 19 ++-- .../wizard/SelectServiceWizardPage.java | 30 +++++- .../NamedAreaSelectionDialog.java | 94 +++++-------------- 5 files changed, 70 insertions(+), 93 deletions(-) diff --git a/taxeditor-editor/plugin.xml b/taxeditor-editor/plugin.xml index 542554cf4..4f506c9cd 100644 --- a/taxeditor-editor/plugin.xml +++ b/taxeditor-editor/plugin.xml @@ -111,7 +111,7 @@ style="push"> + value="eu.etaxonomy.taxeditor.editor.view.descriptive"> + locationURI="popup:eu.etaxonomy.taxeditor.editor.view.descriptive"> { - 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 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 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 selectedVocabularies; + private Collection> selectedVocabularies = new ArrayList>(); - 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> 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 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 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(); - 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 terms = new HashSet(); - for(VocabularyEnum vocabularyEnum : selectedVocabularies){ - TermVocabulary vocabulary = (TermVocabulary) HibernateProxyHelper.deproxy(CdmStore.getService(IVocabularyService.class).getVocabulary(vocabularyEnum)); + for(TermVocabulary vocabulary : selectedVocabularies){ terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage())); } -- 2.34.1