01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.cheatsheet.simple.actions;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants;
14: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSItem;
15: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
16: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSPerformWhen;
17: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSRunContainerObject;
18: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSRunObject;
19: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSSubItem;
20: import org.eclipse.pde.internal.ui.PDEUIMessages;
21:
22: /**
23: * SimpleCSAddStepAction
24: *
25: */
26: public class SimpleCSRemoveRunObjectAction extends Action {
27:
28: private ISimpleCSRunContainerObject fRunContainerObject;
29:
30: /**
31: *
32: */
33: public SimpleCSRemoveRunObjectAction() {
34: setText(PDEUIMessages.SimpleCSRemoveStepAction_0);
35: // setImageDescriptor(PDEPluginImages.DESC_GEL_SC_OBJ);
36: // setToolTipText(PDEUIMessages.SchemaEditor_NewElement_tooltip);
37: }
38:
39: /**
40: * @param cheatsheet
41: */
42: public void setRunObject(ISimpleCSRunContainerObject runObject) {
43: fRunContainerObject = runObject;
44: }
45:
46: /* (non-Javadoc)
47: * @see org.eclipse.jface.action.Action#run()
48: */
49: public void run() {
50: if (fRunContainerObject != null) {
51: // Determine parent type and remove accordingly
52: ISimpleCSObject parent = fRunContainerObject.getParent();
53: if (parent.getType() == ISimpleCSConstants.TYPE_ITEM) {
54: ISimpleCSItem item = (ISimpleCSItem) parent;
55: item.setExecutable(null);
56: } else if (parent.getType() == ISimpleCSConstants.TYPE_SUBITEM) {
57: ISimpleCSSubItem subitem = (ISimpleCSSubItem) parent;
58: subitem.setExecutable(null);
59: } else if (parent.getType() == ISimpleCSConstants.TYPE_PERFORM_WHEN) {
60: // Specifically for perform-when edge case
61: // Action and command supported; but, will never be applicable
62: if ((fRunContainerObject.getType() == ISimpleCSConstants.TYPE_ACTION)
63: || (fRunContainerObject.getType() == ISimpleCSConstants.TYPE_COMMAND)) {
64: ISimpleCSPerformWhen performWhen = (ISimpleCSPerformWhen) parent;
65: performWhen
66: .removeExecutable((ISimpleCSRunObject) fRunContainerObject);
67: }
68: }
69: }
70: }
71: }
|