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