List of usage examples for org.eclipse.jface.action IAction getDescription
String getDescription();
From source file:com.nokia.tools.s60.ide.actions.menu.GeneralRetargetAction.java
License:Open Source License
public GeneralRetargetAction(IAction template) { this(template.getId(), template.getText(), template.getToolTipText(), template.getStyle()); setImageDescriptor(template.getImageDescriptor()); setDisabledImageDescriptor(template.getDisabledImageDescriptor()); setDescription(template.getDescription()); }
From source file:de.fhg.igd.swingrcp.SwingAction.java
License:Open Source License
/** * Creates a Swing action from a JFace action * //w w w. j a v a2 s.c om * @param action the JFace action */ public SwingAction(IAction action) { super(); this.action = action; putValue(Action.NAME, action.getText()); putValue(Action.SHORT_DESCRIPTION, action.getToolTipText()); putValue(Action.LONG_DESCRIPTION, action.getDescription()); ImageDescriptor imageDesc = action.getImageDescriptor(); if (imageDesc != null) { ImageData imageData = imageDesc.getImageData(100); if (imageData != null) { BufferedImage img = SwingRCPUtilities.convertToAWT(imageData, true); ImageIcon icon = new ImageIcon(img); putValue(Action.SMALL_ICON, icon); } } }
From source file:org.drools.eclipse.flow.common.editor.DropDownMenuWithDefaultAction.java
License:Apache License
public void setAction(final IAction action) { if (this.enabledListener == null) { this.enabledListener = new EnabledPropertyChangeListener(this); }//from w w w.j av a 2 s .c o m setText(action.getText()); setToolTipText(action.getToolTipText()); setImageDescriptor(action.getImageDescriptor()); setDisabledImageDescriptor(action.getDisabledImageDescriptor()); setEnabled(action.isEnabled()); setDescription(action.getDescription()); setHelpListener(action.getHelpListener()); setHoverImageDescriptor(action.getHoverImageDescriptor()); if (this.delegate != null) { this.delegate.removePropertyChangeListener(this.enabledListener); } this.delegate = action; this.delegate.addPropertyChangeListener(this.enabledListener); }
From source file:org.eclipse.ui.internal.dialogs.cpd.NameAndDescriptionToolTip.java
License:Open Source License
static String getDescription(IContributionItem item) { if (item instanceof ActionContributionItem) { ActionContributionItem aci = (ActionContributionItem) item; IAction action = aci.getAction(); if (action == null) { return null; }//from ww w. jav a 2 s . c o m return action.getDescription(); } if (item instanceof ActionSetContributionItem) { ActionSetContributionItem asci = (ActionSetContributionItem) item; IContributionItem subitem = asci.getInnerItem(); return getDescription(subitem); } return null; }
From source file:org.eclipse.ui.internal.dialogs.CustomizePerspectiveDialog.java
License:Open Source License
private static String getDescription(IContributionItem item) { if (item instanceof ActionContributionItem) { ActionContributionItem aci = (ActionContributionItem) item; IAction action = aci.getAction(); if (action == null) return null; return action.getDescription(); }/* w w w . j a va 2 s . c o m*/ if (item instanceof ActionSetContributionItem) { ActionSetContributionItem asci = (ActionSetContributionItem) item; IContributionItem subitem = asci.getInnerItem(); return getDescription(subitem); } return null; }
From source file:org.eclipse.wst.sse.ui.StructuredTextEditor.java
License:Open Source License
private void updateMenuText() { ITextViewer viewer = getTextViewer(); StyledText widget = null;/* ww w. ja v a2s . c o m*/ if (viewer != null) widget = viewer.getTextWidget(); if (fStructuredModel != null && !fStructuredModel.isModelStateChanging() && viewer != null && widget != null && !widget.isDisposed()) { // performance: don't force an update of the action bars unless // required as it is expensive String previousUndoText = null; String previousUndoDesc = null; String previousRedoText = null; String previousRedoDesc = null; boolean updateActions = false; IAction undoAction = getAction(ITextEditorActionConstants.UNDO); IAction redoAction = getAction(ITextEditorActionConstants.REDO); if (undoAction != null) { previousUndoText = undoAction.getText(); previousUndoDesc = undoAction.getDescription(); updateActions = updateActions || previousUndoText == null || previousUndoDesc == null; undoAction.setText(UNDO_ACTION_TEXT_DEFAULT); undoAction.setDescription(UNDO_ACTION_DESC_DEFAULT); } if (redoAction != null) { previousRedoText = redoAction.getText(); previousRedoDesc = redoAction.getDescription(); updateActions = updateActions || previousRedoText == null || previousRedoDesc == null; redoAction.setText(REDO_ACTION_TEXT_DEFAULT); redoAction.setDescription(REDO_ACTION_DESC_DEFAULT); } if (fStructuredModel.getUndoManager() != null) { IStructuredTextUndoManager undoManager = fStructuredModel.getUndoManager(); // get undo command Command undoCommand = undoManager.getUndoCommand(); // set undo label and description if (undoAction != null) { undoAction.setEnabled(undoManager.undoable()); if (undoCommand != null) { String label = undoCommand.getLabel(); if (label != null) { String customText = MessageFormat.format(UNDO_ACTION_TEXT, new String[] { label }); updateActions = updateActions || customText == null || previousUndoText == null || !customText.equals(previousUndoText); undoAction.setText(customText); } String desc = undoCommand.getDescription(); if (desc != null) { String customDesc = MessageFormat.format(UNDO_ACTION_DESC, new String[] { desc }); updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousUndoDesc); undoAction.setDescription(customDesc); } } } // get redo command Command redoCommand = undoManager.getRedoCommand(); // set redo label and description if (redoAction != null) { redoAction.setEnabled(undoManager.redoable()); if (redoCommand != null) { String label = redoCommand.getLabel(); if (label != null) { String customText = MessageFormat.format(REDO_ACTION_TEXT, new String[] { label }); updateActions = updateActions || customText == null || previousRedoText == null || !customText.equals(previousRedoText); redoAction.setText(customText); } String desc = redoCommand.getDescription(); if (desc != null) { String customDesc = MessageFormat.format(REDO_ACTION_DESC, new String[] { desc }); updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousRedoDesc); redoAction.setDescription(customDesc); } } } } // tell the action bars to update if (updateActions) { if (getEditorSite().getActionBars() != null) { getEditorSite().getActionBars().updateActionBars(); } else if (getEditorPart() != null && getEditorPart().getEditorSite().getActionBars() != null) { getEditorPart().getEditorSite().getActionBars().updateActionBars(); } } } }
From source file:org.gluster.storage.management.console.actions.AbstractActionDelegate.java
License:Open Source License
@Override public void run(final IAction action) { try {/* w w w . j a v a2s. c o m*/ performAction(action); } catch (final Exception e) { final String actionDesc = action.getDescription(); logger.error("Exception while running action [" + actionDesc + "]", e); showErrorDialog(actionDesc, e.getMessage()); } }
From source file:org.gluster.storage.management.console.actions.AbstractMonitoredActionDelegate.java
License:Open Source License
@Override protected void performAction(final IAction action) { try {// w w w .j ava 2s . c om new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { performAction(action, monitor); } }); } catch (Exception e) { String errMsg = "Exception while performing action [" + action.getDescription() + "] : [" + e.getMessage() + "]"; logger.error(errMsg, e); showErrorDialog(ConsoleConstants.CONSOLE_TITLE, errMsg); } }
From source file:org.gluster.storage.management.console.actions.AddServerAction.java
License:Open Source License
@Override protected void performAction(final IAction action, IProgressMonitor monitor) { GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance(); GlusterServersClient glusterServersClient = new GlusterServersClient(); Set<Server> selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), Server.class); Set<Server> successServers = new HashSet<Server>(); Set<Server> partSuccessServers = new HashSet<Server>(); String errMsg = ""; String partErrMsg = ""; if (selectedServers.isEmpty()) { monitor.beginTask("Starting Manual Server Addition", 1); addServerManually();// www.j a v a 2 s.co m monitor.worked(1); monitor.done(); return; } monitor.beginTask("Adding Selected Servers...", selectedServers.size()); for (Server server : selectedServers) { if (monitor.isCanceled()) { break; } monitor.setTaskName("Adding server [" + server.getName() + "]..."); try { URI newServerURI = glusterServersClient.addServer(server.getName()); modelManager.addGlusterServer(glusterServersClient.getGlusterServer(newServerURI)); successServers.add(server); } catch (Exception e) { if (!errMsg.isEmpty()) { errMsg += CoreConstants.NEWLINE; } errMsg += "Server " + server.getName() + ". Error: [" + e.getMessage() + "]"; } monitor.worked(1); } monitor.done(); showStatusMessage(action.getDescription(), selectedServers, successServers, partSuccessServers, errMsg, partErrMsg); }
From source file:org.gluster.storage.management.console.actions.ClearTaskAction.java
License:Open Source License
@Override protected void performAction(final IAction action) { final String actionDesc = action.getDescription(); try {//from www. j a v a 2s .c o m new TasksClient().deleteTask(taskInfo.getName()); // taskId modelManager.removeTask(taskInfo); action.setEnabled(false); // TODO disable other task buttons } catch (Exception e) { showErrorDialog(actionDesc, "Task [" + taskInfo.getName() + "] could not be cleared! Error: [" + e.getMessage() + "]"); } }