Example usage for org.eclipse.jface.action Action getText

List of usage examples for org.eclipse.jface.action Action getText

Introduction

In this page you can find the example usage for org.eclipse.jface.action Action getText.

Prototype

@Override
    public String getText() 

Source Link

Usage

From source file:com.generalrobotix.ui.GrxPluginManager.java

License:Open Source License

/**
 * @brief/*w  ww.  ja  v a  2s. c o  m*/
 */
private void dynamicChangeMenu(final Class<? extends GrxBaseItem> cls, Vector<Action> menu) {
    try {
        Method m = cls.getMethod("paste", String.class); //$NON-NLS-1$
        Class<?> c = m.getDeclaringClass();
        if (c != GrxBaseItem.class) {
            for (Action action : menu) {
                if (action.getText().equals("paste")) { //$NON-NLS-1$
                    action.setEnabled(!isEmptyClipBord());
                    break;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.google.dart.tools.ui.dialogs.UpdateStatusControl.java

License:Open Source License

private void setAction(Action action, boolean enabled) {
    this.updateAction = action;
    updateStatusButton.setText(action.getText());
    updateStatusButton.setEnabled(enabled);
    updateStatusButton.getParent().layout();
}

From source file:com.google.eclipse.javascript.core.ServerStartStopViewActionDelegateTest.java

License:Apache License

public void testClickingOnActionTogglesIconAndTextBetweenStartStop() {
    Icons icons = new Icons() {

        @Override/*from w w  w  . j  av  a 2  s . c  om*/
        public ImageDescriptor startServerIcon() {
            startServerIconCalled = true;
            stopServerIconCalled = false;
            return null;
        }

        @Override
        public ImageDescriptor stopServerIcon() {
            startServerIconCalled = false;
            stopServerIconCalled = true;
            return null;
        }
    };

    ServerController serverController = new ServerController(new JstdServerListener(),
            new com.google.eclipse.javascript.jstestdriver.core.PortSupplier() {

                @Override
                public int getPort() {
                    return 42242;
                }
            });
    ServerStartStopViewActionDelegate delegate = new ServerStartStopViewActionDelegate(icons, serverController);
    Action action = new Action() {
    };

    delegate.run(action);

    assertEquals("Stop Server", action.getText());
    assertFalse("Start icon not called", startServerIconCalled);
    assertTrue("Stop icon called", stopServerIconCalled);

    delegate.run(action);

    assertTrue("Start icon called", startServerIconCalled);
    assertFalse("Stop icon not called", stopServerIconCalled);
    assertEquals("Start Server", action.getText());
}

From source file:com.google.eclipse.javascript.jstestdriver.ui.view.actions.ServerStartStopViewActionDelegateTest.java

License:Apache License

public void testClickingOnActionToglesIconAndTextBetweenStartStop() {
    Server server = Server.getInstance(4224);
    ServerStartStopViewActionDelegate delegate = new ServerStartStopViewActionDelegate(server, new Icons() {

        @Override//from   w w  w.  j ava2s.co  m
        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);
}

From source file:com.gorillalogic.monkeyconsole.actions.DropDownMenuAction.java

License:Open Source License

public void setSelectedAction(Action selectedAction) {
    this.selectedAction = selectedAction;
    this.setToolTipText(selectedAction.getToolTipText());
    this.setImageDescriptor(selectedAction.getImageDescriptor());
    this.setText(selectedAction.getText());

}

From source file:com.netifera.platform.host.terminal.ui.actions.SelectTerminalAction.java

License:Open Source License

private void addActionToMenu(Menu parent, Action action, int accelerator) {
    if (accelerator < 10) {
        StringBuffer label = new StringBuffer();
        //add the numerical accelerator
        label.append('&');
        label.append(accelerator);/*from  ww  w .  java2 s . co  m*/
        label.append(' ');
        label.append(action.getText());
        action.setText(label.toString());
    }
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(parent, -1);
}

From source file:fr.inria.linuxtools.tmf.ui.views.uml2sd.SDView.java

License:Open Source License

/**
 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
 *
 * @see ISDGraphNodeSupporter Action support definition
 * @see SDView#setSDFilterProvider(ISDFilterProvider)
 * @see SDView#setSDFindProvider(ISDFindProvider)
 * @see SDView#setSDPagingProvider(ISDPagingProvider)
 *///from   w  w  w .ja v  a 2s . co  m
protected void createCoolbarContent() {
    IActionBars bar = getViewSite().getActionBars();

    bar.getMenuManager().removeAll();
    bar.getToolBarManager().removeAll();

    createMenuGroup();

    Zoom resetZoom = new Zoom(this, ZoomType.ZOOM_RESET);
    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom);
    bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom);

    Zoom noZoom = new Zoom(this, ZoomType.ZOOM_NONE);
    noZoom.setChecked(true);
    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom);
    bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom);

    Zoom zoomIn = new Zoom(this, ZoomType.ZOOM_IN);
    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn);
    bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn);

    Zoom zoomOut = new Zoom(this, ZoomType.ZOOM_OUT);
    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut);
    bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut);

    MenuManager navigation = new MenuManager(Messages.SequenceDiagram_Navigation);

    ShowNodeStart showNodeStart = new ShowNodeStart(this);
    showNodeStart.setText(Messages.SequenceDiagram_ShowNodeStart);

    showNodeStart.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
    showNodeStart.setActionDefinitionId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
    navigation.add(showNodeStart);

    ShowNodeEnd showNodeEnd = new ShowNodeEnd(this);
    showNodeEnd.setText(Messages.SequenceDiagram_ShowNodeEnd);

    showNodeEnd.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
    showNodeEnd.setActionDefinitionId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
    navigation.add(showNodeEnd);

    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, navigation);

    ConfigureMinMax minMax = new ConfigureMinMax(this);
    minMax.setText(Messages.SequenceDiagram_ConfigureMinMax);
    minMax.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
    bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, minMax);

    if ((fSdWidget.getFrame() != null) && (fSdWidget.getFrame().hasTimeInfo())) {
        minMax.setEnabled(true);
    } else {
        minMax.setEnabled(false);
    }

    // Do we need to display a paging item
    if (fSdPagingProvider != null) {
        fNextPageButton = new NextPage(this);
        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton);
        fNextPageButton.setEnabled(fSdPagingProvider.hasNextPage());
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton);

        fPrevPageButton = new PrevPage(this);
        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton);
        fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton);

        fFirstPageButton = new FirstPage(this);
        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton);
        fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton);

        fLastPageButton = new LastPage(this);
        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton);
        fLastPageButton.setEnabled(fSdPagingProvider.hasNextPage());
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton);
    }

    if (fSdExFilterProvider != null) {
        Action action = fSdExFilterProvider.getFilterAction();
        if (action != null) {
            if (action.getId() == null) {
                action.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
            }
            if (action.getImageDescriptor() == null) {
                action.setImageDescriptor(
                        Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS));
            }
            if (action.getText() == null || action.getText().length() == 0) {
                action.setText(Messages.SequenceDiagram_EditFilters);
            }
            bar.getMenuManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action);
            bar.getToolBarManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action);
        }
    }
    // Both systems can be used now: commenting out else keyword
    if (fSdFilterProvider != null) {
        bar.getMenuManager().appendToGroup(UML2SD_FILTERING_SEPARATOR,
                new OpenSDFiltersDialog(this, fSdFilterProvider));
    }
    if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
        IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID);
        if (sdPaging != null) {
            bar.getMenuManager().remove(sdPaging);
            sdPaging = null;
        }
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR,
                new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider));
        updatePagesMenuItem(bar);
    }

    if (fSdExFindProvider != null) {
        Action action = fSdExFindProvider.getFindAction();
        if (action != null) {
            if (action.getId() == null) {
                action.setId("fr.inria.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
            }
            if (action.getImageDescriptor() == null) {
                action.setImageDescriptor(Activator.getDefault()
                        .getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
            }
            if (action.getText() == null) {
                action.setText(Messages.SequenceDiagram_Find + "..."); //$NON-NLS-1$
            }
            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action);
            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action);
        }
    } else if (fSdFindProvider != null) {
        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this));
        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this));
    }

    if (fSdExtendedActionBarProvider != null) {
        fSdExtendedActionBarProvider.supplementCoolbarContent(bar);
    }

    bar.updateActionBars();
}

From source file:org.caleydo.view.table.action.TableSettingsAction.java

License:Open Source License

private void addActionToMenu(Menu parent, Action action, int accelerator) {
    if (accelerator < 10) {
        StringBuilder label = new StringBuilder();
        //add the numerical accelerator
        label.append('&');
        label.append(accelerator);/*from  www. ja va  2  s . co  m*/
        label.append(' ');
        label.append(action.getText());
        action.setText(label.toString());
    }
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(parent, -1);
}

From source file:org.csstudio.swt.chart.test.ToolBarActionHook.java

License:Open Source License

public ToolBarActionHook(final InteractiveChart chart, final Action action) {
    Button b = new Button(chart.getButtonBar(), SWT.PUSH);
    b.setText(action.getText());
    b.setToolTipText(action.getToolTipText());
    b.addSelectionListener(new SelectionAdapter() {
        @Override//  w w w. ja  v  a2 s .c  o  m
        public void widgetSelected(SelectionEvent e) {
            action.run();
        }
    });
}

From source file:org.dawnsci.common.widgets.radio.RadioGroupWidget.java

License:Open Source License

/**
 * Creates a list of Actions as Menu items or Buttons given the parent Widget<br>
 * The radio item text is coming from the text defined for each action
 * @param actions//from  w  ww  .  j  av a2s.  c  o  m
 */
public void setActions(List<Action> actions, boolean repectCurrentSelections) {
    if (actions == null)
        return;
    if (parent instanceof Composite) {
        int i = 0;
        Composite comp = (Composite) parent;
        for (final Action action : actions) {
            final Button radioButton = new Button(comp, SWT.RADIO);
            radioButton.setText(action.getText());
            if (action.getToolTipText() != null)
                radioButton.setToolTipText(action.getToolTipText());
            radioButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (((Button) e.getSource()).getSelection())
                        action.run();
                }
            });
            if ((!repectCurrentSelections && i == 0) || action.isChecked())
                radioButton.setSelection(true);
            radiosList.add(radioButton);
            i++;
        }
    } else if (parent instanceof Menu) {
        int i = 0;
        Menu menu = (Menu) parent;
        for (final Action action : actions) {
            final MenuItem radioButton = new MenuItem(menu, SWT.RADIO);
            radioButton.setText(action.getText());
            radioButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (((MenuItem) e.getSource()).getSelection())
                        action.run();
                }
            });
            if ((!repectCurrentSelections && i == 0) || action.isChecked())
                radioButton.setSelection(true);
            radiosList.add(radioButton);
            i++;
        }
    } else {
        logger.error("The parent widget provided:" + parent.getClass() + " is not supported");
    }

}