List of usage examples for org.eclipse.jface.action IAction setEnabled
void setEnabled(boolean enabled);
From source file:ac.soton.eventb.classdiagrams.diagram.part.ClassdiagramsInitDiagramFileAction.java
License:Open Source License
/** * @generated//from www .j av a 2 s.c om */ public void selectionChanged(IAction action, ISelection selection) { domainModelURI = null; action.setEnabled(false); if (selection instanceof IStructuredSelection == false || selection.isEmpty()) { return; } IFile file = (IFile) ((IStructuredSelection) selection).getFirstElement(); domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); action.setEnabled(true); }
From source file:actions.DeleteAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection selection) { selectedObjects.clear();//ww w . java 2 s.c om if (selection instanceof IStructuredSelection) { IStructuredSelection structedSelection = (IStructuredSelection) selection; Object[] objects = structedSelection.toArray(); selectToBeRemoved(objects); } if (!selectedObjects.isEmpty() && PARENT_FEATURE != null) { action.setEnabled(true); } else action.setEnabled(false); }
From source file:actions.RenameAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection selection) { selectedObject = null;//from ww w. ja v a 2 s. c o m selectedNameAttribute = null; selectedROAttribute = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structedSelection = (IStructuredSelection) selection; if (structedSelection.size() > 0 && ALLOWED_TYPES != null && isSupportedType(structedSelection.getFirstElement())) { selectedObject = (EObject) structedSelection.getFirstElement(); } } if (selectedObject != null && ALLOWED_TYPES != null && !isObjectReadOnly(selectedObject)) { action.setEnabled(true); } else action.setEnabled(false); }
From source file:br.unb.cic.rtgoretoprism.action.AbstractCodeGeneractionAction.java
License:Open Source License
/** * Allow the selection only if a set of (sub)Actor has been chosen * /*w w w. j a va 2 s. co m*/ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */ public void selectionChanged(IAction action, ISelection selection) { //at first disable the action action.setEnabled(false); //if( shell == null ) // return; //assure no actor is selected selectedActors.clear(); selectedGoals.clear(); //then verify if it is necessary to enable it if (!(selection instanceof StructuredSelection)) return; //current selection StructuredSelection ss = (StructuredSelection) selection; Iterator it = ss.iterator(); while (it.hasNext()) { //current selected element Object selected = it.next(); //we expect only an MD_ActorUIEditPart type if ((selected instanceof MD_IntentionalUIEditPart)) { MD_IntentionalUIEditPart currEP = (MD_IntentionalUIEditPart) selected; MD_IntentionalUI currActorUI = (MD_IntentionalUI) currEP.getModel(); //current selected Actor model objectMD_ActorUIEditPart if (currActorUI.getSingleCore() instanceof FHardGoal) { FHardGoal currGoal = (FHardGoal) currActorUI.getSingleCore(); //add it to the set selectedGoals.add(currGoal); selectedActors.add(currGoal.getActor()); action.setEnabled(true); } } else { //we expect only an MD_ActorUIEditPart type if (!(selected instanceof MD_ActorUIEditPart)) return; MD_ActorUIEditPart currEP = (MD_ActorUIEditPart) selected; MD_ActorUI currActorUI = (MD_ActorUI) currEP.getModel(); //current selected Actor model objectMD_ActorUIEditPart Actor currActor = (Actor) currActorUI.getSingleCore(); //mm: Commented to allow code generation for all agents ////we accept only system one //if( !currActor.isIsSystem() ) // return; //add it to the set selectedActors.add(currActor); //get all owned subsystems, if any List subSystems = currActor.getSubsystems(); //add the to the set too for (Object a : subSystems) selectedActors.add((Actor) a); } //if here, we are ok so enable the action back action.setEnabled(true); } }
From source file:br.unb.cic.rtgoretoprism.action.JadexGUIAction.java
License:Open Source License
/** * Selection in the workbench has been changed. * /*from w w w. java 2s . co m*/ * @see IWorkbenchWindowActionDelegate#selectionChanged */ public void selectionChanged(IAction action, ISelection selection) { action.setEnabled(true); }
From source file:ca.usask.cs.srlab.simclipse.clone.comparison.CloneCompareAction.java
License:Open Source License
final public void selectionChanged(IAction action, ISelection selection) { action.setEnabled(false); this.selection = selection; if (action != null) action.setEnabled(isEnabled(selection)); }
From source file:ca.uvic.chisel.diver.sequencediagrams.sc.java.actions.OpenEditorAction.java
License:Open Source License
/** * Selection in the workbench has been changed. We * can change the state of the 'real' action here * if we want, but this can only happen after * the delegate has been created.// w w w . j av a2s . c o m * @see IWorkbenchWindowActionDelegate#selectionChanged */ public void selectionChanged(IAction action, ISelection selection) { action.setEnabled(false); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; this.method = null; for (Iterator<?> i = ss.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IAdaptable) { IMethod method = (IMethod) ((IAdaptable) o).getAdapter(IMethod.class); this.method = method; break; } } action.setEnabled(method != null); } }
From source file:ca.uvic.chisel.javasketch.ui.internal.TraceActionDelegate.java
License:Open Source License
private void updateAction(IAction action) { if (action == null) return;//from w w w.j ava 2s. c o m IProcess process = DebugUITools.getCurrentProcess(); ITraceClient client = SketchPlugin.getDefault().getAssociatedClient(process); if (client == null || client.isTerminated()) { //set the icon to "play" action.setImageDescriptor( SketchPlugin.imageDescriptorFromPlugin(SketchPlugin.PLUGIN_ID, "images/etool16/play_icon.png")); action.setText("Resume Trace"); action.setToolTipText("Resumes a paused trace"); action.setChecked(false); action.setEnabled(false); } else { if (client.isPaused()) { //set the icon to "play" action.setImageDescriptor(SketchPlugin.imageDescriptorFromPlugin(SketchPlugin.PLUGIN_ID, "images/etool16/play_icon.png")); action.setText("Resume Trace"); action.setToolTipText("Resumes a paused trace"); } else { //set the icon to "play" action.setImageDescriptor(SketchPlugin.imageDescriptorFromPlugin(SketchPlugin.PLUGIN_ID, "images/etool16/pause_icon.png")); action.setText("Pause Trace"); action.setToolTipText("Pauses a running trace"); } action.setEnabled(true); } }
From source file:ca.uwaterloo.gsd.wpi.code.ui.WpiModelCodeSynchronizeAction.java
License:Open Source License
@Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { if (targetEditor instanceof WpiEditor) super.setActiveEditor(action, targetEditor); else// ww w. ja v a 2 s .co m action.setEnabled(false); }
From source file:ch.elexis.actions.GlobalActions.java
License:Open Source License
private void setMenuForUser(final ACE ace, final IAction action) { if (Hub.acl.request(ace) == true) { action.setEnabled(true); } else {//w ww . j av a 2 s . co m action.setEnabled(false); } }