List of usage examples for org.eclipse.jface.action IAction ENABLED
String ENABLED
To view the source code for org.eclipse.jface.action IAction ENABLED.
Click Source Link
"enabled"). From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.OutlinePage.java
License:Open Source License
/** * This viewer uses its own actions that delegate to the ones given * by the {@link LayoutCanvas}. All the processing is actually handled * directly by the canvas and this viewer only gets refreshed as a * consequence of the canvas changing the XML model. *//* w ww .j a v a2s . c o m*/ private void setupContextMenu() { mMenuManager = new MenuManager(); mMenuManager.removeAll(); mMenuManager.add(mMoveUpAction); mMenuManager.add(mMoveDownAction); mMenuManager.add(new Separator()); mMenuManager.add(new SelectionManager.SelectionMenu(mGraphicalEditorPart)); mMenuManager.add(new Separator()); final String prefix = LayoutCanvas.PREFIX_CANVAS_ACTION; mMenuManager.add(new DelegateAction(prefix + ActionFactory.CUT.getId())); mMenuManager.add(new DelegateAction(prefix + ActionFactory.COPY.getId())); mMenuManager.add(new DelegateAction(prefix + ActionFactory.PASTE.getId())); mMenuManager.add(new Separator()); mMenuManager.add(new DelegateAction(prefix + ActionFactory.DELETE.getId())); mMenuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { // Update all actions to match their LayoutCanvas counterparts for (IContributionItem contrib : manager.getItems()) { if (contrib instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) contrib).getAction(); if (action instanceof DelegateAction) { ((DelegateAction) action).updateFromEditorPart(mGraphicalEditorPart); } } } } }); new DynamicContextMenu(mGraphicalEditorPart.getEditorDelegate(), mGraphicalEditorPart.getCanvasControl(), mMenuManager); getTreeViewer().getTree().setMenu(mMenuManager.createContextMenu(getControl())); // Update Move Up/Move Down state only when the menu is opened getTreeViewer().getTree().addMenuDetectListener(new MenuDetectListener() { @Override public void menuDetected(MenuDetectEvent e) { mMenuManager.update(IAction.ENABLED); } }); }
From source file:com.github.haixing_hu.swt.action.ActionContributionItemEx.java
License:Open Source License
/** * Synchronizes the UI with the given property. * * @param propertyName/* w w w. ja va 2s .c o m*/ * the name of the property, or <code>null</code> meaning all * applicable properties */ @Override public void update(String propertyName) { if (widget != null) { // determine what to do final boolean textChanged = (propertyName == null) || propertyName.equals(IAction.TEXT); boolean imageChanged = (propertyName == null) || propertyName.equals(IAction.IMAGE); final boolean tooltipTextChanged = (propertyName == null) || propertyName.equals(IAction.TOOL_TIP_TEXT); final boolean enableStateChanged = (propertyName == null) || propertyName.equals(IAction.ENABLED) || propertyName.equals(IContributionManagerOverrides.P_ENABLED); final boolean checkChanged = ((action.getStyle() == IAction.AS_CHECK_BOX) || (action.getStyle() == IAction.AS_RADIO_BUTTON)) && ((propertyName == null) || propertyName.equals(IAction.CHECKED)); if (!showImage) { // do not update the image if not show image imageChanged = false; } if (widget instanceof ToolItem) { final ToolItem ti = (ToolItem) widget; String text = action.getText(); // the set text is shown only if there is no image or if forced // by MODE_FORCE_TEXT final boolean showText = (text != null) && (((getMode() & MODE_FORCE_TEXT) != 0) || !hasImages(action)); // only do the trimming if the text will be used if (showText && (text != null)) { text = Action.removeAcceleratorText(text); text = Action.removeMnemonics(text); } if (textChanged) { final String textToSet = showText ? text : ""; //$NON-NLS-1$ final boolean rightStyle = (ti.getParent().getStyle() & SWT.RIGHT) != 0; if (rightStyle || !ti.getText().equals(textToSet)) { // In addition to being required to update the text if // it // gets nulled out in the action, this is also a // workaround // for bug 50151: Using SWT.RIGHT on a ToolBar leaves // blank space ti.setText(textToSet); } } if (imageChanged) { // only substitute a missing image if it has no text updateImages(!showText); } if (tooltipTextChanged || textChanged) { String toolTip = action.getToolTipText(); if ((toolTip == null) || (toolTip.length() == 0)) { toolTip = text; } final ExternalActionManager.ICallback callback = ExternalActionManager.getInstance() .getCallback(); final String commandId = action.getActionDefinitionId(); if ((callback != null) && (commandId != null) && (toolTip != null)) { final String acceleratorText = callback.getAcceleratorText(commandId); if ((acceleratorText != null) && (acceleratorText.length() != 0)) { toolTip = JFaceResources.format("Toolbar_Tooltip_Accelerator", //$NON-NLS-1$ new Object[] { toolTip, acceleratorText }); } } // if the text is showing, then only set the tooltip if // different if (!showText || ((toolTip != null) && !toolTip.equals(text))) { ti.setToolTipText(toolTip); } else { ti.setToolTipText(null); } } if (enableStateChanged) { final boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (ti.getEnabled() != shouldBeEnabled) { ti.setEnabled(shouldBeEnabled); } } if (checkChanged) { final boolean bv = action.isChecked(); if (ti.getSelection() != bv) { ti.setSelection(bv); } } return; } if (widget instanceof MenuItem) { final MenuItem mi = (MenuItem) widget; if (textChanged) { int accelerator = 0; String acceleratorText = null; final ActionEx updatedAction = getAction(); String text = null; accelerator = updatedAction.getAccelerator(); final ExternalActionManager.ICallback callback = ExternalActionManager.getInstance() .getCallback(); // Block accelerators that are already in use. if ((accelerator != 0) && (callback != null) && (callback.isAcceleratorInUse(accelerator))) { accelerator = 0; } /* * Process accelerators on GTK in a special way to avoid Bug 42009. We * will override the native input method by allowing these reserved * accelerators to be placed on the menu. We will only do this for * "Ctrl+Shift+[0-9A-FU]". */ final String commandId = updatedAction.getActionDefinitionId(); if ((Util.isGtk()) && (callback instanceof IBindingManagerCallback) && (commandId != null)) { final IBindingManagerCallback bindingManagerCallback = (IBindingManagerCallback) callback; final IKeyLookup lookup = KeyLookupFactory.getDefault(); final TriggerSequence[] triggerSequences = bindingManagerCallback .getActiveBindingsFor(commandId); for (final TriggerSequence triggerSequence : triggerSequences) { final Trigger[] triggers = triggerSequence.getTriggers(); if (triggers.length == 1) { final Trigger trigger = triggers[0]; if (trigger instanceof KeyStroke) { final KeyStroke currentKeyStroke = (KeyStroke) trigger; final int currentNaturalKey = currentKeyStroke.getNaturalKey(); if ((currentKeyStroke .getModifierKeys() == (lookup.getCtrl() | lookup.getShift())) && (((currentNaturalKey >= '0') && (currentNaturalKey <= '9')) || ((currentNaturalKey >= 'A') && (currentNaturalKey <= 'F')) || (currentNaturalKey == 'U'))) { accelerator = currentKeyStroke.getModifierKeys() | currentNaturalKey; acceleratorText = triggerSequence.format(); break; } } } } } if (accelerator == 0) { if ((callback != null) && (commandId != null)) { acceleratorText = callback.getAcceleratorText(commandId); } } IContributionManagerOverrides overrides = null; if (getParent() != null) { overrides = getParent().getOverrides(); } if (overrides != null) { text = getParent().getOverrides().getText(this); } mi.setAccelerator(accelerator); if (text == null) { text = updatedAction.getText(); } if ((text != null) && (acceleratorText == null)) { // use extracted accelerator text in case accelerator // cannot be fully represented in one int (e.g. // multi-stroke keys) acceleratorText = LegacyActionTools.extractAcceleratorText(text); if ((acceleratorText == null) && (accelerator != 0)) { acceleratorText = Action.convertAccelerator(accelerator); } } if (text == null) { text = ""; //$NON-NLS-1$ } else { text = Action.removeAcceleratorText(text); } // add "..." if the action will show a dialog if (updatedAction.isShowDialog()) { text = text + dialogIndicator; } if (acceleratorText == null) { mi.setText(text); } else { mi.setText(text + '\t' + acceleratorText); } } if (imageChanged) { updateImages(false); } if (enableStateChanged) { final boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (mi.getEnabled() != shouldBeEnabled) { mi.setEnabled(shouldBeEnabled); } } if (checkChanged) { final boolean bv = action.isChecked(); if (mi.getSelection() != bv) { mi.setSelection(bv); } } return; } if (widget instanceof Button) { final Button button = (Button) widget; if (imageChanged) { updateImages(false); } if (textChanged) { String text = action.getText(); final boolean showText = (text != null) && (((getMode() & MODE_FORCE_TEXT) != 0) || !hasImages(action)); // only do the trimming if the text will be used if (showText) { text = Action.removeAcceleratorText(text); } final String textToSet = showText ? text : ""; //$NON-NLS-1$ button.setText(textToSet); } if (tooltipTextChanged) { button.setToolTipText(action.getToolTipText()); } if (enableStateChanged) { final boolean shouldBeEnabled = action.isEnabled() && isEnabledAllowed(); if (button.getEnabled() != shouldBeEnabled) { button.setEnabled(shouldBeEnabled); } } if (checkChanged) { final boolean bv = action.isChecked(); if (button.getSelection() != bv) { button.setSelection(bv); } } return; } } }
From source file:com.microsoft.tfs.client.common.ui.framework.action.ToolbarPulldownAction.java
License:Open Source License
private void subActionPropertyChange(final PropertyChangeEvent event) { if (IAction.ENABLED.equals(event.getProperty())) { recomputeEnablement();//from ww w . ja va2 s .c o m } }
From source file:com.nokia.tools.media.utils.tooltip.DynamicTooltip.java
License:Open Source License
protected void addContributedControls(final Composite composite, boolean focusState) { Composite toolBarComposite = null; Composite sectionsComposite = null; children.clear();/*from ww w .ja v a 2 s . c o m*/ if (style == EStyle.MENU) { GridLayout gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = gl.horizontalSpacing = 0; composite.setLayout(gl); toolBarComposite = new Composite(composite, SWT.NONE); gl = new GridLayout(1, false); // gl.marginHeight = gl.marginWidth = 0; toolBarComposite.setLayout(gl); toolBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); } // horizontal toolbar if (style == EStyle.HORIZONTAL_HORIZONTAL || style == EStyle.HORIZONTAL_VERTICAL) { GridLayout gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = gl.verticalSpacing = 0; composite.setLayout(gl); toolBarComposite = new Composite(composite, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; toolBarComposite.setLayout(gl); toolBarComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); } // vertical toolbar if (style == EStyle.VERTICAL_VERTICAL || style == EStyle.VERTICAL_HORIZONTAL) { GridLayout gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = gl.horizontalSpacing = 0; composite.setLayout(gl); toolBarComposite = new Composite(composite, SWT.NONE); gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; toolBarComposite.setLayout(gl); toolBarComposite.setLayoutData(new GridData(SWT.NONE, SWT.FILL, false, true)); } sectionsComposite = new Composite(composite, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginHeight = gl.marginWidth = 0; sectionsComposite.setLayout(gl); sectionsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); toolBarComposite.setBackground(composite.getBackground()); sectionsComposite.setBackground(composite.getBackground()); Set<ToolbarItemContribution> toolbarContributions = new TreeSet<ToolbarItemContribution>(); toolbarContributions.addAll(collectToolbarContributions(focusState)); List<SectionContribution> sectionContributions = collectSectionContributions(focusState); for (SectionContribution contribution : sectionContributions) { if (contribution.uiClass != null) { try { IDynamicTooltipUIContribution ui = contribution.uiClass.newInstance(); ui.setTooltip(this); ui.setUIContainer(uiContainer); ui.setSelection(selection); ui.setContext(context); configureUIContribution(ui); ToolbarItemContribution[] tcs = ui.contributeToolbar(); if (tcs != null) { for (ToolbarItemContribution tc : tcs) { toolbarContributions.add(tc); } } ui.createControls(sectionsComposite, focusState); } catch (Exception e) { e.printStackTrace(); } } } if (sectionsComposite.getChildren().length == 0) { sectionsComposite.dispose(); } if (toolbarContributions.size() > 0) { GridLayout layout = (GridLayout) toolBarComposite.getLayout(); layout.horizontalSpacing = 1; if (EStyle.HORIZONTAL_HORIZONTAL == style || EStyle.HORIZONTAL_VERTICAL == style || EStyle.VERTICAL_HORIZONTAL == style || EStyle.VERTICAL_VERTICAL == style) { CoolBar cb = null; if (EStyle.HORIZONTAL_HORIZONTAL == style || EStyle.HORIZONTAL_VERTICAL == style) { cb = new CoolBar(toolBarComposite, SWT.FLAT | SWT.HORIZONTAL); cb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); } else { cb = new CoolBar(toolBarComposite, SWT.FLAT | SWT.VERTICAL); cb.setLayoutData(new GridData(GridData.FILL_VERTICAL)); } Map<String, ToolBarManager> linkMap = new LinkedHashMap<String, ToolBarManager>(); final Map<ContributionItem, ToolbarItemContribution> map = new HashMap<ContributionItem, ToolbarItemContribution>(); for (final ToolbarItemContribution contribution : toolbarContributions) { ToolBarManager toolBar = linkMap.get(contribution.getTarget()); if (toolBar == null) { if (EStyle.HORIZONTAL_HORIZONTAL == style || EStyle.HORIZONTAL_VERTICAL == style) { toolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); } else { toolBar = new ToolBarManager(SWT.FLAT | SWT.VERTICAL); } linkMap.put(contribution.getTarget(), toolBar); } if (contribution.getAction() == null) { Action action = new Action(contribution.getLabel()) { @Override public void run() { // do nothing } }; action.setImageDescriptor(contribution.getIcon()); action.setDisabledImageDescriptor(contribution.getDisabledIcon()); action.setHoverImageDescriptor(contribution.getHoverIcon()); ActionContributionItem item = new ActionContributionItem(action); map.put(item, contribution); toolBar.add(item); } else { IAction action = contribution.getAction(); if (contribution.getAction() instanceof IDynamicTooltipToolbarAction) { ((IDynamicTooltipToolbarAction) action).setTooltip(DynamicTooltip.this); ((IDynamicTooltipToolbarAction) action).setUIContainer(uiContainer); ((IDynamicTooltipToolbarAction) action).setSelection(selection); } if (action instanceof SeparatorAction) { Separator separator = new Separator(); map.put(separator, contribution); toolBar.add(separator); } else { ActionContributionItem item = new ActionContributionItem(action); map.put(item, contribution); toolBar.add(item); } } } Point preffered = new Point(0, 0); for (Map.Entry<String, ToolBarManager> entry : linkMap.entrySet()) { CoolItem ci = new CoolItem(cb, SWT.NONE); ToolBar tb = entry.getValue().createControl(cb); ci.setControl(tb); Point tbSize = tb.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point cbSize = ci.computeSize(tbSize.x, tbSize.y); ci.setSize(cbSize); ci.setPreferredSize(cbSize); ci.setMinimumSize(tbSize); if (EStyle.HORIZONTAL_HORIZONTAL == style || EStyle.HORIZONTAL_VERTICAL == style) { preffered.x += cbSize.x; preffered.y = Math.max(preffered.y, cbSize.y); } else { preffered.x = Math.max(preffered.x, cbSize.x); preffered.y += cbSize.y; } for (int i = 0; i < tb.getItems().length; i++) { ToolItem item = tb.getItems()[i]; ContributionItem actionItem = (ContributionItem) item.getData(); if (actionItem instanceof ActionContributionItem) { createChildTooltip(map.get(actionItem), item); } } } cb.setLocked(false); cb.setLayoutData(new GridData(preffered.x, preffered.y)); } else if (EStyle.MENU == style) { for (final ToolbarItemContribution contribution : toolbarContributions) { Composite itemComposite = null; itemComposite = createMenuComposite(toolBarComposite); if (contribution.getAction() instanceof SeparatorAction) { itemComposite.setEnabled(false); final Canvas img = new Canvas(itemComposite, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); gd.heightHint = 5; gd.horizontalSpan = 3; img.setLayoutData(gd); img.setBackground(itemComposite.getBackground()); img.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { GC gc = e.gc; gc.setForeground(ColorConstants.black); e.gc.drawLine(0, 2, img.getSize().x - 1, 2); } }); continue; } final Canvas img = new Canvas(itemComposite, SWT.NONE); img.setBackground(itemComposite.getBackground()); final Label label = new Label(itemComposite, SWT.NONE); label.setBackground(itemComposite.getBackground()); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label.setText(contribution.getLabel() != null ? contribution.getLabel() : ""); label.setEnabled(!contribution.isDisabled()); final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (IAction.TEXT.equals(event.getProperty())) { label.setText(contribution.getLabel() != null ? contribution.getLabel() : ""); layout(); } if (IAction.ENABLED.equals(event.getProperty())) { label.setEnabled(!contribution.isDisabled()); } } }; contribution.addPropertyChangeListener(propertyChangeListener); label.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { contribution.removePropertyChangeListener(propertyChangeListener); } }); if (contribution.tooltip != null) { final Canvas arrow = new Canvas(itemComposite, SWT.NONE); arrow.setBackground(itemComposite.getBackground()); arrow.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); final Image image = ARROW_IMAGE.createImage(); arrow.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { image.dispose(); } }); ((GridData) arrow.getLayoutData()).widthHint = image.getImageData().width; ((GridData) arrow.getLayoutData()).heightHint = image.getImageData().height; arrow.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.drawImage(image, 0, 0); } }); } img.setToolTipText(contribution.getLabel()); final IPropertyChangeListener labelChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (IAction.TEXT.equals(event.getProperty())) { img.setToolTipText(contribution.getLabel()); } } }; contribution.addPropertyChangeListener(labelChangeListener); img.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { contribution.removePropertyChangeListener(labelChangeListener); } }); final Image[] image = new Image[] { contribution.isDisabled() ? contribution.getDisabledIcon().createImage() : contribution.getIcon().createImage() }; final Image[] hoverImage = new Image[] { (contribution.isDisabled() || contribution.getHoverIcon() == null) ? image[0] : contribution.getHoverIcon().createImage() }; final IPropertyChangeListener imageChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (IAction.IMAGE.equals(event.getProperty()) || IAction.ENABLED.equals(event.getProperty())) { if (image[0] != null) { image[0].dispose(); } if (hoverImage[0] != null) { hoverImage[0].dispose(); } image[0] = contribution.isDisabled() ? contribution.getDisabledIcon().createImage() : contribution.getIcon().createImage(); hoverImage[0] = (contribution.isDisabled() || contribution.getHoverIcon() == null) ? image[0] : contribution.getHoverIcon().createImage(); img.redraw(); } } }; contribution.addPropertyChangeListener(imageChangeListener); img.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { contribution.removePropertyChangeListener(imageChangeListener); if (image[0] != null) { image[0].dispose(); } if (hoverImage[0] != null) { hoverImage[0].dispose(); } } }); img.setLayoutData( new GridData(image[0].getImageData().width + 4, image[0].getImageData().height + 4)); img.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.drawImage(image[0], 2, 2); } }); if (EStyle.MENU == style) { DynamicTooltip tooltip = createChildTooltip(contribution, itemComposite); registerOnClickAction(contribution, itemComposite, tooltip); for (Control control : itemComposite.getChildren()) { registerOnClickAction(contribution, control, tooltip); } } } } } // set proper number of columns for horizontal sections alignment if ((style == EStyle.HORIZONTAL_HORIZONTAL || style == EStyle.VERTICAL_HORIZONTAL) && !sectionsComposite.isDisposed()) { ((GridLayout) sectionsComposite.getLayout()).numColumns = sectionsComposite.getChildren().length; } if (toolBarComposite.getChildren().length == 0) { toolBarComposite.dispose(); } if (sectionsComposite.isDisposed() && toolBarComposite.isDisposed()) { composite.dispose(); } }
From source file:com.onpositive.mapper.actions.LayerViewAction.java
License:Open Source License
public LayerViewAction(final AbstractLayerAction layerAction, ISelectionProvider provider, MapEditor editor, String name, String description) { super(provider, name); this.layerAction = layerAction; layerAction.addPropertyChangeListener(new IPropertyChangeListener() { @Override// w w w. ja va2 s.c o m public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IAction.ENABLED)) setEnabled(layerAction.isEnabled()); } }); setDescription(description); layerAction.setDescription(description); layerAction.setText(name); layerAction.setActiveEditor(layerAction, editor); if (provider instanceof ColumnViewer) { layerAction.setLayerViewer((ColumnViewer) provider); } setEnabled(layerAction.calcEnabled()); }
From source file:net.refractions.udig.project.ui.internal.tool.display.ToolManager.java
License:Open Source License
/** * Creates a action that acts as a proxy for the tool in the editor toolbar. * <p>//from www . j av a 2 s. c o m * The client code must set the name image descriptor etc... of the Action * </p> * * @param toolID the id of the tool * @param categoryID the category the tool is part of * @return a proxy action that can be put in other toolbars */ public IAction createToolAction(final String toolID, final String categoryID) { final IAction toolAction = new Action() { @Override public void runWithEvent(Event event) { IAction action = getTool(toolID, categoryID); if (action != null && action.isEnabled()) { action.runWithEvent(event); } } }; toolAction.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IAction.ENABLED)) { toolAction.setEnabled((Boolean) event.getNewValue()); } } }); toolAction.setEnabled(getTool(toolID, categoryID).isEnabled()); addToolAction(toolAction); return toolAction; }
From source file:net.refractions.udig.style.sld.editor.internal.PageHistoryHolder.java
License:Open Source License
/** * Updates the history controls./* ww w . j av a 2s.com*/ * */ private void updateHistoryControls() { historyToolbar.update(false); IContributionItem[] items = historyToolbar.getItems(); for (int i = 0; i < items.length; i++) { items[i].update(IAction.ENABLED); items[i].update(IAction.TOOL_TIP_TEXT); } }
From source file:org.eclipse.birt.core.ui.frameworks.taskwizard.internal.SubtaskHistory.java
License:Open Source License
/** * Updates the history controls./*from www . ja v a 2 s . com*/ * */ private void updateHistoryControls() { if (historyToolbar != null) { historyToolbar.update(false); IContributionItem[] items = historyToolbar.getItems(); for (int i = 0; i < items.length; i++) { items[i].update(IAction.ENABLED); items[i].update(IAction.TOOL_TIP_TEXT); } } }
From source file:org.eclipse.birt.report.designer.data.ui.dataset.HistoryToolBar.java
License:Open Source License
/** * update history control//from w ww.j a v a2 s . c o m * */ private void updateHistoryControls() { toolbarManager.update(false); IContributionItem[] items = toolbarManager.getItems(); for (int i = 0; i < items.length; i++) { items[i].update(IAction.ENABLED); items[i].update(IAction.TOOL_TIP_TEXT); } }
From source file:org.eclipse.egit.ui.internal.dialogs.AbstractConfigureRemoteDialog.java
License:Open Source License
private Button createActionButton(Composite parent, int style, IAction action) { Button button = new Button(parent, style); button.setText(action.getText());//w w w . ja v a 2 s. c o m button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { action.run(); } }); IPropertyChangeListener listener = event -> { if (IAction.ENABLED.equals(event.getProperty())) { if (!button.isDisposed()) { if (Display.getCurrent() == null) { button.getShell().getDisplay().syncExec(() -> { if (!button.isDisposed()) { button.setEnabled(action.isEnabled()); } }); } else { button.setEnabled(action.isEnabled()); } } } }; button.addDisposeListener(event -> action.removePropertyChangeListener(listener)); action.addPropertyChangeListener(listener); GridDataFactory.fillDefaults().applyTo(button); return button; }