From: Patric Plitzner
BulkEditorPropertyTester class.
@@ -31,33 +28,41 @@ import eu.etaxonomy.taxeditor.ui.section.description.DerivedUnitElement; * @version 1.0 */ public class BulkEditorPropertyTester extends PropertyTester { - private static final Logger logger = Logger + + @SuppressWarnings("unused") + private static final Logger logger = Logger .getLogger(BulkEditorPropertyTester.class); - private static final String GROUP = "isGroup"; - private static final String DERIVEDUNIT = "isDerivedUnit"; + private static final String IS_MERGING_ENABLED = "isMergingEnabled"; + + private static final String IS_GROUP_EDITOR = "isGroupEditor"; + public static final String IS_DERIVED_UNIT_EDITOR = "isDerivedUnitEditor"; + public static final String IS_TAXON_EDITOR = "isTaxonEditor"; + /* (non-Javadoc) * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) */ /** {@inheritDoc} */ - public boolean test(Object receiver, String property, Object[] args, + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { BulkEditor bulkEditor = (BulkEditor) receiver; - - if ("isMergingEnabled".equals(property)) { + + if (IS_MERGING_ENABLED.equals(property)) { IEditorInput input = bulkEditor.getEditorInput(); if (input instanceof AbstractBulkEditorInput) { - return ((AbstractBulkEditorInput) input).isMergingEnabled(); - } + return ((AbstractBulkEditorInput>) input).isMergingEnabled(); + } } - if(GROUP.equals(property)){ - return isGroup(bulkEditor); + else if(IS_GROUP_EDITOR.equals(property)){ + return bulkEditor.getEditorInput() instanceof GroupEditorInput; } - - if (DERIVEDUNIT.equals(property)){ - - return isDerivedUnit(bulkEditor); + else if (IS_DERIVED_UNIT_EDITOR.equals(property)){ + return bulkEditor.getEditorInput() instanceof OccurrenceEditorInput; } + else if(IS_TAXON_EDITOR.equals(property)){ + return bulkEditor.getEditorInput() instanceof TaxonEditorInput; + } // if (("isPublishFlagEditingEnabled").equals(property)) { // IEditorInput input = bulkEditor.getEditorInput(); // if (input instanceof NameEditorInput) { @@ -66,14 +71,4 @@ public class BulkEditorPropertyTester extends PropertyTester { // } return false; } - - private boolean isDerivedUnit(BulkEditor bulkEditor) { - IEditorInput input = bulkEditor.getEditorInput(); - return (input instanceof OccurrenceEditorInput) ? true : false; - } - - private boolean isGroup(BulkEditor bulkEditor) { - IEditorInput input = bulkEditor.getEditorInput(); - return (input instanceof GroupEditorInput) ? true : false; - } } diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java index 917f5f40d..e4876d35a 100644 --- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java +++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/EditHandler.java @@ -19,7 +19,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.handlers.HandlerUtil; @@ -46,8 +46,8 @@ public class EditHandler extends AbstractHandler implements IHandler{ ISelection selection = HandlerUtil.getCurrentSelection(event); - if(selection instanceof StructuredSelection){ - final StructuredSelection structuredSelection = (StructuredSelection) selection; + if(selection instanceof IStructuredSelection){ + final IStructuredSelection structuredSelection = (IStructuredSelection) selection; if(structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof Classification){ Classification classification = (Classification) structuredSelection.getFirstElement();