Example usage for org.eclipse.jface.action LegacyActionTools escapeMnemonics

List of usage examples for org.eclipse.jface.action LegacyActionTools escapeMnemonics

Introduction

In this page you can find the example usage for org.eclipse.jface.action LegacyActionTools escapeMnemonics.

Prototype

public static String escapeMnemonics(String text) 

Source Link

Document

Convenience method for escaping all mnemonics in the given string.

Usage

From source file:codeOrchestra.lcs.status.StatusLineContributionItemEx.java

License:Open Source License

/**
 * Sets the text to be displayed in the status line.
 * /*from w ww .  j  a  v  a2s  .  co m*/
 * @param text
 *          the text to be displayed, must not be <code>null</code>
 */
public void setText(String text) {
    Assert.isNotNull(text);

    this.text = LegacyActionTools.escapeMnemonics(text);

    if (label != null && !label.isDisposed()) {
        label.setText(this.text);
    }

    if (this.text.length() == 0) {
        if (isVisible()) {
            setVisible(false);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    } else {
        // Always update if using 'CALC_TRUE_WIDTH'
        if (!isVisible() || charWidth == CALC_TRUE_WIDTH) {
            setVisible(true);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    }
}

From source file:com.google.dart.tools.search2.internal.ui.SearchView.java

License:Open Source License

@Override
public void updateLabel() {
    ISearchResultPage page = getActivePage();
    String label = ""; //$NON-NLS-1$
    if (page != null) {
        label = LegacyActionTools.escapeMnemonics(page.getLabel());
    }//from   w w w .ja v a 2  s  .  c  o m
    if (!fPageContent.isDisposed()) {
        if (label.length() == 0) {
            if (fDescriptionComposite != null) {
                fDescriptionComposite.dispose();
                fDescriptionComposite = null;
                fPageContent.layout();
            }
        } else {
            if (fDescriptionComposite == null) {
                fDescriptionComposite = new Composite(fPageContent, SWT.NONE);
                fDescriptionComposite.moveAbove(null);

                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                fDescriptionComposite.setLayout(layout);
                fDescriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

                fDescription = new Link(fDescriptionComposite, SWT.NONE);
                GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
                gridData.horizontalIndent = 5;
                fDescription.setLayoutData(gridData);
                fDescription.setText(label);

                Label separator = new Label(fDescriptionComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
                separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                fPageContent.layout();
            } else {
                fDescription.setText(label);
            }
        }
    }
}

From source file:net.yatomiya.e4.ui.workbench.renderers.swt.StackRenderer.java

License:Open Source License

private String getLabel(MUILabel itemPart, String newName) {
    if (newName == null) {
        newName = ""; //$NON-NLS-1$
    } else {//from  w w w .j a v a  2 s  .  com
        newName = LegacyActionTools.escapeMnemonics(newName);
    }

    if (itemPart instanceof MDirtyable && ((MDirtyable) itemPart).isDirty()) {
        newName = '*' + newName;
    }
    return newName;
}

From source file:net.yatomiya.e4.ui.workbench.renderers.swt.StackRenderer.java

License:Open Source License

private String getToolTip(String newToolTip) {
    return newToolTip == null || newToolTip.length() == 0 ? null
            : LegacyActionTools.escapeMnemonics(newToolTip);
}

From source file:org.eclipse.compare.codereview.compareEditor.RefacContentMergeViewer.java

License:Open Source License

/**
 * Updates the headers of the three areas
 * by querying the content provider for a name and image for
 * the three sides of the input object./* www .jav  a2  s.c  o  m*/
 * <p>
 * This method is called whenever the header must be updated.
 * <p>
 * Subclasses may extend this method, although this is generally not required.
 */
protected void updateHeader() {

    IMergeViewerContentProvider content = getMergeContentProvider();
    Object input = getInput();

    // Only change a label if there is a new label available
    if (fAncestorLabel != null) {
        Image ancestorImage = content.getAncestorImage(input);
        if (ancestorImage != null)
            fAncestorLabel.setImage(ancestorImage);
        String ancestorLabel = content.getAncestorLabel(input);
        if (ancestorLabel != null)
            fAncestorLabel.setText(LegacyActionTools.escapeMnemonics(TextProcessor.process(ancestorLabel)));
    }
    if (fLeftLabel != null) {
        Image leftImage = content.getLeftImage(input);
        if (leftImage != null)
            fLeftLabel.setImage(leftImage);
        String leftLabel = content.getLeftLabel(input);
        if (leftLabel != null)
            fLeftLabel.setText(LegacyActionTools.escapeMnemonics(leftLabel));
    }
    if (fRightLabel != null) {
        Image rightImage = content.getRightImage(input);
        if (rightImage != null)
            fRightLabel.setImage(rightImage);
        String rightLabel = content.getRightLabel(input);
        if (rightLabel != null)
            fRightLabel.setText(LegacyActionTools.escapeMnemonics(rightLabel));
    }
}

From source file:org.eclipse.mylyn.commons.ui.CommonUiUtil.java

License:Open Source License

/**
 * Returns text for use as the label of an action to ensure that it is displayed properly.
 * //from  w  w w.ja  v  a2 s .  c  o m
 * @return the cleaned text
 */
public static String toMenuLabel(String label) {
    // a tab at the end of the text will make sure that the @ will not create a weird space in the action text
    // bug 287347: @ at start of task name cause a weird space in activation history menu
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=287347
    if (label.contains("@")) { //$NON-NLS-1$
        label += "\t"; //$NON-NLS-1$
    }
    return LegacyActionTools.escapeMnemonics(label);
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaFlagPart.java

License:Open Source License

private void createInfoOverlay(Composite composite, Section section, FormToolkit toolkit) {
    String text = getInfoOverlayText();
    if (text == null) {
        return;//from w w  w .  jav a  2  s  .c  o  m
    }

    final Label label = toolkit.createLabel(composite, LegacyActionTools.escapeMnemonics(text));
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    label.setBackground(null);
    label.setVisible(!section.isExpanded());
    label.setToolTipText(getInfoOverlayTooltipText());

    section.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            label.setVisible(!e.getState());
        }
    });
}

From source file:org.eclipse.mylyn.internal.builds.ui.BuildToolTip.java

License:Open Source License

protected void addIconAndLabel(Composite parent, Image image, String text, boolean bold) {
    Label imageLabel = new Label(parent, SWT.NONE);
    imageLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    imageLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    imageLabel.setLayoutData(/* w  w  w .j a  va  2 s . c om*/
            new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
    imageLabel.setImage(image);

    Label textLabel = new Label(parent, SWT.WRAP);
    if (bold) {
        textLabel.setFont(CommonFonts.BOLD);
    }
    textLabel.setForeground(getTitleColor());
    textLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));

    textLabel.setText(LegacyActionTools.escapeMnemonics(text));
    int width = Math.min(textLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, MAX_WIDTH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(width, SWT.DEFAULT).applyTo(textLabel);
}

From source file:org.eclipse.mylyn.internal.builds.ui.editor.AbstractBuildEditorPart.java

License:Open Source License

/**
 * Clients can implement to provide attribute overlay text
 * /*w w w . j a va  2 s. c  o m*/
 * @param section
 */
private void createInfoOverlay(Composite composite, Section section, FormToolkit toolkit) {
    String text = getInfoOverlayText();
    if (text == null) {
        return;
    }

    final Label label = toolkit.createLabel(composite, LegacyActionTools.escapeMnemonics(text));
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    label.setBackground(null);
    label.setVisible(!section.isExpanded());

    section.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            label.setVisible(!e.getState());
        }
    });
}

From source file:org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup.java

License:Open Source License

@Override
protected void createContentArea(Composite parent) {
    int count = 0;
    for (final AbstractNotification notification : notifications) {
        Composite notificationComposite = new Composite(parent, SWT.NO_FOCUS);
        GridLayout gridLayout = new GridLayout(2, false);
        GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP)
                .applyTo(notificationComposite);
        notificationComposite.setLayout(gridLayout);
        notificationComposite.setBackground(parent.getBackground());

        if (count < NUM_NOTIFICATIONS_TO_DISPLAY) {
            final Label notificationLabelIcon = new Label(notificationComposite, SWT.NO_FOCUS);
            notificationLabelIcon.setBackground(parent.getBackground());
            if (notification instanceof AbstractUiNotification) {
                notificationLabelIcon//  w  ww .  j  av  a  2 s.com
                        .setImage(((AbstractUiNotification) notification).getNotificationKindImage());
            }
            // FIXME
            //            if (!(notification instanceof TaskListNotificationReminder)) {
            //               final AbstractTask task = (AbstractTask) notification.getAdapter(AbstractTask.class);
            //               if (task != null) {
            //                  notificationLabelIcon.addMouseListener(new MouseAdapter() {
            //                     @Override
            //                     public void mouseUp(MouseEvent e) {
            //                        TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
            //                        notificationLabelIcon.setImage(null);
            //                        notificationLabelIcon.setToolTipText(null);
            //                     }
            //                  });
            //                  notificationLabelIcon.setToolTipText(Messages.TaskListNotificationPopup_Mark_Task_Read);
            //               }
            //            }

            // FIXME
            //            final TaskScalingHyperlink itemLink = new TaskScalingHyperlink(notificationComposite, SWT.BEGINNING
            //                  | SWT.NO_FOCUS);

            final ScalingHyperlink itemLink = new ScalingHyperlink(notificationComposite,
                    SWT.BEGINNING | SWT.NO_FOCUS);
            GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(itemLink);
            itemLink.setForeground(CommonColors.HYPERLINK_WIDGET);
            itemLink.registerMouseTrackListener();
            itemLink.setText(LegacyActionTools.escapeMnemonics(notification.getLabel()));
            if (notification instanceof AbstractUiNotification) {
                itemLink.setImage(((AbstractUiNotification) notification).getNotificationImage());
            }
            itemLink.setBackground(parent.getBackground());
            itemLink.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent e) {
                    if (notification instanceof AbstractUiNotification) {
                        ((AbstractUiNotification) notification).open();
                    }
                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    if (window != null) {
                        Shell windowShell = window.getShell();
                        if (windowShell != null) {
                            if (windowShell.getMinimized()) {
                                windowShell.setMinimized(false);
                            }

                            windowShell.open();
                            windowShell.forceActive();
                        }
                    }
                }
            });

            String descriptionText = null;
            if (notification.getDescription() != null) {
                descriptionText = notification.getDescription();
            }
            if (descriptionText != null && !descriptionText.trim().equals("")) { //$NON-NLS-1$
                Label descriptionLabel = new Label(notificationComposite, SWT.NO_FOCUS);
                descriptionLabel.setText(LegacyActionTools.escapeMnemonics(descriptionText));
                descriptionLabel.setBackground(parent.getBackground());
                GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).grab(true, false).align(SWT.FILL, SWT.TOP)
                        .applyTo(descriptionLabel);
            }
        } else {
            int numNotificationsRemain = notifications.size() - count;
            ScalingHyperlink remainingLink = new ScalingHyperlink(notificationComposite, SWT.NO_FOCUS);
            remainingLink.setForeground(CommonColors.HYPERLINK_WIDGET);
            remainingLink.registerMouseTrackListener();
            remainingLink.setBackground(parent.getBackground());

            remainingLink.setText(NLS.bind("{0} more", numNotificationsRemain)); //$NON-NLS-1$
            GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(remainingLink);
            remainingLink.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent e) {
                    // FIXME
                    //                  TasksUiUtil.openTasksViewInActivePerspective().setFocus();
                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    if (window != null) {
                        Shell windowShell = window.getShell();
                        if (windowShell != null) {
                            windowShell.setMaximized(true);
                            windowShell.open();
                        }
                    }
                }
            });
            break;
        }
        count++;
    }
}