Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / command / DeleteObjectContributionItem.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.bulkeditor.command;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.jface.action.IContributionItem;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.ui.IEditorInput;
16 import org.eclipse.ui.IWorkbenchWindow;
17 import org.eclipse.ui.PlatformUI;
18 import org.eclipse.ui.actions.CompoundContributionItem;
19 import org.eclipse.ui.menus.CommandContributionItem;
20 import org.eclipse.ui.menus.CommandContributionItemParameter;
21
22 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
23 import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
24
25 /**
26 * <p>DeleteObjectContributionItem class.</p>
27 *
28 * @author p.ciardelli
29 * @created 25.08.2009
30 * @version 1.0
31 */
32 public class DeleteObjectContributionItem extends CompoundContributionItem {
33 private static final Logger logger = Logger
34 .getLogger(DeleteObjectContributionItem.class);
35
36 /**
37 * <p>Constructor for DeleteObjectContributionItem.</p>
38 */
39 public DeleteObjectContributionItem() {}
40
41 /**
42 * <p>Constructor for DeleteObjectContributionItem.</p>
43 *
44 * @param id a {@link java.lang.String} object.
45 */
46 public DeleteObjectContributionItem(String id) {
47 super(id);
48 }
49
50 /* (non-Javadoc)
51 * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
52 */
53 /** {@inheritDoc} */
54 @Override
55 protected IContributionItem[] getContributionItems() {
56
57 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
58
59 CommandContributionItemParameter parameter =
60 new CommandContributionItemParameter(
61 window, null, IBulkEditorConstants.DYNAMIC_DELETE_OBJECT_ID, SWT.NONE);
62
63 parameter.label = "Delete " + getEditorInputLabel(window) + " in Current Line";
64
65 return new IContributionItem[] {
66 new CommandContributionItem(parameter)
67 };
68 }
69
70 /**
71 * @param window
72 * @return
73 */
74 private String getEditorInputLabel(IWorkbenchWindow window) {
75 IEditorInput input = window.getActivePage().getActiveEditor().getEditorInput();
76
77 BulkEditorInputType inputType = BulkEditorInputType.getByInput(input);
78 return (inputType != null) ? inputType.label : "";
79 }
80 }