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

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

Introduction

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

Prototype

@Override
public void setToolTipText(String toolTipText) 

Source Link

Document

Sets the tool tip text for this action.

Usage

From source file:at.bestsolution.efxclipse.tooling.ui.preview.LivePreviewPart.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(3, false));

    folder = new CTabFolder(container, SWT.BOTTOM | SWT.BORDER);
    folder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1));

    parent.getDisplay().asyncExec(new Runnable() {

        @Override// ww  w.j  a  va 2s. co m
        public void run() {

            {
                CTabItem item = new CTabItem(folder, SWT.NONE);

                item.setText("Preview");
                item.setImage(JFaceResources.getImage(IMAGE_PREVIEW));

                swtFXContainer = new FXCanvas(folder, SWT.NONE);
                swtFXContainer.setEnabled(false);

                item.setControl(swtFXContainer);

                rootPane_new = new BorderPane();
                Scene scene = new Scene((Parent) rootPane_new, 1000, 1000);
                currentScene = scene;
                swtFXContainer.setScene(scene);
            }

            {
                logItem = new CTabItem(folder, SWT.NONE);
                logItem.setText("Error log");
                logItem.setImage(JFaceResources.getImage(IMAGE_OK));

                logStatement = new Text(folder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
                logStatement.setEditable(false);
                logItem.setControl(logStatement);

                Menu m = new Menu(logStatement);
                logStatement.setMenu(m);
                MenuItem clearItem = new MenuItem(m, SWT.PUSH);
                clearItem.setText("Clear Log");
                clearItem.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        logStatement.setText("");
                    }
                });
            }

            {
                CTabItem fxmlContent = new CTabItem(folder, SWT.NONE);
                fxmlContent.setText("FXML-Source");
                fxmlContent.setImage(JFaceResources.getImage(IMAGE_FXML_CONTENT));

                final AnnotationModel model = new AnnotationModel();
                VerticalRuler verticalRuler = new VerticalRuler(VERTICAL_RULER_WIDTH, new AnnotationAccess());
                int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
                SourceViewer sourceViewer = new SourceViewer(folder, verticalRuler, styles);
                sourceViewer.configure(new XMLConfiguration(new ColorManager()));
                sourceViewer.setEditable(false);
                sourceViewer.getTextWidget().setFont(JFaceResources.getTextFont());

                document = new Document();
                IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(),
                        new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT });
                partitioner.connect(document);
                document.setDocumentPartitioner(partitioner);
                sourceViewer.setDocument(document);
                verticalRuler.setModel(model);
                fxmlContent.setControl(sourceViewer.getControl());
            }

            folder.setSelection(0);

            statusLabelIcon = new Label(container, SWT.NONE);
            statusLabelIcon.setImage(JFaceResources.getImage(IMAGE_STATUS_NOPREVIEW));

            statusLabelText = new Label(container, SWT.NONE);
            statusLabelText.setText(NO_PREVIEW_TEXT);
            statusLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

            Composite scaleControl = new Composite(container, SWT.NONE);
            scaleControl.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
            scaleControl.setLayout(new GridLayout(2, false));

            Label l = new Label(scaleControl, SWT.NONE);
            l.setText("Zoom");

            scale = new Spinner(scaleControl, SWT.BORDER);
            scale.setMinimum(10);
            scale.setMaximum(500);
            scale.setIncrement(10);
            scale.setSelection(100);
            scale.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    rootPane_new.setScaleX(scale.getSelection() / 100.0);
                    rootPane_new.setScaleY(scale.getSelection() / 100.0);
                    if (currentFile != null) {
                        scaleMap.put(currentFile, scale.getSelection());
                    }
                }
            });

            parent.layout(true, true);

            if (currentData != null) {
                refreshContent(currentData);
            }
        }
    });

    parent.layout(true, true);

    Action loadController = new Action("", IAction.AS_CHECK_BOX) {
        @Override
        public void run() {
            preference.putBoolean(PREF_LOAD_CONTROLLER, !preference.getBoolean(PREF_LOAD_CONTROLLER, false));
            try {
                preference.flush();
                synchronizer.refreshPreview();
            } catch (BackingStoreException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    };
    loadController.setChecked(preference.getBoolean(PREF_LOAD_CONTROLLER, false));
    loadController.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(IMAGE_LOAD_CONTROLLER));
    loadController.setToolTipText("Load the controller");

    Action refresh = new Action("", JFaceResources.getImageRegistry().getDescriptor(IMAGE_REFRESH)) {
        @Override
        public void run() {
            synchronizer.refreshPreview();
        }
    };
    refresh.setToolTipText("Force a refresh");

    getViewSite().getActionBars().getToolBarManager().add(refresh);
    getViewSite().getActionBars().getToolBarManager().add(loadController);
}

From source file:ca.mt.wb.devtools.tx.InheritanceView.java

License:unlicense.org

private IAction createLayoutAction(String desc, final LayoutAlgorithm la) {
    Action action = new Action() {
        public void run() {
            viewer.setLayoutAlgorithm(la, true);
            viewer.refresh();/*from www. j av  a  2  s .  c o m*/
        }
    };
    action.setText(desc);
    action.setToolTipText("Re-layout items with " + desc);
    return action;
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle1.UiContentOutlinePage.java

License:Apache License

/**
 * Adds the menu actions to the context menu when the given UI node is selected in
 * the tree view./*  w w w. j a  va 2s  . com*/
 *
 * @param manager The context menu manager
 * @param selected The UI node selected in the tree. Can be null, in which case the root
 *                is to be modified.
 */
private void doCreateMenuAction(IMenuManager manager, List<UiElementNode> selected) {

    if (selected != null) {
        boolean hasXml = false;
        for (UiElementNode uiNode : selected) {
            if (uiNode.getXmlNode() != null) {
                hasXml = true;
                break;
            }
        }

        if (hasXml) {
            manager.add(new CopyCutAction(mEditor.getLayoutEditor(), mEditor.getClipboard(), null, selected,
                    true /* cut */));
            manager.add(new CopyCutAction(mEditor.getLayoutEditor(), mEditor.getClipboard(), null, selected,
                    false /* cut */));

            // Can't paste with more than one element selected (the selection is the target)
            if (selected.size() <= 1) {
                // Paste is not valid if it would add a second element on a terminal element
                // which parent is a document -- an XML document can only have one child. This
                // means paste is valid if the current UI node can have children or if the parent
                // is not a document.
                UiElementNode ui_root = selected.get(0).getUiRoot();
                if (ui_root.getDescriptor().hasChildren()
                        || !(ui_root.getUiParent() instanceof UiDocumentNode)) {
                    manager.add(new PasteAction(mEditor.getLayoutEditor(), mEditor.getClipboard(),
                            selected.get(0)));
                }
            }
            manager.add(new Separator());
        }
    }

    // Append "add" and "remove" actions. They do the same thing as the add/remove
    // buttons on the side.
    //
    // "Add" makes sense only if there's 0 or 1 item selected since the
    // one selected item becomes the target.
    if (selected == null || selected.size() <= 1) {
        manager.add(mAddAction);
    }

    if (selected != null) {
        manager.add(mDeleteAction);
        manager.add(new Separator());

        manager.add(mUpAction);
        manager.add(mDownAction);
    }

    if (selected != null && selected.size() == 1) {
        manager.add(new Separator());

        Action propertiesAction = new Action("Properties") {
            @Override
            public void run() {
                EclipseUiHelper.showView(EclipseUiHelper.PROPERTY_SHEET_VIEW_ID, true /* activate */);
            }
        };
        propertiesAction.setToolTipText("Displays properties of the selected element.");
        manager.add(propertiesAction);
    }
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas.java

License:Open Source License

/**
 * Helper for {@link #setupGlobalActionHandlers()}.
 * Copies the action attributes form the given {@link ActionFactory}'s action to
 * our action./*ww w  .  j  a va 2  s .  c om*/
 * <p/>
 * {@link ActionFactory} provides access to the standard global actions in Eclipse.
 * <p/>
 * This allows us to grab the standard labels and icons for the
 * global actions such as copy, cut, paste, delete and select-all.
 */
private void copyActionAttributes(Action action, ActionFactory factory) {
    IWorkbenchAction wa = factory.create(mEditorDelegate.getEditor().getEditorSite().getWorkbenchWindow());
    action.setId(wa.getId());
    action.setText(wa.getText());
    action.setEnabled(wa.isEnabled());
    action.setDescription(wa.getDescription());
    action.setToolTipText(wa.getToolTipText());
    action.setAccelerator(wa.getAccelerator());
    action.setActionDefinitionId(wa.getActionDefinitionId());
    action.setImageDescriptor(wa.getImageDescriptor());
    action.setHoverImageDescriptor(wa.getHoverImageDescriptor());
    action.setDisabledImageDescriptor(wa.getDisabledImageDescriptor());
    action.setHelpListener(wa.getHelpListener());
}

From source file:com.aptana.editor.common.outline.CommonQuickOutlinePage.java

License:Open Source License

/**
 * Contributes actions to quick outline menu.
 * //from ww  w. ja  va  2  s . co m
 * @param manager
 *            - menu manager.
 */
void contributeToQuickOutlineMenu(IMenuManager manager) {
    // add sort action
    Action sortAction = new Action(Messages.CommonQuickOutlinePage_SortAlphabetically, Action.AS_CHECK_BOX) {
        public void run() {
            // Hide tree control during redraw
            getTreeViewer().getControl().setVisible(false);

            // Set the sorting according to whether this Action is checked/unchecked
            // TODO Store this persistently across quick outlines per-language?
            if (this.isChecked()) {
                getTreeViewer().setComparator(new ViewerComparator());
            } else {
                getTreeViewer().setComparator(null);
            }

            // Show the tree control
            getTreeViewer().getControl().setVisible(true);
        }
    };
    sortAction.setImageDescriptor(UIUtils.getImageDescriptor(CommonEditorPlugin.PLUGIN_ID, "icons/sort.gif")); //$NON-NLS-1$
    sortAction.setToolTipText(Messages.CommonQuickOutlinePage_SortAlphabetically);
    // this._sortItem = new ActionContributionItem(sortAction);
    manager.add(new ActionContributionItem(sortAction));

    // add Collapse All action
    Action collapseAction = new Action(Messages.CommonQuickOutlinePage_CollapseAll, Action.AS_PUSH_BUTTON) {
        public void run() {
            getTreeViewer().collapseAll();
        }
    };
    collapseAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
    collapseAction.setToolTipText(Messages.CommonQuickOutlinePage_CollapseAll);
    manager.add(new ActionContributionItem(collapseAction));

    // Expand All action
    Action expandAction = new Action(Messages.CommonQuickOutlinePage_ExpandAll) {
        public void run() {
            getTreeViewer().expandAll();
        }
    };
    expandAction.setImageDescriptor(
            UIUtils.getImageDescriptor(CommonEditorPlugin.PLUGIN_ID, "icons/expandall.gif")); //$NON-NLS-1$
    expandAction.setToolTipText(Messages.CommonQuickOutlinePage_ExpandAll);
    manager.add(new ActionContributionItem(expandAction));
}

From source file:com.aptana.ide.editors.unified.actions.ToolBarContributionRegistryImpl.java

License:Open Source License

private static void updateToolbar(final IToolBarManager toolBarManager, String defaultLanguage,
        final IUnifiedEditor editor) {
    toolBarManager.removeAll();/* w  w w  .jav a2s  .  c  o m*/

    ArrayList contributions = (ArrayList) toolBarContributions.get(defaultLanguage);
    if (contributions != null) {
        for (Iterator iterator = contributions.iterator(); iterator.hasNext();) {
            final ToolBarContribution name = (ToolBarContribution) iterator.next();
            Action action = new Action(name.getText(), Action.AS_PUSH_BUTTON) {
                public void run() {

                    IToolBarMember member = (IToolBarMember) name.getInstance();
                    member.execute(editor, name.getText());

                }
            };
            action.setImageDescriptor(name.getIcon());
            action.setToolTipText(name.getTooltipText());
            toolBarManager.add(action);
        }
    }
}

From source file:com.aptana.ide.views.outline.UnifiedOutlinePage.java

License:Open Source License

/**
 * @see org.eclipse.ui.part.Page#setActionBars(org.eclipse.ui.IActionBars)
 *///  w  w  w. j  a v a 2s .  com
public void setActionBars(IActionBars actionBars) {
    // add split action
    if (this._outlines.size() > 0) {
        SplitOutlinesAction splitAction = new SplitOutlinesAction(this);

        splitAction.setEnabled(this._composite.isReparentable());
        this._splitItem = new ActionContributionItem(splitAction);
        actionBars.getToolBarManager().add(this._splitItem);
    }
    this._actionBars = actionBars;
    // add sort action
    SortAction sortAction = new SortAction(this);
    IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore();
    boolean sort = store.getBoolean(IPreferenceConstants.SORT_OUTLINE_ALPHABETICALLY);
    sortAction.setChecked(sort);
    if (sort) {
        getTreeViewer().setSorter(SortAction.SORTER);
    }
    this._sortItem = new ActionContributionItem(sortAction);
    actionBars.getToolBarManager().add(this._sortItem);

    // add hide private members action
    this._hidePrivateAction = new HidePrivateAction(this);
    this._hidePrivateItem = new ActionContributionItem(this._hidePrivateAction);
    actionBars.getToolBarManager().add(this._hidePrivateItem);

    // add collapse all action
    CollapseAction collapseAction = new CollapseAction(this);
    this._collapseItem = new ActionContributionItem(collapseAction);
    actionBars.getToolBarManager().add(this._collapseItem);

    Action expandAction = new Action(Messages.UnifiedOutlinePage_ExpandAll) {
        public void run() {
            getTreeViewer().expandAll();
        }
    };
    expandAction.setImageDescriptor(UnifiedEditorsPlugin.getImageDescriptor("icons/expandall.gif")); //$NON-NLS-1$
    expandAction.setToolTipText(Messages.UnifiedOutlinePage_CollapseAll);
    this._expandItem = new ActionContributionItem(expandAction);
    actionBars.getToolBarManager().add(this._expandItem);

    super.setActionBars(actionBars);
}

From source file:com.aptana.ide.views.outline.UnifiedOutlinePage.java

License:Open Source License

/**
 * Contibutes actions to quick outline menu.
 * /*w  w  w  .j  a  va  2 s .  com*/
 * @param manager
 *            - menu manager.
 */
public void contributeToQuickOutlineMenu(IMenuManager manager) {
    // add split action
    if (this._outlines.size() > 0) {
        SplitOutlinesAction splitAction = new SplitOutlinesAction(this);

        splitAction.setEnabled(this._composite.isReparentable());
        this._splitItem = new ActionContributionItem(splitAction);
        manager.add(this._splitItem);
    }
    // add sort action
    SortAction sortAction = new SortAction(this);
    IPreferenceStore store = UnifiedEditorsPlugin.getDefault().getPreferenceStore();
    boolean sort = store.getBoolean(IPreferenceConstants.SORT_OUTLINE_ALPHABETICALLY);
    sortAction.setChecked(sort);
    if (sort) {
        getTreeViewer().setSorter(SortAction.SORTER);
    }
    this._sortItem = new ActionContributionItem(sortAction);
    manager.add(this._sortItem);

    // add hide private members action
    this._hidePrivateAction = new HidePrivateAction(this);
    this._hidePrivateItem = new ActionContributionItem(this._hidePrivateAction);
    manager.add(this._hidePrivateItem);

    // add collapse all action
    CollapseAction collapseAction = new CollapseAction(this);
    this._collapseItem = new ActionContributionItem(collapseAction);
    manager.add(this._collapseItem);

    Action expandAction = new Action(Messages.UnifiedOutlinePage_ExpandAll) {
        public void run() {
            getTreeViewer().expandAll();
        }
    };
    expandAction.setImageDescriptor(UnifiedEditorsPlugin.getImageDescriptor("icons/expandall.gif")); //$NON-NLS-1$
    expandAction.setToolTipText(Messages.UnifiedOutlinePage_CollapseAll);
    this._expandItem = new ActionContributionItem(expandAction);
    manager.add(this._expandItem);
}

From source file:com.arm.cmsis.config.editors.ConfigEditor.java

License:Open Source License

private void buildToolBar(Composite parent) {

    Label imageLabel = new Label(parent, SWT.LEFT);
    imageLabel.setImage(CpPlugInUI.getImage(CpPlugInUI.ICON_DETAILS));

    Label title = new Label(parent, SWT.NONE);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(title.getFont()).setStyle(SWT.BOLD)
            .increaseHeight(1);/*from   w w  w . j av  a 2s. c om*/
    Font boldFont = boldDescriptor.createFont(title.getDisplay());
    title.setFont(boldFont);
    title.setText(Messages.ConfigEditor_SecondPageText);

    ManagedToolBar toolbar = new ManagedToolBar(parent, SWT.FLAT | SWT.RIGHT_TO_LEFT);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.CONFIG_WIZARD);

    Action help = new Action(Messages.ConfigEditor_Help, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            parent.notifyListeners(SWT.Help, new Event());
        }
    };
    help.setToolTipText(Messages.ConfigEditor_HelpForConfigWizard);
    help.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_HELP));
    toolbar.addAction(help, false);

    Action collapseAll = new Action(Messages.ConfigEditor_CollapseAll, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            fViewer.collapseAll();
        }
    };
    collapseAll.setToolTipText(Messages.ConfigEditor_CollapseAllItems);
    collapseAll.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_COLLAPSE_ALL));
    toolbar.addAction(collapseAll, false);

    Action expandAll = new Action(Messages.ConfigEditor_ExpandAll, IAction.AS_PUSH_BUTTON) {
        @Override
        public void run() {
            fViewer.expandAll();
        }
    };
    expandAll.setToolTipText(Messages.ConfigEditor_ExpandAllItems);
    expandAll.setImageDescriptor(CpPlugInUI.getImageDescriptor(CpPlugInUI.ICON_EXPAND_ALL));
    toolbar.addAction(expandAll, false);
}

From source file:com.arm.cmsis.pack.ui.editors.RteEditorPageHeader.java

License:Open Source License

/**
 * Creates save action and adds it to the right toolbar 
 * @return created IAction//from  w  w w .  j av a 2 s .c o  m
 */
public IAction addSaveAction() {
    Action saveAction = new Action("Save", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$
        public void run() {
            ICommandService commandService = CpPlugInUI.getCommandService();
            if (commandService == null)
                return;
            try {
                // Lookup csave ommand with its ID
                Command command = commandService.getCommand("org.eclipse.ui.file.save"); //$NON-NLS-1$
                if (command != null && command.isEnabled()) {
                    command.executeWithChecks(new ExecutionEvent());
                }
            } catch (Exception e) {
                // Replace with real-world exception handling
                e.printStackTrace();
            }
        }
    };
    saveAction.setToolTipText(CpStringsUI.RteManagerWidget_ApplyAndSave);
    saveAction.setImageDescriptor(
            PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT));
    saveAction.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED));
    addAction(saveAction, SWT.RIGHT);
    return saveAction;
}