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