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

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/core/ui/overview/.

Source file: Toolkit.java

  22 
vote

/** 
 * Creates and returns a link, which when selected, will run the specified IActionDelegate.
 * @param parent The parent composite in which to create the new link.
 * @param text The text to display for the link.
 * @param delegate The delegate object to run when the link is selected.
 * @return The new link.
 */
public Link newActionDelegateLink(Composite parent,String text,final IActionDelegate delegate){
  final Action proxy=new Action("runAction"){
    public void run(){
      delegate.run(this);
    }
  }
;
  Link link=new Link(parent,SWT.NONE);
  link.setText(createAnchor(text,text));
  link.setBackground(parent.getBackground());
  link.addListener(SWT.Selection,new Listener(){
    public void handleEvent(    Event event){
      proxy.run();
    }
  }
);
  return link;
}
 

Example 2

From project ccw, under directory /ccw.util/src/java/ccw/util/.

Source file: TextViewerSupport.java

  22 
vote

private IHandler createActionHandler(final int operation,String actionDefinitionId){
  Action action=new Action(){
    @Override public void run(){
      if (textViewer.canDoOperation(operation)) {
        textViewer.doOperation(operation);
      }
    }
  }
;
  action.setActionDefinitionId(actionDefinitionId);
  return new ActionHandler(action);
}
 

Example 3

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/.

Source file: MenuAdapter.java

  22 
vote

public void run(){
  String[] algorithmKeys=MenuAdapter.this.algorithmsToActions.keySet().toArray(new String[]{});
  for (int ii=0; ii < algorithmKeys.length; ii++) {
    Action item=MenuAdapter.this.algorithmsToActions.get(algorithmKeys[ii]);
    IMenuManager targetMenu=MenuAdapter.this.actionsToMenuManagers.get(item);
    targetMenu.remove(item.getId());
    MenuAdapter.this.algorithmsToActions.remove(algorithmKeys[ii]);
    MenuAdapter.this.actionsToMenuManagers.remove(item);
  }
}
 

Example 4

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

Source file: CheckableActionGroup.java

  22 
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 5

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.editor.ui/src/main/java/com/isencia/passerelle/workbench/model/editor/ui/editor/actions/.

Source file: CheckableActionGroup.java

  22 
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 6

From project dawn-product, under directory /org.dawnsci.intro/src/org/dawnsci/intro/actions/.

Source file: OpenCheatsheetAction.java

  22 
vote

@Override public void run(IIntroSite site,Properties params){
  String id=params.getProperty(ATT_ID);
  final Action action=new OpenCheatSheetAction(id);
  Display.getDefault().asyncExec(new Runnable(){
    @Override public void run(){
      if (action != null)       action.run();
    }
  }
);
}
 

Example 7

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

Source file: SharedMemoryEditor.java

  22 
vote

/** 
 * Override to provide extra content.
 * @param toolMan
 */
protected void createCustomToolbarActionsRight(final ToolBarManager toolMan){
  toolMan.add(new Separator(getClass().getName() + "Separator1"));
  final Action tableColumns=new Action("Open editor preferences.",IAction.AS_PUSH_BUTTON){
    @Override public void run(){
      PreferenceDialog pref=PreferencesUtil.createPreferenceDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"org.edna.workbench.editors.preferencePage",null,null);
      if (pref != null)       pref.open();
    }
  }
;
  tableColumns.setChecked(false);
  tableColumns.setImageDescriptor(Activator.getImageDescriptor("icons/application_view_columns.png"));
  toolMan.add(tableColumns);
}
 

Example 8

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

Source file: CheckableActionGroup.java

  22 
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 9

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

Source file: LightWeightActionBarsManager.java

  22 
vote

protected static void fillAnnotationConfigure(IMenuManager manager,final Annotation annotation,final IPlottingSystem system){
  final Action configure=new Action("Configure '" + annotation.getName() + "'",Activator.getImageDescriptor("icons/Configure.png")){
    public void run(){
      final XYRegionConfigDialog dialog=new XYRegionConfigDialog(Display.getCurrent().getActiveShell(),((LightWeightPlottingSystem)system).getGraph());
      dialog.setPlottingSystem(system);
      dialog.setSelectedAnnotation(annotation);
      dialog.open();
    }
  }
;
  manager.add(configure);
  manager.add(new Separator("org.dawb.workbench.plotting.system.configure.group"));
}
 

Example 10

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/.

Source file: HaskellEditor.java

  22 
vote

private void createTextOpAction(final String name,final int targetId,final String actionDefinitionId){
  ResourceBundle bundle=HaskellUIPlugin.getDefault().getResourceBundle();
  Action action=new TextOperationAction(bundle,name + ".",this,targetId);
  action.setActionDefinitionId(actionDefinitionId);
  setAction(name,action);
  markAsStateDependentAction(name,true);
}
 

Example 11

From project egit-github, under directory /org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/.

Source file: GistAttachmentPart.java

  22 
vote

/** 
 * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart#fillToolBar(org.eclipse.jface.action.ToolBarManager)
 */
protected void fillToolBar(ToolBarManager toolBarManager){
  Action attachFileAction=new Action(){
    @Override public void run(){
      EditorUtil.openNewAttachmentWizard(getTaskEditorPage(),Mode.DEFAULT,null);
    }
  }
;
  attachFileAction.setToolTipText(org.eclipse.mylyn.internal.tasks.ui.editors.Messages.TaskEditorAttachmentPart_Attach_);
  attachFileAction.setImageDescriptor(CommonImages.FILE_PLAIN_SMALL);
  toolBarManager.add(attachFileAction);
}
 

Example 12

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/ui/actions/.

Source file: CheckableActionGroup.java

  22 
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 13

From project neoclipse, under directory /org.neo4j.neoclipse/src/main/java/org/neo4j/neoclipse/view/.

Source file: NeoGraphMenu.java

  22 
vote

/** 
 * Add platform actions like showing the preference page.
 * @param mm current menu manager
 */
private void contributePlatformActions(final IMenuManager mm){
  Action preferencesAction=new Action(){
    @Override public void run(){
      Activator.getDefault().showPreferenceDialog(false);
    }
  }
;
  Actions.PREFERENCES.initialize(preferencesAction);
  mm.add(preferencesAction);
}
 

Example 14

From project netifera, under directory /platform/com.netifera.platform.host/com.netifera.platform.host.filesystem.ui/src/com/netifera/platform/host/filesystem/ui/.

Source file: FileSystemView.java

  22 
vote

private void initializeToolBar(){
  IToolBarManager toolBarManager=getViewSite().getActionBars().getToolBarManager();
  Action collapseAll=TreeAction.collapseAll(viewer);
  toolBarManager.add(collapseAll);
  toolBarManager.add(refreshAllAction);
}
 

Example 15

From project radrails, under directory /plugins/com.aptana.ide.editor.erb/src/com/aptana/ide/editor/erb/.

Source file: ERBSourceEditor.java

  22 
vote

@Override protected void createActions(){
  super.createActions();
  Action action=new OpenAction(this);
  action.setActionDefinitionId(IERBEditorActionConstants.OPEN_EDITOR);
  setAction(IERBEditorActionConstants.OPEN_EDITOR,action);
  action=new ExtractPartialAction(this);
  action.setActionDefinitionId(IERBEditorActionConstants.EXTRACT_PARTIAL_ACTION);
  setAction(IERBEditorActionConstants.EXTRACT_PARTIAL_ACTION,action);
  action=new ContentAssistAction(RubyPlugin.getDefault().getPluginProperties(),"ContentAssistProposal.",this);
  action.setActionDefinitionId(IERBEditorActionConstants.CONTENT_ASSIST_PROPOSALS);
  setAction(IERBEditorActionConstants.CONTENT_ASSIST_PROPOSALS,action);
}
 

Example 16

From project sandbox, under directory /xeclipse/org.xwiki.eclipse.ui/src/main/java/org/xwiki/eclipse/ui/editors/.

Source file: PageEditor.java

  22 
vote

@Override protected void createActions(){
  super.createActions();
  ResourceBundle bundle=ResourceBundle.getBundle("org.xwiki.eclipse.ui.editors.Editor");
  Action action=new TextOperationAction(bundle,"ContentAssistProposal.",this,ISourceViewer.CONTENTASSIST_PROPOSALS);
  String id=ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
  action.setActionDefinitionId(id);
  setAction("ContentAssistProposal",action);
  markAsStateDependentAction("ContentAssistProposal",true);
  removeActionActivationCode(ITextEditorActionConstants.PASTE);
}
 

Example 17

From project scisoft-ui, under directory /uk.ac.diamond.scisoft.analysis.rcp/src/uk/ac/diamond/scisoft/analysis/rcp/plotting/.

Source file: Plot1DUIAdapter.java

  22 
vote

public static IAction createShowLegend(final DataSetPlotter plotter){
  Action action=new Action("Show legend",IAction.AS_CHECK_BOX){
    @Override public void run(){
      if (plotter == null)       return;
      plotter.setUseLegend(isChecked());
    }
  }
;
  action.setImageDescriptor(ResourceManager.getImageDescriptor(Plot1DUIAdapter.class,"/icons/application_tile_vertical.png"));
  return action;
}
 

Example 18

From project substeps-eclipse-plugin, under directory /com.technophobia.substeps.testlauncher/src/main/java/com/technophobia/substeps/junit/ui/.

Source file: FailureTrace.java

  22 
vote

@Override public void menuAboutToShow(final IMenuManager manager){
  if (table.getSelectionCount() > 0) {
    final Action a=createOpenEditorAction(getSelectedText());
    if (a != null)     manager.add(a);
    manager.add(new SubstepsCopyAction(parent.getShell(),this,clipboard));
  }
  if (failure != null && failure.isComparisonFailure())   manager.add(compareAction);
}
 

Example 19

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

Source file: NamespaceView.java

  21 
vote

private void makeActions(){
  detailsAction=new Action(){
    @Override public void run(){
      launchBrowserForSelection();
    }
  }
;
  detailsAction.setText("Show Details");
  detailsAction.setToolTipText("Provide detailed information from web resource.");
  detailsAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_LCL_LINKTO_HELP));
}
 

Example 20

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/editor/.

Source file: SenecaJobEditorContributor.java

  21 
vote

public SenecaJobEditorContributor(){
  super();
  runAction=new Action(){
    @Override public void run(){
      ((SenecaJobEditor)getActiveEditorPart()).runJob();
    }
  }
;
  runAction.setText("Run Seneca Job");
  runAction.setToolTipText("Run Seneca Job");
  runAction.setImageDescriptor(Activator.getImageDescriptor("icons/play.gif"));
}
 

Example 21

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

Source file: OpenExtConfigsContributionItem.java

  21 
vote

@Override protected IContributionItem[] getContributionItems(){
  try {
    IFile buildFile=Central.getWorkspaceBuildFile();
    if (buildFile == null)     return EMPTY;
    IContainer cnfDir=buildFile.getParent();
    IFolder extDir=cnfDir.getFolder(new Path("ext"));
    if (extDir == null || !extDir.exists())     return EMPTY;
    IResource[] extFiles=extDir.members();
    List<IContributionItem> result=new ArrayList<IContributionItem>(extFiles.length);
    for (    final IResource extFile : extFiles) {
      if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
        Action action=new Action(){
          @Override public void run(){
            try {
              FileEditorInput input=new FileEditorInput((IFile)extFile);
              IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
              page.openEditor(input,"bndtools.bndWorkspaceConfigEditor",true);
            }
 catch (            PartInitException e) {
              ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"Error","Unable to open editor",e.getStatus());
            }
          }
        }
;
        action.setText("Open " + extFile.getProjectRelativePath());
        action.setImageDescriptor(extFileImg);
        result.add(new ActionContributionItem(action));
      }
    }
    return result.toArray(new IContributionItem[result.size()]);
  }
 catch (  Exception e) {
    logger.logError("Unable to find default config files",e);
    return EMPTY;
  }
}
 

Example 22

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/property/.

Source file: ImprovedAdvancedPropertiesComposite.java

  21 
vote

private void createMenuItems(MenuManager manager,String prefix,EObject baseElement,boolean root){
  ItemProviderAdapter itemProviderAdapter=(ItemProviderAdapter)new Bpmn2ItemProviderAdapterFactory().adapt(baseElement,ItemProviderAdapter.class);
  Collection<CommandParameter> desc=(Collection<CommandParameter>)itemProviderAdapter.getNewChildDescriptors(baseElement,diagramEditor.getEditingDomain(),null);
  EList<EReference> eAllContainments=baseElement.eClass().getEAllContainments();
  for (  CommandParameter command : desc) {
    EStructuralFeature feature=(EStructuralFeature)command.feature;
    EObject commandValue=(EObject)command.value;
    if (root) {
      if (eAllContainments.contains(feature) && prefs.isEnabled(commandValue.eClass()) && prefs.isEnabled(commandValue.eClass(),feature)) {
        Object value=baseElement.eGet(feature);
        String name=PropertyUtil.deCamelCase(commandValue.eClass().getName());
        Action item=createMenuItemFor(prefix + name,baseElement,(EReference)feature,command.value);
        item.setEnabled(value == null || value instanceof EList);
        manager.add(item);
      }
    }
 else {
      if (eAllContainments.contains(feature) && prefs.isEnabled(baseElement.eClass(),feature)) {
        Object value=baseElement.eGet(feature);
        String name=PropertyUtil.deCamelCase(commandValue.eClass().getName());
        Action item=createMenuItemFor(prefix + name,baseElement,(EReference)feature,command.value);
        item.setEnabled(value == null || value instanceof EList);
        manager.add(item);
      }
    }
  }
}
 

Example 23

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

Source file: TimeLineAnnotationHook.java

  21 
vote

@Override public void menuAboutToShow(IMenuManager manager){
  Point p=editor.getTimeRange().getDisplay().getCursorLocation();
  p=editor.getTimeRange().toControl(p);
  RangeAnnotation r=editor.getTimeRange().itemAt(p);
  if (r != null) {
    IActivation a=getActivation(r.getData());
    IJavaElement je=getJavaElement(r.getData());
    if (a != null) {
      Map<String,String> params=new HashMap<String,String>();
      params.put(RevealActivationHandler.THREAD_PARAMETER,a.getThread().getIdentifier());
      params.put(RevealActivationHandler.TRACE_PARAMETER,a.getTrace().getIdentifier());
      Action revealAction=new CommandAction(RevealActivationHandler.COMMAND_ID,params);
      revealAction.setText("Reveal " + a.getMethod().getName());
      manager.add(revealAction);
      Action focusInAction=new CommandAction(FocusInHandler.COMMAND_ID,null);
      focusInAction.setText("Focus On " + a.getMethod().getName());
      manager.add(focusInAction);
      openJEAction.setJavaElement(je);
    }
  }
 else {
    openJEAction.setJavaElement(null);
  }
}
 

Example 24

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

Source file: MappingMasterPage.java

  21 
vote

protected void fillContextMenu(IMenuManager manager){
  manager.removeAll();
  TreeSelection selection=(TreeSelection)filteredTree.getViewer().getSelection();
  Action fRemoveAction=new Action("Remove Class-Mapping"){
    @Override public void run(){
      StructuredSelection structuredSelection=(StructuredSelection)mappings.getSelection();
      Element selected=(Element)structuredSelection.getFirstElement();
      if ("mapping".equals(selected.getNodeName())) {
        deleteItem();
      }
 else       if ("field".equals(selected.getNodeName()) || "field-exclude".equals(selected.getNodeName())) {
        Element parentNode=(Element)selected.getParentNode();
        parentNode.getParentNode().removeChild(parentNode);
        mappings.refresh();
      }
    }
  }
;
  Action fFieldRemoveAction=new Action("Remove Field-Mapping"){
    @Override public void run(){
      deleteItem();
    }
  }
;
  if (!selection.isEmpty()) {
    manager.add(fAddClassMappingAction);
    manager.add(fRemoveAction);
    manager.add(new Separator());
    manager.add(fAddFieldMappingAction);
    manager.add(fAddFieldExcludeMappingAction);
    Element element=(Element)selection.getFirstElement();
    if ("field".equals(element.getNodeName()) || "field-exclude".equals(element.getNodeName())) {
      manager.add(fFieldRemoveAction);
    }
  }
}
 

Example 25

From project droolsjbpm-tools, under directory /drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/views/.

Source file: ResourceHistoryView.java

  21 
vote

private void makeActions(){
  showVersionAction=new Action(){
    public void run(){
      showResourceVersionContents();
    }
  }
;
  showVersionAction.setText(Messages.getString("action.open"));
  showVersionAction.setToolTipText(Messages.getString("action.open.desc"));
  showVersionAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
}
 

Example 26

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

Source file: CheckUpdatesJob.java

  21 
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 27

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

Source file: CaldecottTunnelWizardPage.java

  21 
vote

public void createControl(Composite parent){
  part=new TunnelDisplayPart(getShell(),cloudServer,null){
    @Override protected List<IAction> getViewerActions(    List<CaldecottTunnelDescriptor> descriptors){
      List<IAction> actions=super.getViewerActions(descriptors);
      actions=actions != null ? new ArrayList<IAction>(actions) : new ArrayList<IAction>();
      if (!descriptors.isEmpty()) {
        Action caldecottAction=new DeleteTunnelAction("Disconnect",CloudFoundryImages.DISCONNECT);
        actions.add(caldecottAction);
      }
      return actions;
    }
  }
;
  Control area=part.createControl(parent);
  setControl(area);
}
 

Example 28

From project eclipse-task-editor, under directory /plugins/de.sebastianbenz.task.ui/src/de/sebastianbenz/task/ui/views/.

Source file: TodoView.java

  21 
vote

private Action createActionJumpToElement(){
  return new Action(){
    @Override public void run(){
      ISelection selection=viewer.getSelection();
      Object obj=((IStructuredSelection)selection).getFirstElement();
      if (obj instanceof EObject) {
        editorOpener.open(getURI((EObject)obj),true);
      }
    }
  }
;
}
 

Example 29

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/.

Source file: BundlesView.java

  21 
vote

private void createActions(){
  propertiesAction=new Action(){
    @Override public void run(){
      final IStructuredSelection selection=(IStructuredSelection)treeTableViewer.getSelection();
      if (!selection.isEmpty()) {
      }
    }
  }
;
  propertiesAction.setText("Properties...");
}
 

Example 30

From project Foglyn, under directory /com.foglyn.ui/src/com/foglyn/ui/.

Source file: TaskEditorFogbugzEventsPart.java

  21 
vote

@Override protected void fillToolBar(ToolBarManager barManager){
  if (comments.isEmpty()) {
    return;
  }
  Action reorderCommentsAction=new Action(""){
    @Override public void run(){
      reorderComments();
      reorderCommentsEnabled=!reorderCommentsEnabled;
      FoglynUIPlugin.saveOption(REORDER_COMMENTS_PREF,Boolean.valueOf(reorderCommentsEnabled).toString());
    }
  }
;
  reorderCommentsAction.setImageDescriptor(FoglynImages.UP_DOWN_SMALL);
  reorderCommentsAction.setToolTipText("Change Order of Events");
  barManager.add(reorderCommentsAction);
  Action collapseAllAction=new Action(""){
    @Override public void run(){
      hideOrExpandEvents(false);
    }
  }
;
  collapseAllAction.setImageDescriptor(FoglynImages.COLLAPSE_ALL_SMALL);
  collapseAllAction.setToolTipText("Collapse All Comments");
  barManager.add(collapseAllAction);
  Action expandAllAction=new Action(""){
    @Override public void run(){
      hideOrExpandEvents(true);
    }
  }
;
  expandAllAction.setImageDescriptor(FoglynImages.EXPAND_ALL_SMALL);
  expandAllAction.setToolTipText("Expand All Comments");
  barManager.add(expandAllAction);
}
 

Example 31

From project gmc, under directory /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/utils/.

Source file: GUIHelper.java

  21 
vote

public Action createPullDownMenu(String menuName,String iconPath,final MenuManager menuManager){
  Action action=new Action(menuName,IAction.AS_DROP_DOWN_MENU){
    public void run(){
    }
  }
;
  action.setMenuCreator(new IMenuCreator(){
    @Override public Menu getMenu(    Menu menu){
      return null;
    }
    @Override public Menu getMenu(    Control control){
      return menuManager.createContextMenu(control);
    }
    @Override public void dispose(){
    }
  }
);
  action.setImageDescriptor(getImageDescriptor(iconPath));
  return action;
}
 

Example 32

From project gted, under directory /net.sf.gted.editor/src/net/sf/gted/editor/entry/master/.

Source file: POMasterDetailsBlock.java

  21 
vote

/** 
 * Create the toolbar actions
 * @param managedForm
 */
@Override protected void createToolBarActions(IManagedForm managedForm){
  final ScrolledForm form=managedForm.getForm();
  Action vaction=new Action("ver",Action.AS_RADIO_BUTTON){
    public void run(){
      setSashFormVertical(form);
    }
  }
;
  vaction.setChecked(vertical);
  vaction.setToolTipText("vertical");
  vaction.setImageDescriptor(POFileEditorPlugin.getImageDescriptor("icons/th_vertical.gif"));
  Action haction=new Action("hor",Action.AS_RADIO_BUTTON){
    public void run(){
      setSashFormHorizontal(form);
    }
  }
;
  haction.setChecked(horizontal);
  haction.setToolTipText("horizontal");
  haction.setImageDescriptor(POFileEditorPlugin.getImageDescriptor("icons/th_horizontal.gif"));
  form.getToolBarManager().add(haction);
  form.getToolBarManager().add(vaction);
}
 

Example 33

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/ui/console/.

Source file: IvyConsoleFilterAction.java

  21 
vote

public Menu getMenu(Control parent){
  if (fMenu != null) {
    fMenu.dispose();
  }
  fMenu=new Menu(parent);
  for (int i=0; i < LOG_LEVEL_MESSAGES.length; i++) {
    final int logLevel=i;
    Action action=new Action(LOG_LEVEL_MESSAGES[i]){
      public void run(){
        console.setLogLevel(logLevel);
      }
    }
;
    action.setChecked(console.getLogLevel() == i);
    addActionToMenu(fMenu,action);
  }
  return fMenu;
}
 

Example 34

From project JGit, under directory /org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/.

Source file: GitHistoryPage.java

  21 
vote

private IAction createFindToolbarAction(){
  final IAction r=new Action("Fi",UIIcons.ELCL16_FIND){
    public void run(){
      prefs.setValue(SHOW_FIND_TOOLBAR,isChecked());
      layout();
    }
  }
;
  r.setChecked(prefs.getBoolean(SHOW_FIND_TOOLBAR));
  r.setToolTipText(UIText.HistoryPage_findbar_findTooltip);
  return r;
}
 

Example 35

From project JsTestDriver, under directory /eclipse-plugin/plugins/com.google.eclipse.javascript.jstestdriver.test/src/com/google/eclipse/javascript/jstestdriver/ui/view/actions/.

Source file: ServerStartStopViewActionDelegateTest.java

  21 
vote

public void testClickingOnActionToglesIconAndTextBetweenStartStop(){
  Server server=Server.getInstance(4224);
  ServerStartStopViewActionDelegate delegate=new ServerStartStopViewActionDelegate(server,new Icons(){
    @Override public ImageDescriptor startServerIcon(){
      startServerIconCalled=true;
      stopServerIconCalled=false;
      return null;
    }
    @Override public ImageDescriptor stopServerIcon(){
      startServerIconCalled=false;
      stopServerIconCalled=true;
      return null;
    }
  }
);
  Action action=new Action(){
  }
;
  delegate.run(action);
  assertEquals("Stop Server",action.getText());
  assertTrue(stopServerIconCalled);
  assertFalse(startServerIconCalled);
  delegate.run(action);
  assertEquals("Start Server",action.getText());
  assertTrue(startServerIconCalled);
  assertFalse(stopServerIconCalled);
}
 

Example 36

From project m2eclipse-hudson, under directory /org.sonatype.m2e.hudson.ui/src/main/java/com/sonatype/buildserver/eclipse/ui/job/view/.

Source file: SingleJobView.java

  21 
vote

void constructToolbar(ScrolledForm form){
  Action refreshAction=new Action(Messages.jobView_actions_refresh_title){
    public void run(){
      job.refresh();
    }
  }
;
  refreshAction.setImageDescriptor(HudsonImages.getImageDescriptor(HudsonImages.REFRESH));
  refreshAction.setToolTipText(Messages.jobView_actions_refresh_tooltip);
  Action buildNowAction=new Action(Messages.jobView_actions_build_title){
    @Override public void run(){
      HudsonUtils.runBuild(job);
    }
  }
;
  buildNowAction.setToolTipText(Messages.jobView_actions_build_tooltip);
  buildNowAction.setImageDescriptor(HudsonImages.BUILD_DESCRIPTOR);
  form.getToolBarManager().add(buildNowAction);
  form.getToolBarManager().add(refreshAction);
  form.updateToolBar();
}
 

Example 37

From project mylyn.builds, under directory /org.eclipse.mylyn.builds.ui/src/org/eclipse/mylyn/internal/builds/ui/editor/.

Source file: ArtifactsPart.java

  21 
vote

@Override protected void fillToolBar(ToolBarManager toolBarManager){
  super.fillToolBar(toolBarManager);
  toolBarManager.add(new Action("Collapse All",CommonImages.COLLAPSE_ALL){
    public void run(){
      viewer.collapseAll();
    }
  }
);
}
 

Example 38

From project mylyn.incubator, under directory /org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/actions/.

Source file: ToggleRelationshipProviderAction.java

  21 
vote

public void addActionsToMenu(){
  degreeOfSeparation=getCurrentProvider().getCurrentDegreeOfSeparation();
  MenuItem menuItem=new MenuItem(dropDownMenu,SWT.NONE);
  menuItem.setText(LABEL_DEGREE_OF_SEPARATION);
  new MenuItem(dropDownMenu,SWT.SEPARATOR);
  for (  IDegreeOfSeparation separation : getCurrentProvider().getDegreesOfSeparation()) {
    Action degreeOfSeparationSelectionAction=new Action(separation.getDegree() + ": " + separation.getLabel(),AS_CHECK_BOX){
      @Override public void run(){
        try {
          degreeOfSeparation=Integer.parseInt(getId());
          ActiveSearchView.getFromActivePerspective().updateDegreesOfSeparation(providers,degreeOfSeparation);
        }
 catch (        NumberFormatException e) {
          StatusHandler.log(new Status(IStatus.ERROR,ContextUiPlugin.ID_PLUGIN,"Invalid degree of separation",e));
        }
      }
    }
;
    degreeOfSeparationSelectionAction.setId("" + separation.getDegree());
    degreeOfSeparationSelectionAction.setEnabled(true);
    degreeOfSeparationSelectionAction.setToolTipText(separation.getLabel());
    ActionContributionItem item=new ActionContributionItem(degreeOfSeparationSelectionAction);
    item.fill(dropDownMenu,-1);
    degreeOfSeparationSelectionAction.setChecked(false);
    if (degreeOfSeparation == 0 && separation.getDegree() == 0) {
      degreeOfSeparationSelectionAction.setChecked(true);
    }
 else     if (degreeOfSeparation != 0 && separation.getDegree() != 0 && degreeOfSeparation == separation.getDegree()) {
      degreeOfSeparationSelectionAction.setChecked(true);
    }
  }
}
 

Example 39

From project Newsreader, under directory /bundles/org.eclipse.ecf.salvo.ui/src/org/eclipse/ecf/salvo/ui/internal/views/digest/.

Source file: DigestView.java

  21 
vote

/** 
 * Create the actions.
 */
private void createActions(){
  selectServerAction=new Action("Select Server"){
    public void run(){
      Shell shell=new Shell();
      SelectServerDialog selectServerDialog=new SelectServerDialog(shell);
      selectServerDialog.open();
      treeViewer.setInput(getSelectedServer());
    }
  }
;
  selectServerAction.setToolTipText("Select Server");
  selectServerAction.setImageDescriptor(ImageUtils.getInstance().getImageDescriptor("selectServer.gif"));
}
 

Example 40

From project org.openscada.orilla, under directory /org.openscada.ca.ui.connection/src/org/openscada/ca/ui/connection/.

Source file: CommonActionProvider.java

  21 
vote

@Override public void init(final ICommonActionExtensionSite aSite){
  super.init(aSite);
  final ICommonViewerSite viewSite=aSite.getViewSite();
  if (viewSite instanceof ICommonViewerWorkbenchSite) {
    final ICommonViewerWorkbenchSite workbenchSite=(ICommonViewerWorkbenchSite)viewSite;
    this.openAction=new Action("Open",IAction.AS_PUSH_BUTTON){
      @Override public void run(){
        EditorHelper.handleOpen(workbenchSite.getPage(),workbenchSite.getSelectionProvider());
      }
    }
;
  }
}
 

Example 41

From project RegexUtil, under directory /RegexUtil/src/com/ess/regexutil/views/.

Source file: RegexView.java

  21 
vote

private IAction createAboutAction(){
  IAction res=new Action(){
    @Override public void run(){
      MessageDialog.openInformation(getViewSite().getShell(),"About Regex Util","http://myregexp.com/\n\n(c) 2007 by Sergey Evdokimov ([email protected])");
    }
  }
;
  res.setToolTipText("About");
  res.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
  return res;
}
 

Example 42

From project swtbot, under directory /org.eclipse.swtbot.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/test/ui/editors/.

Source file: MultiPageEditorContributor.java

  21 
vote

private void createActions(){
  sampleAction=new Action(){
    public void run(){
      MessageDialog.openInformation(null,"SWTBot Eclipse Control Finder Plug-in Test (incubation)","Sample Action Executed");
    }
  }
;
  sampleAction.setText("Sample Action");
  sampleAction.setToolTipText("Sample Action tool tip");
  sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
}
 

Example 43

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

Source file: ResultCollectorJob.java

  20 
vote

protected Action createOKAction(final IResultData data){
  return new Action("View results"){
    public void run(){
      InfoWithAxes info=new InfoWithAxes();
      Series x=Series.create(data.getTimeSeries(),"Time");
      info.setXSeries(x);
      for (int s=0; s < data.getNumberOfInstances(); s++) {
        Series y=Series.create(data.getValues(s),"Exp. " + (s + 1));
        info.getYSeries().add(y);
      }
      info.setYLabel("Probability");
      info.setShowLegend(true);
      info.setShowMarkers(false);
      info.setGraphTitle("Passage-Time Analysis");
      IChart chart=Plotting.getPlottingTools().createTimeSeriesChart(info);
      uk.ac.ed.inf.common.ui.plotview.PlotViewPlugin.getDefault().reveal(chart);
    }
  }
;
}
 

Example 44

From project bpelunit, under directory /tycho/net.bpelunit.framework.client.eclipse/src/net/bpelunit/framework/client/eclipse/views/.

Source file: BPELUnitView.java

  20 
vote

private void makeActions(){
  fStopTestAction=new Action(){
    @Override public void run(){
      fStopTestAction.setEnabled(false);
      fTestRunSession.stopTest();
    }
  }
;
  fStopTestAction.setText("Stop Test");
  fStopTestAction.setToolTipText("Stops the current test execution");
  fStopTestAction.setImageDescriptor(BPELUnitActivator.getImageDescriptor("icons/stop.gif"));
  fStopTestAction.setEnabled(false);
  fReRunAction=new Action(){
    @Override public void run(){
      fTestRunSession.relaunchTest();
    }
  }
;
  fReRunAction.setText("Re-Run Last Test Suite");
  fReRunAction.setToolTipText("Re-Runs the current test");
  fReRunAction.setImageDescriptor(BPELUnitActivator.getImageDescriptor("icons/relaunch.gif"));
  fReRunAction.setEnabled(false);
}
 

Example 45

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

Source file: TreeViewPopup.java

  20 
vote

@Override protected Control createTitleMenuArea(Composite parent){
  fViewMenuButtonComposite=(Composite)super.createTitleMenuArea(parent);
  if (hasHeader()) {
    fFilterText=createFilterText(parent);
  }
  fShowViewMenuAction=new Action("showViewMenu"){
    @Override public void run(){
      showDialogMenu();
    }
  }
;
  fShowViewMenuAction.setEnabled(true);
  fShowViewMenuAction.setActionDefinitionId(WINDOW_SHOW_VIEW_MENU);
  return fViewMenuButtonComposite;
}
 

Example 46

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.dashboard.ui/src/org/springsource/ide/eclipse/dashboard/internal/ui/editors/.

Source file: DashboardMainPage.java

  20 
vote

private void createHeader(){
  IManagedForm headerForm=dashboardEditor.getHeaderForm();
  Form topForm=headerForm.getForm().getForm();
  final IToolBarManager toolBarManager=topForm.getToolBarManager();
  toolBarManager.removeAll();
  toolBarManager.update(true);
  toolBarManager.add(new ControlContribution("springSource_search"){
    @Override protected Control createControl(    Composite parent){
      Composite composite=new Composite(parent,SWT.NONE);
      composite.setBackground(null);
      GridLayout layout=new GridLayout(2,false);
      layout.marginRight=0;
      layout.marginHeight=0;
      layout.marginTop=3;
      layout.verticalSpacing=1;
      composite.setLayout(layout);
      GridDataFactory.fillDefaults().align(SWT.FILL,SWT.BOTTOM).grab(false,true).applyTo(composite);
      createSearchBox(composite);
      return composite;
    }
  }
);
  toolBarManager.add(new Action("SpringSource",IdeUiPlugin.getImageDescriptor(LOGO_SPRINGSOURCE)){
    @Override public void run(){
      TasksUiUtil.openUrl(ResourceProvider.getUrl(RESOURCE_DASHBOARD_LOGO));
    }
  }
);
  toolBarManager.update(true);
}
 

Example 47

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.ui.taskview/src/org/springsource/ide/eclipse/gradle/ui/taskview/.

Source file: GradleTasksView.java

  20 
vote

private void makeActions(){
  linkWithSelectionAction=new ToggleLinkingAction(this);
  refreshAction=new RefreshAction(this);
  doubleClickAction=new Action(){
    public void run(){
      ISelection selection=viewer.getSelection();
      Object obj=((IStructuredSelection)selection).getFirstElement();
      if (obj instanceof Task) {
        Task task=(Task)obj;
        GradleProject project=projectSelector.getProject();
        if (project != null) {
          final ILaunchConfiguration conf=GradleLaunchConfigurationDelegate.getOrCreate(project,task.getPath());
          JobUtil.schedule(NO_RULE,new GradleRunnable(project.getDisplayName() + " " + task.getPath()){
            @Override public void doit(            IProgressMonitor mon) throws Exception {
              conf.launch("run",mon,false,true);
            }
          }
);
        }
      }
    }
  }
;
}
 

Example 48

From project eclipse.platform.runtime, under directory /bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/.

Source file: TableWithTotalView.java

  20 
vote

private void createCommonActions(){
  copyAction=new Action(){
    public void run(){
      IStructuredSelection selection=(IStructuredSelection)viewer.getSelection();
      String result="";
      String[] columnHeaders=getColumnHeaders();
      for (int i=0; i < columnHeaders.length; i++)       result+=columnHeaders[i] + ",";
      result+="\n\n";
      ITableLabelProvider labelProvider=(ITableLabelProvider)viewer.getLabelProvider();
      for (Iterator iterator=selection.iterator(); iterator.hasNext(); ) {
        Object selectedItem=iterator.next();
        for (int i=0; i < columnHeaders.length; i++)         result+=labelProvider.getColumnText(selectedItem,i) + ",";
        result+="\n";
      }
      clipboard.setContents(new Object[]{result},new Transfer[]{TextTransfer.getInstance()});
    }
  }
;
  IActionBars actionBars=getViewSite().getActionBars();
  actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),copyAction);
  selectAllAction=new Action(){
    public void run(){
      tableTree.selectAll();
      viewer.setSelection(viewer.getSelection());
    }
  }
;
  actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),selectAllAction);
}
 

Example 49

From project hackergarten-moreunit, under directory /org.moreunit.plugin/src/org/moreunit/ui/.

Source file: MethodPage.java

  20 
vote

private void createToolbar(){
  this.filterPrivateAction=new Action("",IAction.AS_CHECK_BOX){
    @Override public void run(){
      actionFilterPrivateMethods();
    }
  }
;
  this.filterPrivateAction.setImageDescriptor(MoreUnitPlugin.getImageDescriptor("icons/private.gif"));
  this.filterPrivateAction.setChecked(false);
  this.filterPrivateAction.setToolTipText("Filter private methods");
  this.filterGetterAction=new Action("",IAction.AS_CHECK_BOX){
    @Override public void run(){
      actionFilterGetterMethods();
    }
  }
;
  this.filterGetterAction.setImageDescriptor(MoreUnitPlugin.getImageDescriptor("icons/getter.gif"));
  this.filterGetterAction.setChecked(false);
  this.filterGetterAction.setToolTipText("Filter getter/setter");
  this.addTestAction=new Action("Add..."){
    @Override public void run(){
      addItem();
    }
  }
;
  this.addTestAction.setImageDescriptor(MoreUnitPlugin.getImageDescriptor("icons/add.png"));
  this.addTestAction.setToolTipText("Add test");
  IToolBarManager toolBarManager=getSite().getActionBars().getToolBarManager();
  toolBarManager.add(this.filterPrivateAction);
  toolBarManager.add(this.filterGetterAction);
  toolBarManager.add(this.addTestAction);
}
 

Example 50

From project incubator, under directory /net.karlmartens.ui/test/net/karlmartens/ui/widget/.

Source file: TableTest.java

  20 
vote

public static void main(String[] args) throws Exception {
  final Shell shell=new Shell();
  final Display display=shell.getDisplay();
  shell.setLayout(new FillLayout());
  final Table table=new Table(shell,SWT.NONE);
  table.setHeaderVisible(true);
  table.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
  table.setFont(new Font(display,"Arial",10,SWT.NONE));
  table.addColumnSortSupport();
  IMenuManager menuManager=table.getColumnMenuManager();
  menuManager.appendToGroup(Table.GROUP_COMMAND,new Action("Test"){
    @Override public void run(){
      MessageDialog.openInformation(shell,"Test","Test");
    }
  }
);
  final TableColumn[] columns={new TableColumn(table,SWT.NONE),new TableColumn(table,SWT.CHECK)};
  columns[0].setText("Target");
  columns[0].setWidth(75);
  columns[1].setText("Enabled");
  columns[1].setWidth(60);
  final TableItem[] items={new TableItem(table),new TableItem(table),new TableItem(table),new TableItem(table),new TableItem(table)};
  items[0].setText(new String[]{"Rigs","true"});
  items[1].setText(new String[]{"Capital","true"});
  items[2].setText(new String[]{"Oil","true"});
  items[3].setText(new String[]{"Water","true"});
  items[4].setText(new String[]{"Steel","true"});
  shell.open();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch())     display.sleep();
  }
}
 

Example 51

From project libra, under directory /plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/dependencies/.

Source file: BundleDependencyEditorPage.java

  20 
vote

void fillContextMenu(IMenuManager manager){
  manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
  if (!viewer.getSelection().isEmpty()) {
    manager.add(new Action("Show Bundle Overview"){
      @Override public void run(){
        Object obj=((IStructuredSelection)viewer.getSelection()).getFirstElement();
        if (obj instanceof IBundle) {
          openDependencyPage((IBundle)obj);
        }
      }
    }
);
    manager.add(new Separator());
  }
  manager.add(zoomContributionItem);
}
 

Example 52

From project m2eclipse-webby, under directory /org.sonatype.m2e.webby/src/org/sonatype/m2e/webby/internal/view/.

Source file: WebbyView.java

  20 
vote

private void createActions(){
  stop=new Action("Stop",WebbyImages.STOP_DESC){
    @Override public void run(){
      stop();
    }
  }
;
  stop.setToolTipText("Stops the selected web applications");
  browse=new Action("Browse",WebbyImages.BROWSE_DESC){
    @Override public void runWithEvent(    Event event){
      browse((event.stateMask & EXTERNAL_BROWSER_MOD_MASK) != 0);
    }
  }
;
  browse.setToolTipText("Opens the selected web application, hold modifier key to open in external browser");
  updateActions();
}
 

Example 53

From project mylyn.context, under directory /org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/editors/.

Source file: ContextEditorFormPage.java

  20 
vote

private void createToolBar(Section section){
  Composite composite=toolkit.createComposite(section);
  composite.setBackground(null);
  section.setTextClient(composite);
  ToolBarManager manager=new ToolBarManager(SWT.FLAT);
  manager.add(new Action(Messages.ContextEditorFormPage_Collapse_All,CommonImages.COLLAPSE_ALL_SMALL){
    @Override public void run(){
      if (commonViewer != null && commonViewer.getTree() != null && !commonViewer.getTree().isDisposed()) {
        commonViewer.collapseAll();
      }
    }
  }
);
  manager.add(new Action(Messages.ContextEditorFormPage_Expand_All,CommonImages.EXPAND_ALL_SMALL){
    @Override public void run(){
      if (commonViewer != null && commonViewer.getTree() != null && !commonViewer.getTree().isDisposed()) {
        commonViewer.expandAll();
      }
    }
  }
);
  manager.createControl(composite);
}
 

Example 54

From project p2-browser, under directory /com.ifedorenko.p2browser/src/com/ifedorenko/p2browser/views/.

Source file: InstallableUnitTreeActions.java

  20 
vote

private void createActions(){
  collapseAll=new Action("Collapse All"){
    @Override public void run(){
      treeViewer.collapseAll();
    }
  }
;
  collapseAll.setImageDescriptor(ResourceManager.getPluginImageDescriptor("com.ifedorenko.p2browser","icons/collapseall.gif"));
  expandAll=new Action("Expand All"){
    @Override public void run(){
      treeViewer.getTree().setRedraw(false);
      treeViewer.expandAll();
      treeViewer.getTree().setRedraw(true);
    }
  }
;
  expandAll.setImageDescriptor(ResourceManager.getPluginImageDescriptor("com.ifedorenko.p2browser","icons/expandall.gif"));
}
 

Example 55

From project sveditor, under directory /sveditor/plugins/net.sf.sveditor.ui/src/net/sf/sveditor/ui/views/diagram/.

Source file: SVDiagramView.java

  20 
vote

private void createToolBarItems(Composite parent){
  IToolBarManager tbm=getViewSite().getActionBars().getToolBarManager();
  final Shell shell=parent.getShell();
  tbm.add(new Action("Export Image",Action.AS_PUSH_BUTTON){
{
      setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVEAS_EDIT));
    }
    public void run(){
      FileDialog fileDialog=new FileDialog(shell,SWT.SAVE);
      fileDialog.setText("Select File");
      fileDialog.setFilterExtensions(new String[]{"*.png"});
      fileDialog.setFilterNames(new String[]{"PNG files (*.png)"});
      String selected=fileDialog.open();
      if (selected != null) {
        ScalableFigure figure=fGraphViewer.getGraphControl().getRootLayer();
        Rectangle bounds=figure.getBounds();
        Control srcCanvas=fGraphViewer.getGraphControl();
        GC srcGC=new GC(srcCanvas);
        Image destImg=new Image(null,bounds.width,bounds.height);
        GC destImgGC=new GC(destImg);
        destImgGC.setBackground(srcGC.getBackground());
        destImgGC.setForeground(srcGC.getForeground());
        destImgGC.setFont(srcGC.getFont());
        destImgGC.setLineStyle(srcGC.getLineStyle());
        destImgGC.setLineWidth(srcGC.getLineWidth());
        Graphics dstImgGraphics=new SWTGraphics(destImgGC);
        figure.paint(dstImgGraphics);
        ImageLoader imgLoader=new ImageLoader();
        imgLoader.data=new ImageData[]{destImg.getImageData()};
        imgLoader.save(selected,SWT.IMAGE_PNG);
        destImg.dispose();
        destImgGC.dispose();
      }
    }
  }
);
}
 

Example 56

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/ui/.

Source file: DelegatesScriptView.java

  19 
vote

public void updateEnablement(){
  boolean enabled=getSelectedEObject() instanceof EClassifier;
  if (enabled != this.enabled) {
    this.enabled=enabled;
    firePropertyChange(Action.ENABLED,!enabled,enabled);
  }
}
 

Example 57

From project rascal-eclipse, under directory /src/org/rascalmpl/eclipse/terms/.

Source file: ActionContributor.java

  19 
vote

public Runner(boolean checked,boolean synchronous,String label,UniversalEditor editor,RascalAction job){
  super(label,Action.AS_CHECK_BOX);
  setChecked(checked);
  this.editor=editor;
  this.job=job;
  this.sync=synchronous;
}