Java Code Examples for org.eclipse.jface.action.IAction

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/explorer/.

Source file: ResourcesView.java

  22 
vote

public void open(OpenEvent event){
  StructuredSelection selection=(StructuredSelection)event.getSelection();
  Iterator<?> i=selection.iterator();
  while (i.hasNext()) {
    Object obj=i.next();
    if (obj instanceof ExplorerNode) {
      ExplorerNode explorerNode=(ExplorerNode)obj;
      IAction openAction=explorerNode.getOpenAction();
      if (openAction != null)       openAction.run();
    }
  }
}
 

Example 2

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: CeylonEditor.java

  22 
vote

protected void rulerContextMenuAboutToShow(IMenuManager menu){
  addDebugActions(menu);
  super.rulerContextMenuAboutToShow(menu);
  menu.appendToGroup(GROUP_RULERS,new Separator());
  IAction action;
  action=getAction("FoldingExpandAll");
  menu.appendToGroup(GROUP_RULERS,action);
  action=getAction("FoldingCollapseAll");
  menu.appendToGroup(GROUP_RULERS,action);
}
 

Example 3

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/plot/.

Source file: PlottingActionBarManager.java

  22 
vote

@Override public void remove(String id){
  if (extraImageActions != null)   for (Iterator<IAction> it=this.extraImageActions.iterator(); it.hasNext(); ) {
    IAction action=it.next();
    if (action.getId() != null && action.getId().equals(id))     it.remove();
  }
  if (extra1DActions != null)   for (Iterator<IAction> it=this.extra1DActions.iterator(); it.hasNext(); ) {
    IAction action=it.next();
    if (action.getId() != null && action.getId().equals(id))     it.remove();
  }
}
 

Example 4

From project dawn-isenciaui, under directory /com.teaminabox.eclipse.wiki/src/com/teaminabox/eclipse/wiki/editors/.

Source file: WikiEditor.java

  22 
vote

@Override protected void createActions(){
  super.createActions();
  IAction action=new TextOperationAction(wikiPlugin().getResourceBundle(),"ContentAssistProposal.",this,ISourceViewer.CONTENTASSIST_PROPOSALS);
  action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
  setAction(WikiConstants.CONTENT_ASSIST,action);
}
 

Example 5

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/.

Source file: AuditView.java

  22 
vote

protected void createActions(){
  deleteAction=new DeleteLogAction(this);
  setAction("ClearLog",deleteAction);
  deleteAction.setEnabled(logFileName != null);
  refreshAction=new RefreshLogAction(this);
  setAction("RefreshLog",refreshAction);
  refreshAction.setEnabled(logFileName != null);
  IAction action=new OpenLogAction(this);
  setAction("OpenLog",action);
  action=new ShowEventCauseAction(this);
  setAction("ShowEventCause",action);
}
 

Example 6

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/jobs/.

Source file: CheckUpdatesJob.java

  22 
vote

private IAction createNoUpdateNotificationAction(){
  String text="No Update Available";
  IAction notificationAction=new Action(text){
    public void run(){
      InstaSearchUI.showMessage("You have the latest version (" + InstaSearchPlugin.getVersion() + ")");
      setEnabled(false);
    }
  }
;
  notificationAction.setDescription(text);
  notificationAction.setToolTipText(text);
  return notificationAction;
}
 

Example 7

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaActionBarContributor.java

  21 
vote

/** 
 * This removes from the specified <code>manager</code> all  {@link org.eclipse.jface.action.ActionContributionItem}s based on the  {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager,Collection<? extends IAction> actions){
  if (actions != null) {
    IContributionItem[] items=manager.getItems();
    for (int i=0; i < items.length; i++) {
      IContributionItem contributionItem=items[i];
      while (contributionItem instanceof SubContributionItem) {
        contributionItem=((SubContributionItem)contributionItem).getInnerItem();
      }
      if (contributionItem instanceof ActionContributionItem) {
        IAction action=((ActionContributionItem)contributionItem).getAction();
        if (actions.contains(action)) {
          manager.remove(contributionItem);
        }
      }
    }
  }
}
 

Example 8

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappActionBarContributor.java

  21 
vote

/** 
 * This removes from the specified <code>manager</code> all  {@link org.eclipse.jface.action.ActionContributionItem}s based on the  {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager,Collection<? extends IAction> actions){
  if (actions != null) {
    IContributionItem[] items=manager.getItems();
    for (int i=0; i < items.length; i++) {
      IContributionItem contributionItem=items[i];
      while (contributionItem instanceof SubContributionItem) {
        contributionItem=((SubContributionItem)contributionItem).getInnerItem();
      }
      if (contributionItem instanceof ActionContributionItem) {
        IAction action=((ActionContributionItem)contributionItem).getAction();
        if (actions.contains(action)) {
          manager.remove(contributionItem);
        }
      }
    }
  }
}
 

Example 9

From project bndtools, under directory /bndtools.core/src/bndtools/views/.

Source file: ImportsExportsView.java

  21 
vote

void fillActionBars(){
  IAction toggleShowSelfImports=new Action("showSelfImports",IAction.AS_CHECK_BOX){
    @Override public void runWithEvent(    Event event){
      if (isChecked()) {
        viewer.removeFilter(hideSelfImportsFilter);
      }
 else {
        viewer.addFilter(hideSelfImportsFilter);
      }
    }
  }
;
  toggleShowSelfImports.setChecked(false);
  toggleShowSelfImports.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID,"/icons/package_folder_impexp.gif"));
  toggleShowSelfImports.setToolTipText("Show self-imported packages");
  IToolBarManager toolBarManager=getViewSite().getActionBars().getToolBarManager();
  toolBarManager.add(toggleShowSelfImports);
}
 

Example 10

From project ccw, under directory /ccw.core/src/java/ccw/editors/clojure/.

Source file: BasicClojureEditorActionContributor.java

  21 
vote

public void setActiveEditor(IEditorPart part){
  if (fActiveEditorPart == part)   return;
  fActiveEditorPart=part;
  super.setActiveEditor(part);
  if (fActiveEditorPart instanceof ITextEditorExtension) {
    ITextEditorExtension extension=(ITextEditorExtension)fActiveEditorPart;
    for (int i=0; i < STATUS_FIELD_DEFS.length; i++)     extension.setStatusField(null,STATUS_FIELD_DEFS[i].category);
  }
  ITextEditor textEditor=null;
  if (part instanceof ITextEditor)   textEditor=(ITextEditor)part;
  IActionBars actionBars=getActionBars();
  IStatusLineManager manager=actionBars.getStatusLineManager();
  manager.setMessage(null);
  manager.setErrorMessage(null);
  IAction action=getAction(textEditor,ITextEditorActionConstants.NEXT);
  actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION,action);
  actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT,action);
  action=getAction(textEditor,ITextEditorActionConstants.PREVIOUS);
  actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION,action);
  actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS,action);
  for (int i=0; i < STATUS_FIELD_DEFS.length; i++) {
    if (fActiveEditorPart instanceof ITextEditorExtension) {
      StatusLineContributionItem statusField=(StatusLineContributionItem)fStatusFields.get(STATUS_FIELD_DEFS[i]);
      statusField.setActionHandler(getAction(textEditor,STATUS_FIELD_DEFS[i].actionId));
      ITextEditorExtension extension=(ITextEditorExtension)fActiveEditorPart;
      extension.setStatusField(statusField,STATUS_FIELD_DEFS[i].category);
    }
  }
}
 

Example 11

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseActionBarContributor.java

  21 
vote

/** 
 * This removes from the specified <code>manager</code> all  {@link org.eclipse.jface.action.ActionContributionItem}s based on the  {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void depopulateManager(IContributionManager manager,Collection<? extends IAction> actions){
  if (actions != null) {
    IContributionItem[] items=manager.getItems();
    for (int i=0; i < items.length; i++) {
      IContributionItem contributionItem=items[i];
      while (contributionItem instanceof SubContributionItem) {
        contributionItem=((SubContributionItem)contributionItem).getInnerItem();
      }
      if (contributionItem instanceof ActionContributionItem) {
        IAction action=((ActionContributionItem)contributionItem).getAction();
        if (actions.contains(action)) {
          manager.remove(contributionItem);
        }
      }
    }
  }
}
 

Example 12

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/system/.

Source file: LightWeightActionBarsManager.java

  21 
vote

public void createOriginActions(){
  final MenuAction origins=new MenuAction("Image Origin");
  origins.setId(getClass().getName() + ".imageOrigin");
  origins.setImageDescriptor(Activator.getImageDescriptor("icons/origins.png"));
  CheckableActionGroup group=new CheckableActionGroup();
  ImageOrigin imageOrigin=ImageOrigin.forLabel(Activator.getDefault().getPreferenceStore().getString(PlottingConstants.ORIGIN_PREF));
  IAction selectedAction=null;
  for (  final ImageOrigin origin : ImageOrigin.origins) {
    final IAction action=new Action(origin.getLabel(),IAction.AS_CHECK_BOX){
      public void run(){
        Activator.getDefault().getPreferenceStore().setValue(PlottingConstants.ORIGIN_PREF,origin.getLabel());
        system.getGraph().setImageOrigin(origin);
        setChecked(true);
      }
    }
;
    origins.add(action);
    group.add(action);
    if (imageOrigin == origin)     selectedAction=action;
  }
  if (selectedAction != null)   selectedAction.setChecked(true);
  final IActionBars bars=system.getActionBars();
  bars.getMenuManager().add(new Separator(origins.getId() + ".group"));
  bars.getMenuManager().insertAfter(origins.getId() + ".group",origins);
  twoDimensionalActions.add(new ActionContainer(origins,bars.getMenuManager()));
}
 

Example 13

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/ui/internal/views/java/.

Source file: RevealInThreadContribution.java

  21 
vote

/** 
 * @param manager
 */
private void fill(MenuManager manager){
  IProgramSketch sketch=SketchPlugin.getDefault().getActiveSketch();
  if (sketch != null && !sketch.isAnalysing() && !sketch.isRunning() && sketch.isConnected()) {
    IJavaElement selection=getActiveSelection();
    IThread[] threads=JavaSearchUtils.findThreadsForElement(sketch.getTraceData(),selection);
    for (    IThread thread : threads) {
      Map<String,String> parameters=new HashMap<String,String>();
      parameters.put(RevealActivationHandler.TRACE_PARAMETER,sketch.getID());
      parameters.put(RevealActivationHandler.THREAD_PARAMETER,thread.getIdentifier());
      IAction action=new CommandAction(RevealActivationHandler.COMMAND_ID,parameters);
      action.setImageDescriptor(SketchPlugin.getDefault().getImageRegistry().getDescriptor(ISketchImageConstants.ICON_TRACE_EDITOR));
      action.setText(thread.getName());
      manager.add(action);
    }
  }
}
 

Example 14

From project Eclipse, under directory /com.mobilesorcery.sdk.ui/src/com/mobilesorcery/sdk/ui/internal/actions/.

Source file: ChangeBuildConfigContextAction.java

  21 
vote

protected void fillMenu(Menu menu){
  MenuItem[] items=menu.getItems();
  for (  MenuItem item : items)   item.dispose();
  if (project.areBuildConfigurationsSupported()) {
    Set<String> cfgs=project.getBuildConfigurations();
    for (    String cfg : cfgs) {
      IAction action=new ChangeBuildConfigAction(project,cfg);
      IBuildConfiguration activeCfg=project.getActiveBuildConfiguration();
      action.setChecked(activeCfg != null && activeCfg.getId().equals(cfg));
      ActionContributionItem item=new ActionContributionItem(action);
      item.fill(menu,-1);
    }
  }
 else {
    IAction action=new ActivateBuildConfigurationsAction(project);
    ActionContributionItem item=new ActionContributionItem(action);
    item.fill(menu,-1);
  }
}
 

Example 15

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.ui/src/org/cloudfoundry/ide/eclipse/internal/server/ui/actions/.

Source file: CaldecottUIHelper.java

  21 
vote

/** 
 * Returns a list of applicable Caldecott Actions given the selection, or empty list if not actions are applicable.
 * @param selection
 * @param editorPage
 * @return non-null list of actions. May be empty.
 */
public List<IAction> getCaldecottActions(IStructuredSelection selection,final CloudFoundryApplicationsEditorPage editorPage){
  Collection<String> selectedServices=ModifyServicesForApplicationAction.getServiceNames(selection);
  List<IAction> actions=new ArrayList<IAction>();
  final CaldecottTunnelHandler handler=new CaldecottTunnelHandler(cloudServer);
  if (selectedServices != null && !selectedServices.isEmpty()) {
    final List<String> servicesWithTunnels=new ArrayList<String>();
    final List<String> servicesToAdd=getServicesWithNoTunnel(selectedServices,handler,servicesWithTunnels);
    if (!servicesToAdd.isEmpty()) {
      actions.add(new AddServiceStartCaldecottAction(servicesToAdd,cloudServer.getBehaviour(),editorPage,"Open Tunnel"));
    }
 else     if (!servicesWithTunnels.isEmpty()) {
      actions.add(new DisconnectCaldecottTunnelAction(editorPage,handler,servicesWithTunnels));
      IAction showCaldecottTunnelInfo=new Action("Show Tunnel Information...",CloudFoundryImages.CONNECT){
        public void run(){
          displayCaldecottTunnels(servicesWithTunnels);
        }
      }
;
      actions.add(showCaldecottTunnelInfo);
    }
  }
  return actions;
}
 

Example 16

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/actions/.

Source file: AddNativeAction.java

  19 
vote

@Override public void run(IAction action){
  IProject project=null;
  if (selection != null && selection instanceof IStructuredSelection) {
    IStructuredSelection ss=(IStructuredSelection)selection;
    if (ss.size() == 1) {
      Object obj=ss.getFirstElement();
      if (obj instanceof IProject) {
        project=(IProject)obj;
      }
 else       if (obj instanceof PlatformObject) {
        project=(IProject)((PlatformObject)obj).getAdapter(IProject.class);
      }
    }
  }
  if (project != null) {
    AddNativeWizard wizard=new AddNativeWizard(project,part.getSite().getWorkbenchWindow());
    WizardDialog dialog=new WizardDialog(part.getSite().getShell(),wizard);
    dialog.open();
  }
}
 

Example 17

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/rca/update/.

Source file: ManageConfigAction.java

  19 
vote

public void run(IAction action){
  BusyIndicator.showWhile(window.getShell().getDisplay(),new Runnable(){
    public void run(){
      UpdateManagerUI.openConfigurationManager(window.getShell());
    }
  }
);
}
 

Example 18

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/actions/.

Source file: DocumentGroupDelegate.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override public void run(IAction action){
  Shell shell=getCurrent().getActiveShell();
  InputDialog i=new InputDialog(shell,DIALOG_TITLE,DIALOG_PROMPT,"",new IInputValidator(){
    @Override public String isValid(    String newGrp){
      return validateDocumentGroup(newGrp);
    }
  }
);
  i.open();
  if (i.getReturnCode() == Window.OK) {
    String userInput=i.getValue();
    List<String> projects=getDefault().getSelectedProjects();
    for (    final String project : projects) {
      IWorkspaceRoot r=getWorkspace().getRoot();
      IProject p=r.getProject(project);
      IFolder f=p.getFolder(userInput);
      try {
        f.create(false,true,new NullProgressMonitor());
      }
 catch (      CoreException e) {
        logError(e);
      }
    }
  }
}
 

Example 19

From project Bio-PEPA, under directory /uk.ac.ed.inf.biopepa.ui/src/uk/ac/ed/inf/biopepa/ui/actions/.

Source file: AbstractAction.java

  19 
vote

public final void setActiveEditor(IAction action,IEditorPart targetEditor){
  if (model != null)   model.removeListener(this);
  this.action=action;
  if (action == null || targetEditor == null)   return;
  bioPEPAEditor=targetEditor;
  model=((BioPEPAEditor)targetEditor).getModel();
  model.addListener(this);
  this.action=action;
  activeShell=targetEditor.getEditorSite().getShell();
  checkStatus();
}
 

Example 20

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.nmrshiftdb/src/net/bioclipse/nmrshiftdb/actions/.

Source file: AssignByPredictionAction.java

  19 
vote

public void run(IAction action){
  try {
    if (this.editor != null) {
      if (this.editor instanceof SpecMolEditor) {
        SpecMolEditor specMolEditor=(SpecMolEditor)editor;
        CMLMolecule molecule=specMolEditor.getSpecmoleditorpage().getCurrentMolecule();
        CMLSpectrum spectrum=specMolEditor.getSpecmoleditorpage().getCurrentSpectrum();
        AssignPredictWizard predwiz=new AssignPredictWizard(molecule,spectrum,specMolEditor.getSpecmoleditorpage(),editor,false);
        WizardDialog wd=new WizardDialog(new Shell(),predwiz);
        wd.open();
      }
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
}
 

Example 21

From project bundlemaker, under directory /main/org.bundlemaker.core.ui.projecteditor/src/org/bundlemaker/core/ui/projecteditor/.

Source file: ProjectEditorPage.java

  19 
vote

protected void fillContextMenu(IMenuManager menuManager){
  List<IProjectContentProviderEditorElement> selectedTreeViewerElements=getSelectedObjects(_treeViewer.getSelection(),IProjectContentProviderEditorElement.class);
  Set<IProjectContentProviderEditor> contentProviderEditors=getProjectEditorContributionRegistry().getContentProviderEditors();
  for (  IProjectContentProviderEditor iProjectContentProviderEditor : contentProviderEditors) {
    List<IAction> contextMenuActions=iProjectContentProviderEditor.getContextMenuActions(_bundleMakerProject,selectedTreeViewerElements);
    if (contextMenuActions != null) {
      for (      IAction iAction : contextMenuActions) {
        menuManager.add(iAction);
      }
    }
  }
}
 

Example 22

From project CBCJVM, under directory /eclipse/CBC/src/cbc/actions/.

Source file: CBCAction.java

  19 
vote

public void run(IAction action){
  String workspace=helper.getWorkspace();
  String projectName=helper.getProjectName(workspace);
  String bin=workspace + helper.m_BinDir;
  m_IP=helper.getInputFromUser("Please input the CBC's IP:",m_IP);
  try {
    Ssh cbc=new Ssh("root",m_IP);
    if (cbc.sendCommand("/mnt/user/jvm/cjm/dlprep \"" + projectName + "\"") != 0) {
      helper.error("CBC Reported error preparing for download. It is advised to delete the project from the cbc, and try again. Please consider reinstalling CBCJava on the CBC.");
      return;
    }
    cbc.sendFile("/mnt/user/code/" + projectName + "/"+ projectName+ ".c",helper.getTmpCFile(projectName));
    helper.sendDirectory(cbc,projectName,true,"/",new File(bin));
    cbc.close();
    helper.message("Download Complete!");
  }
 catch (  IOException e) {
    helper.error("Exception occured: " + e.toString());
    e.printStackTrace();
  }
}
 

Example 23

From project dawn-tango, under directory /org.dawb.tango.extensions/src/org/dawb/tango/extensions/editors/actions/.

Source file: OpenSpecMonitorHandler.java

  19 
vote

@Override public void run(IAction action){
  try {
    execute(null);
  }
 catch (  ExecutionException e) {
    logger.error("Cannot run action",e);
  }
}
 

Example 24

From project dawn-third, under directory /org.dawb.org.csstudio.swt.xygraph/src/org/csstudio/swt/xygraph/toolbar/.

Source file: CheckableActionGroup.java

  19 
vote

@Override public void propertyChange(PropertyChangeEvent event){
  if (off)   return;
  try {
    off=true;
    final Action action=(Action)event.getSource();
    final Collection<IAction> others=new ArrayList<IAction>(actions);
    others.remove(action);
    action.setChecked(true);
    for (    IAction other : others)     other.setChecked(false);
  }
  finally {
    off=false;
  }
}
 

Example 25

From project dolphin, under directory /com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/actions/.

Source file: PathActionDelegate.java

  19 
vote

public void run(IAction action){
  final String tomcatDir=TomcatLauncherPlugin.getDefault().getTomcatDir();
  if (TomcatLauncherPlugin.checkTomcatSettingsAndWarn()) {
    command(tomcatDir + File.separatorChar + "conf"+ File.separatorChar+ "server.xml");
  }
}
 

Example 26

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/editorpage/pages/.

Source file: MappingMasterPage.java

  19 
vote

@Override protected void createToolBarActions(IManagedForm managedForm){
  final ScrolledForm form=managedForm.getForm();
  Action haction=new Action("hor",IAction.AS_RADIO_BUTTON){
    @Override public void run(){
      sashForm.setOrientation(SWT.HORIZONTAL);
      form.reflow(true);
    }
  }
;
  haction.setChecked(true);
  haction.setToolTipText(Messages.getString("MappingsPage.horizontal"));
  haction.setImageDescriptor(DozerPlugin.getDefault().getImageRegistry().getDescriptor(DozerPlugin.IMG_HORIZONTAL));
  Action vaction=new Action("ver",IAction.AS_RADIO_BUTTON){
    @Override public void run(){
      sashForm.setOrientation(SWT.VERTICAL);
      form.reflow(true);
    }
  }
;
  vaction.setChecked(false);
  vaction.setToolTipText(Messages.getString("MappingsPage.vertical"));
  vaction.setImageDescriptor(DozerPlugin.getDefault().getImageRegistry().getDescriptor(DozerPlugin.IMG_VERTICAL));
  form.getToolBarManager().add(haction);
  form.getToolBarManager().add(vaction);
}
 

Example 27

From project ds-annotation-builder, under directory /com.wuetherich.osgi.ds.annotations/src/com/wuetherich/osgi/ds/annotations/internal/actions/.

Source file: DisableNatureAction.java

  19 
vote

@Override public void run(IAction action){
  if (selection instanceof IStructuredSelection) {
    IStructuredSelection structuredSelection=(IStructuredSelection)selection;
    for (Iterator<?> it=structuredSelection.iterator(); it.hasNext(); ) {
      Object element=it.next();
      IProject project=null;
      if (element instanceof IProject) {
        project=(IProject)element;
      }
 else       if (element instanceof IAdaptable) {
        project=(IProject)((IAdaptable)element).getAdapter(IProject.class);
      }
      if (project != null) {
        try {
          disableNature(project,structuredSelection.size() == 1);
        }
 catch (        CoreException e) {
          e.printStackTrace();
        }
      }
    }
  }
}