+++ /dev/null
-// $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.
-*/
-
-package eu.etaxonomy.taxeditor.editor.description.handler;
-
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.description.CommonTaxonName;
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.Page;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-import eu.etaxonomy.taxeditor.editor.description.DescriptionLabelComposite;
-import eu.etaxonomy.taxeditor.editor.description.DistributionDialog;
-import eu.etaxonomy.taxeditor.editor.description.LanguageDialog;
-import eu.etaxonomy.taxeditor.editor.description.TaxonDescriptionEditor;
-import eu.etaxonomy.taxeditor.editor.descriptionnew.TaxonDescriptionFeature;
-import eu.etaxonomy.taxeditor.operations.CreateDescriptionElementOperation;
-import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
-
-/**
- * @author n.hoffmann
- * @created 16.04.2009
- * @version 1.0
- */
-public class CreateDescriptionElementHandler extends AbstractHandler {
- private static final Logger logger = Logger
- .getLogger(CreateDescriptionElementHandler.class);
-
- private DescriptionElementBase element;
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- IEditorInput input = editor.getEditorInput();
- if (input instanceof TaxonEditorInput) {
- Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof TreeSelection) {
- TreePath[] paths = ((TreeSelection) selection).getPaths();
- TaxonDescription description = (TaxonDescription) (paths[0]).getFirstSegment();
-
- Feature feature = (Feature) ((Event)event.getTrigger()).data;;
-
- IUndoableOperation operation;
- try {
- // TODO use undo context specific to editor
- operation = new CreateDescriptionElementOperation(event.getCommand().getName(),
- EditorUtil.getUndoContext(), taxon, description, feature, (IPostOperationEnabled) editor);
- EditorUtil.executeOperation(operation);
- } catch (NotDefinedException e) {
- logger.warn("Command name not set");
- }
- }
- }
-
-
-
-
-// TaxonDescriptionEditor editor = (TaxonDescriptionEditor) EditorUtil.getActiveEditorPage(
-// Page.DESCRIPTIVE);
-//
-// Feature feature = (Feature) ((Event)event.getTrigger()).data;
-//
-// // FIXME right now we have only one description per taxon
-// // this will change in the future and then attaching the feature to
-// // the firstGroupedComposite will not work anymore
-// TaxonDescription description = ((DescriptionLabelComposite)editor.getFirstGroupedComposite()).getDescription();
-
-// if (getElementUserInput(feature).equals(Status.OK_STATUS)) {
-// IUndoableOperation operation;
-// try {
-// operation = new CreateDescriptionElementOperation(event.getCommand().getName(),
-// editor.getUndoContext(), editor.getTaxon(), description, feature, element, editor);
-// EditorUtil.executeOperation(operation);
-// } catch (NotDefinedException e) {
-// logger.warn("Command name not set");
-// }
-// }
- return null;
- }
-
- /**
- * Some element types require input via the UI - initialize these here
- *
- * @param feature
- * @return
- */
- private IStatus getElementUserInput(Feature feature) {
-
- // Remove object from last execution from element
- element = null;
-
- // -------------- Common name -------------- //
- if (feature.supportsCommonTaxonName()) {
- Language language = LanguageDialog.getLanguage
- ("Select language", "Select the common name's language:");
- if (language == null) {
- return Status.CANCEL_STATUS;
- }
- element = CommonTaxonName.NewInstance("", language);
- // Feature must be explicitly set to sync w term in persistence layer
- element.setFeature(feature);
- }
-
- // -------------- Distribution -------------- //
- if (feature.supportsDistribution()) {
- element = DistributionDialog.getDistribution
- ("Create distribution", null);
- if (element == null) {
- return Status.CANCEL_STATUS;
- }
- // Feature must be explicitly set to sync w term in persistence layer
- element.setFeature(feature);
- }
-
- return Status.OK_STATUS;
- }
-}
\ No newline at end of file
+++ /dev/null
-// $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.
-*/
-
-package eu.etaxonomy.taxeditor.editor.description.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.operations.IUndoableOperation;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-import eu.etaxonomy.taxeditor.operations.DeleteDescriptionElementOperation;
-import eu.etaxonomy.taxeditor.operations.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.propertysheet.description.DescriptionElementPropertySource;
-
-/**
- * @author n.hoffmann
- * @created 20.04.2009
- * @version 1.0
- */
-public class DeleteDescriptionElementHandler extends AbstractHandler implements
- IHandler {
- private static final Logger logger = Logger
- .getLogger(DeleteDescriptionElementHandler.class);
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- IEditorInput input = editor.getEditorInput();
- if (input instanceof TaxonEditorInput) {
- Taxon taxon = ((TaxonEditorInput) input).getTaxon();
-
- DescriptionElementBase descriptionElement = (DescriptionElementBase) ((TreeSelection) HandlerUtil.getCurrentSelection(event)).getFirstElement();
-
- IUndoableOperation operation;
- try {
- // TODO use undo context specific to editor
- operation = new DeleteDescriptionElementOperation(event.getCommand().getName(),
- EditorUtil.getUndoContext(), taxon, descriptionElement, (IPostOperationEnabled) editor);
- EditorUtil.executeOperation(operation);
- } catch (NotDefinedException e) {
- logger.warn("Command name not set");
- }
- }
-
-// MultiPageTaxonEditor editor = EditorUtil.getActiveEditor();
-// ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);
-//
-// DescriptionElementBase descriptionElement = ((DescriptionElementPropertySource) ((StructuredSelection) menuSelection).getFirstElement()).getDescriptionElement();
-//
-// IUndoableOperation operation;
-// try {
-// operation = new DeleteDescriptionElementOperation(event.getCommand().getName(),
-// editor.getUndoContext(), editor.getTaxon(), descriptionElement, editor);
-// EditorUtil.executeOperation(operation);
-// } catch (NotDefinedException e) {
-// logger.warn("Command name not set");
-// }
-
- return null;
- }
-}