AT: committing Trunk fix to missing dependency
authora.theys <a.theys@localhost>
Tue, 17 Jan 2012 16:05:22 +0000 (16:05 +0000)
committera.theys <a.theys@localhost>
Tue, 17 Jan 2012 16:05:22 +0000 (16:05 +0000)
1  2 
.gitattributes
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java

diff --cc .gitattributes
@@@ -475,13 -474,6 +475,14 @@@ eu.etaxonomy.taxeditor.editor/src/main/
  eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java -text
  eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/MoveMediaInListOperation.java -text
  eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/RemoveImageFromDescriptionElementOperation.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java -text
++eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DynamicFeatureMenu.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java -text
 +eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java -text
  eu.etaxonomy.taxeditor.editor/src/main/resources/TaonDescriptionEditor.screen -text
  eu.etaxonomy.taxeditor.editor/src/main/resources/log4j.properties -text
  eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/Application.java -text
index 0000000,0000000..167b4f5
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,109 @@@
++package eu.etaxonomy.taxeditor.editor.view.uses.handler;\r
++\r
++import java.util.ArrayList;\r
++import java.util.List;\r
++\r
++import org.eclipse.core.commands.AbstractHandler;\r
++import org.eclipse.core.commands.ExecutionEvent;\r
++import org.eclipse.core.commands.ExecutionException;\r
++import org.eclipse.core.commands.common.NotDefinedException;\r
++import org.eclipse.core.commands.operations.IUndoContext;\r
++import org.eclipse.jface.viewers.IStructuredSelection;\r
++import org.eclipse.jface.viewers.TreePath;\r
++import org.eclipse.jface.viewers.TreeSelection;\r
++import org.eclipse.ui.IWorkbenchPart;\r
++import org.eclipse.ui.handlers.HandlerUtil;\r
++\r
++import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
++import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
++import eu.etaxonomy.cdm.model.media.Media;\r
++import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
++import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;\r
++import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation;\r
++import eu.etaxonomy.taxeditor.editor.view.uses.operation.DeleteTaxonUseOperation;\r
++import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;\r
++import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
++import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
++\r
++public class DeleteUseHandler extends AbstractHandler {\r
++\r
++      /*\r
++       * (non-Javadoc)\r
++       * \r
++       * @see\r
++       * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.\r
++       * ExecutionEvent)\r
++       */\r
++      /** {@inheritDoc} */\r
++      public Object execute(ExecutionEvent event) throws ExecutionException {\r
++              IStructuredSelection selection = (IStructuredSelection) HandlerUtil\r
++                              .getActiveSite(event).getSelectionProvider().getSelection();\r
++\r
++              IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
++              IPostOperationEnabled postOperationEnabled = (part instanceof IPostOperationEnabled) ? (IPostOperationEnabled) part\r
++                              : null;\r
++\r
++              try {\r
++                      String label = event.getCommand().getName();\r
++\r
++                      IUndoContext undoContext = EditorUtil.getUndoContext();\r
++\r
++                      List<AbstractPostOperation> operations = new ArrayList<AbstractPostOperation>();\r
++\r
++                      for (Object object : selection.toArray()) {\r
++\r
++                              AbstractPostOperation operation = null;\r
++\r
++                              // TaxonDescription\r
++                              if (object instanceof TaxonDescription) {\r
++                                      operations.add(new DeleteTaxonUseOperation(label,\r
++                                                      undoContext, (TaxonDescription) object,\r
++                                                      postOperationEnabled));\r
++                              }\r
++                              // DescriptionElementBase\r
++                              else if (object instanceof DescriptionElementBase) {\r
++                                      operations.add(new DeleteDescriptionElementOperation(label,\r
++                                                      undoContext, (DescriptionElementBase) object,\r
++                                                      postOperationEnabled));\r
++                              } else if (object instanceof FeatureNodeContainer) {\r
++                                      List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) object)\r
++                                                      .getDescriptionElementsForEntireBranch();\r
++\r
++                                      for (DescriptionElementBase description : descriptions) {\r
++                                              operations.add(new DeleteDescriptionElementOperation(\r
++                                                              label, undoContext, description,\r
++                                                              postOperationEnabled));\r
++                                      }\r
++                              }\r
++                              // Media\r
++                              else if (object instanceof Media) {\r
++                                      TreeSelection treeSelection = (TreeSelection) selection;\r
++\r
++                                      TreePath[] path = treeSelection.getPathsFor(object);\r
++\r
++                                      TaxonDescription imageGallery = (TaxonDescription) path[0]\r
++                                                      .getFirstSegment();\r
++\r
++                                      operations\r
++                                                      .add(new DeleteMediaOperation(label, undoContext,\r
++                                                                      imageGallery, (Media) object,\r
++                                                                      postOperationEnabled));\r
++                              } else {\r
++                                      EditorUtil.error(getClass(),\r
++                                                      "Selection is not valid for this delete handler",\r
++                                                      null);\r
++                              }\r
++                      }\r
++\r
++                      // execute all cumulated operations\r
++                      for (AbstractPostOperation operation : operations) {\r
++                              EditorUtil.executeOperation(operation);\r
++                      }\r
++\r
++              } catch (NotDefinedException e) {\r
++                      EditorUtil.warn(getClass(), "Command name not set.");\r
++              }\r
++\r
++              return null;\r
++      }\r
++}\r