List of usage examples for org.eclipse.jface.action Action getToolTipText
@Override
public String getToolTipText()
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:fr.opensagres.mongodb.ide.ui.actions.ActionMenu.java
License:Open Source License
public ActionMenu(List<Action> actions) { this.actions = actions; if (this.actions.size() > 0) { Action firstAction = this.actions.get(0); setToolTipText(firstAction.getToolTipText()); setImageDescriptor(firstAction.getImageDescriptor()); if (this.actions.size() > 1) setMenuCreator(this); }// ww w. j a v a 2 s .com }
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());/* www. j ava2 s. co m*/ b.setToolTipText(action.getToolTipText()); b.addSelectionListener(new SelectionAdapter() { @Override 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 a v a2 s.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"); } }
From source file:org.dawnsci.plotting.tools.masking.MaskingTool.java
License:Open Source License
/** * Actions for /*from w w w.j a v a 2s . co m*/ * @param freeToolbar2 */ private void createDirectToolbarActions(ToolBarManager man) { final MenuAction penSize = new MenuAction("Pen Size"); penSize.setToolTipText("Pen size"); man.add(penSize); CheckableActionGroup group = new CheckableActionGroup(); final int[] pensizes = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 32, 64 }; Action currentSize = null; for (final int pensize : pensizes) { final Action action = new Action("Pen size of " + String.valueOf(pensize), IAction.AS_CHECK_BOX) { public void run() { Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_SIZE, pensize); penSize.setSelectedAction(this); penSize.setToolTipText(getToolTipText()); ShapeType penShape = ShapeType.valueOf( Activator.getPlottingPreferenceStore().getString(PlottingConstants.MASK_PEN_SHAPE)); if (penShape != null) { viewer.setSelectedCursor(CursorUtils.getPenCursor(pensize, penShape)); } } }; action.setImageDescriptor(IconUtils.createPenDescriptor(pensize)); penSize.add(action); group.add(action); if (Activator.getPlottingPreferenceStore().getInt(PlottingConstants.MASK_PEN_SIZE) == pensize) { currentSize = action; } action.setToolTipText("Set pen size to " + pensize); } if (currentSize != null) { currentSize.setChecked(true); penSize.setSelectedAction(currentSize); penSize.setToolTipText(currentSize.getToolTipText()); } man.add(new Separator()); group = new CheckableActionGroup(); Action action = new Action("Square brush", IAction.AS_CHECK_BOX) { public void run() { int pensize = Activator.getPlottingPreferenceStore().getInt(PlottingConstants.MASK_PEN_SIZE); ShapeType penShape = ShapeType.SQUARE; viewer.setSelectedCursor(CursorUtils.getPenCursor(pensize, penShape)); Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_SHAPE, penShape.name()); } }; action.setId(ShapeType.SQUARE.getId()); group.add(action); man.add(action); action = new Action("Triangle brush", IAction.AS_CHECK_BOX) { public void run() { int pensize = Activator.getPlottingPreferenceStore().getInt(PlottingConstants.MASK_PEN_SIZE); ShapeType penShape = ShapeType.TRIANGLE; viewer.setSelectedCursor(CursorUtils.getPenCursor(pensize, penShape)); Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_SHAPE, penShape.name()); } }; action.setId(ShapeType.TRIANGLE.getId()); group.add(action); man.add(action); action = new Action("Circular brush", IAction.AS_CHECK_BOX) { public void run() { int pensize = Activator.getPlottingPreferenceStore().getInt(PlottingConstants.MASK_PEN_SIZE); ShapeType penShape = ShapeType.CIRCLE; viewer.setSelectedCursor(CursorUtils.getPenCursor(pensize, penShape)); Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_SHAPE, penShape.name()); } }; action.setId(ShapeType.CIRCLE.getId()); group.add(action); man.add(action); action = new Action("None", IAction.AS_CHECK_BOX) { public void run() { ShapeType penShape = ShapeType.NONE; Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_SHAPE, penShape.name()); if (viewer != null) viewer.setSelectedCursor(null); } }; action.setId(ShapeType.NONE.getId()); action.setImageDescriptor(Activator.getImageDescriptor("icons/MouseArrow.png")); group.add(action); man.add(action); man.add(new Separator()); group = new CheckableActionGroup(); final Action mask = new Action("Mask", IAction.AS_CHECK_BOX) { public void run() { Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_MASKOUT, true); updateIcons(getImageTrace().getNanBound().getColor()); } }; mask.setImageDescriptor(Activator.getImageDescriptor("icons/mask-add.png")); group.add(mask); man.add(mask); final Action unmask = new Action("Unmask", IAction.AS_CHECK_BOX) { public void run() { Activator.getPlottingPreferenceStore().setValue(PlottingConstants.MASK_PEN_MASKOUT, false); updateIcons(null); } }; unmask.setImageDescriptor(Activator.getImageDescriptor("icons/mask-remove.png")); group.add(unmask); man.add(unmask); man.add(new Separator()); boolean maskout = Activator.getPlottingPreferenceStore().getBoolean(PlottingConstants.MASK_PEN_MASKOUT); if (maskout) { if (getImageTrace() != null) { updateIcons(getImageTrace().getNanBound().getColor()); } else { updateIcons(new int[] { 0, 255, 0 }); } mask.setChecked(true); } else { updateIcons(null); unmask.setChecked(true); } Display.getDefault().asyncExec(new Runnable() { public void run() { String savedShape = Activator.getPlottingPreferenceStore() .getString(PlottingConstants.MASK_PEN_SHAPE); if (savedShape != null && !"".equals(savedShape)) { ShapeType type = ShapeType.valueOf(savedShape); ((ActionContributionItem) directToolbar.find(type.getId())).getAction().setChecked(true); } } }); }
From source file:org.eclipse.emf.ecp.edit.internal.swt.util.SWTControl.java
License:Open Source License
/** * A helper method which creates a button for an action on a composite. * * @param action the action to create a button for * @param composite the composite to create the button onto * @return the created button//from ww w . ja v a 2s.c om */ protected Button createButtonForAction(final Action action, final Composite composite) { final Button selectButton = new Button(composite, SWT.PUSH); selectButton.setImage(Activator.getImage(action)); selectButton.setEnabled(!getControl().isReadonly()); selectButton.setToolTipText(action.getToolTipText()); selectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { action.run(); composite.layout(); } }); return selectButton; }
From source file:org.eclipse.emf.ecp.editor.mecontrols.melinkcontrol.MESingleLinkControl.java
License:Open Source License
/** * Creates a button for an action.//from w ww .j a v a 2 s . c o m * * @param action the action */ protected void createButtonForAction(final Action action) { Button selectButton = getToolkit().createButton(composite, "", SWT.PUSH); selectButton.setImage(action.getImageDescriptor().createImage()); selectButton.setToolTipText(action.getToolTipText()); selectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { action.run(); } }); }
From source file:org.eclipse.emf.ecp.view.internal.editor.controls.DomainModelReferenceControlSWTRenderer.java
License:Open Source License
/** * A helper method which creates a button for an action on a composite. * * @param action the action to create a button for * @param composite the composite to create the button onto * @return the created button/*w w w. ja v a 2s. com*/ */ protected Button createButtonForAction(final Action action, final Composite composite) { final Button selectButton = new Button(composite, SWT.PUSH); selectButton.setImage(Activator.getImage(action)); selectButton.setEnabled(true); selectButton.setToolTipText(action.getToolTipText()); return selectButton; }
From source file:org.eclipse.emf.ecp.view.internal.editor.controls.TableDetailViewControlSWTRenderer.java
License:Open Source License
private Button createButtonForAction(final Action action, final Composite composite) { final Button selectButton = new Button(composite, SWT.PUSH); selectButton.setImage(Activator.getImage(action)); selectButton.setEnabled(true);/* w w w . ja v a 2s . co m*/ selectButton.setToolTipText(action.getToolTipText()); return selectButton; }
From source file:org.eclipse.osee.ats.util.AtsUtil.java
License:Open Source License
public static ToolItem actionToToolItem(ToolBar toolBar, Action action, KeyedImage imageEnum) { final Action fAction = action; ToolItem item = new ToolItem(toolBar, SWT.PUSH); item.setImage(ImageManager.getImage(imageEnum)); item.setToolTipText(action.getToolTipText()); item.addSelectionListener(new SelectionAdapter() { @Override/*from w w w . j a va 2 s . c o m*/ public void widgetSelected(SelectionEvent e) { fAction.run(); } }); return item; }