List of usage examples for org.eclipse.jface.action LegacyActionTools removeMnemonics
public static String removeMnemonics(final String text)
From source file:com.aptana.ruby.internal.debug.ui.breakpoints.AbstractRubyBreakpointEditor.java
License:Open Source License
/** * Returns text with mnemonics in tact or removed based on {@link #isMnemonics()}. * /*from www .j ava2 s .co m*/ * @param text string to process * @return text with mnemonics in tact or removed based on {@link #isMnemonics()} */ protected String processMnemonics(String text) { if (isMnemonics()) { return text; } return LegacyActionTools.removeMnemonics(text); }
From source file:com.google.dart.tools.internal.corext.refactoring.util.Strings.java
License:Open Source License
public static String removeMnemonicIndicator(String string) { return LegacyActionTools.removeMnemonics(string); }
From source file:com.google.dart.tools.search.internal.ui.SearchDialog.java
License:Open Source License
private void handleCustomizePressed() { List<SearchPageDescriptor> input = SearchPlugin.getDefault().getSearchPageDescriptors(); input = filterByActivities(input);/*from www . j ava 2s . c om*/ final ArrayList<Image> createdImages = new ArrayList<Image>(input.size()); ILabelProvider labelProvider = new LabelProvider() { @Override public Image getImage(Object element) { if (element instanceof SearchPageDescriptor) { ImageDescriptor imageDesc = ((SearchPageDescriptor) element).getImage(); if (imageDesc == null) { return null; } Image image = imageDesc.createImage(); if (image != null) { createdImages.add(image); } return image; } return null; } @Override public String getText(Object element) { if (element instanceof SearchPageDescriptor) { return LegacyActionTools.removeMnemonics(((SearchPageDescriptor) element).getLabel()); } return null; } }; String message = SearchMessages.SearchPageSelectionDialog_message; ListSelectionDialog dialog = new ListSelectionDialog(getShell(), input, new ArrayContentProvider(), labelProvider, message) { @Override public void create() { super.create(); final CheckboxTableViewer viewer = getViewer(); final Button okButton = this.getOkButton(); viewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { okButton.setEnabled(viewer.getCheckedElements().length > 0); } }); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { okButton.setEnabled(viewer.getCheckedElements().length > 0); } }; this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener); this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener); } }; dialog.setTitle(SearchMessages.SearchPageSelectionDialog_title); dialog.setInitialSelections( SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray()); if (dialog.open() == Window.OK) { SearchPageDescriptor.setEnabled(dialog.getResult()); Display display = getShell().getDisplay(); close(); if (display != null && !display.isDisposed()) { display.asyncExec(new Runnable() { @Override public void run() { new OpenSearchDialogAction().run(); } }); } } destroyImages(createdImages); }
From source file:com.google.dart.tools.ui.internal.text.dart.CompletionProposalCategory.java
License:Open Source License
/** * Returns the name of the described extension without mnemonic hint in order to be displayed in a * message.//from ww w. j ava 2s . co m * * @return Returns the name */ public String getDisplayName() { return LegacyActionTools.removeMnemonics(fName); }
From source file:com.google.dart.tools.ui.internal.text.dart.ContentAssistProcessor.java
License:Open Source License
/** * Informs the user about the fact that there are no enabled categories in the default content * assist set and shows a link to the preferences. *//* w w w . j av a 2s . c o m*/ private boolean informUserAboutEmptyDefaultCategory() { if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) { final Shell shell = DartToolsPlugin.getActiveWorkbenchShell(); String title = DartTextMessages.ContentAssistProcessor_all_disabled_title; String message = DartTextMessages.ContentAssistProcessor_all_disabled_message; // see PreferencePage#createControl for the 'defaults' label final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$ final String linkMessage = Messages.format( DartTextMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel)); final int restoreId = IDialogConstants.CLIENT_ID + 10; final int settingsId = IDialogConstants.CLIENT_ID + 11; final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* * default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) { /* * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar * (org.eclipse.swt.widgets.Composite) */ @Override protected void createButtonsForButtonBar(Composite parent) { Button[] buttons = new Button[2]; buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false); buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); setButtons(buttons); } /* * @see com.google.dart.tools.ui.dialogs.OptionalMessageDialog#createCustomArea * (org.eclipse.swt.widgets.Composite) */ @Override protected Control createCustomArea(Composite composite) { // wrap link and checkbox in one composite without space Composite parent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; parent.setLayout(layout); Composite linkComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); linkComposite.setLayout(layout); Link link = new Link(linkComposite, SWT.NONE); link.setText(linkMessage); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setReturnCode(settingsId); close(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); // create checkbox and "don't show this message" prompt super.createCustomArea(parent); return parent; } }; int returnValue = dialog.open(); if (restoreId == returnValue || settingsId == returnValue) { if (restoreId == returnValue) { IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); } if (settingsId == returnValue) { PreferencesUtil.createPreferenceDialogOn(shell, "com.google.dart.tools.ui.internal.preferences.CodeAssistPreferenceAdvanced", null, //$NON-NLS-1$ null).open(); } CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault(); registry.reload(); return true; } } return false; }
From source file:com.nokia.carbide.search.system.internal.ui.SearchDialog.java
License:Open Source License
private void handleCustomizePressed() { List input = SearchPlugin.getDefault().getSearchPageDescriptors(); input = filterByActivities(input);//from ww w . j av a 2 s.co m final ArrayList createdImages = new ArrayList(input.size()); ILabelProvider labelProvider = new LabelProvider() { public String getText(Object element) { if (element instanceof SearchPageDescriptor) return LegacyActionTools.removeMnemonics(((SearchPageDescriptor) element).getLabel()); return null; } public Image getImage(Object element) { if (element instanceof SearchPageDescriptor) { ImageDescriptor imageDesc = ((SearchPageDescriptor) element).getImage(); if (imageDesc == null) return null; Image image = imageDesc.createImage(); if (image != null) createdImages.add(image); return image; } return null; } }; String message = SearchMessages.SearchPageSelectionDialog_message; ListSelectionDialog dialog = new ListSelectionDialog(getShell(), input, new ArrayContentProvider(), labelProvider, message) { public void create() { super.create(); final CheckboxTableViewer viewer = getViewer(); final Button okButton = this.getOkButton(); viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { okButton.setEnabled(viewer.getCheckedElements().length > 0); } }); SelectionListener listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { okButton.setEnabled(viewer.getCheckedElements().length > 0); } }; this.getButton(IDialogConstants.SELECT_ALL_ID).addSelectionListener(listener); this.getButton(IDialogConstants.DESELECT_ALL_ID).addSelectionListener(listener); } }; dialog.setTitle(SearchMessages.SearchPageSelectionDialog_title); dialog.setInitialSelections( SearchPlugin.getDefault().getEnabledSearchPageDescriptors(fInitialPageId).toArray()); if (dialog.open() == Window.OK) { SearchPageDescriptor.setEnabled(dialog.getResult()); Display display = getShell().getDisplay(); close(); if (display != null && !display.isDisposed()) { display.asyncExec(new Runnable() { public void run() { new OpenSearchDialogAction().run(); } }); } } destroyImages(createdImages); }
From source file:com.redhat.ceylon.eclipse.code.open.FilteredItemsSelectionDialog.java
License:Open Source License
@Override protected Control createDialogArea(final Composite parent) { final Composite dialogArea = (Composite) super.createDialogArea(parent); final Composite content = new Composite(dialogArea, SWT.NONE); content.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); layout.numColumns = 1;/*from w ww . ja v a 2 s .co m*/ layout.marginWidth = 0; layout.marginHeight = 0; content.setLayout(layout); createPatternInput(content); final Label listLabel = createLabels(content); sash = new SashForm(content, SWT.HORIZONTAL | SWT.SMOOTH); sash.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite composite = new Composite(sash, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setLayout(GridLayoutFactory.fillDefaults().create()); list = new TableViewer(composite, (multi ? SWT.MULTI : SWT.SINGLE) | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL); list.getTable().getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { if (e.childID == ACC.CHILDID_SELF) { e.result = LegacyActionTools.removeMnemonics(listLabel.getText()); } } }); list.setContentProvider(contentProvider); list.setLabelProvider(itemsListLabelProvider); list.setInput(new Object[0]); list.setItemCount(contentProvider.getNumberOfElements()); applyDialogFont(list.getTable()); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = list.getTable().getItemHeight() * 15; list.getTable().setLayoutData(gd); if (enableDocArea()) { browser = new DocBrowser(sash, SWT.BORDER); browser.addLocationListener(new LocationListener() { @Override public void changing(LocationEvent event) { String location = event.location; //necessary for windows environment (fix for blank page) //somehow related to this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=129236 if (!"about:blank".equals(location) && !location.startsWith("http:")) { event.doit = false; handleLink(event.location, browser); } } @Override public void changed(LocationEvent event) { } }); refreshBrowserContent(browser, null); setDocAreaVisible(toggleDocAction == null || toggleDocAction.isChecked()); } createPopupMenu(); pattern.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { applyFilter(); } }); pattern.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.ARROW_DOWN) { if (list.getTable().getItemCount() > 0) { list.getTable().setFocus(); } } } }); list.addSelectionChangedListener(new ISelectionChangedListener() { boolean first = true; @Override public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); handleSelected(selection); //we need to re-layout the status area *only* the //very first time an icon is displayed! if (first && selection != null && !selection.isEmpty()) { statusArea.getParent().layout(); first = false; } } }); list.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { handleDoubleClick(); } }); list.getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { List selectedElements = ((StructuredSelection) list.getSelection()).toList(); Object item = null; boolean isSelectedHistory = true; for (Iterator it = selectedElements.iterator(); it.hasNext();) { item = it.next(); if (item instanceof ItemsListSeparator || !isHistoryElement(item)) { isSelectedHistory = false; break; } } if (isSelectedHistory) removeSelectedItems(selectedElements); } if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.SHIFT) != 0 && (e.stateMask & SWT.CTRL) != 0) { StructuredSelection selection = (StructuredSelection) list.getSelection(); if (selection.size() == 1) { Object element = selection.getFirstElement(); if (element.equals(list.getElementAt(0))) { pattern.setFocus(); } if (list.getElementAt( list.getTable().getSelectionIndex() - 1) instanceof ItemsListSeparator) list.getTable().setSelection(list.getTable().getSelectionIndex() - 1); list.getTable().notifyListeners(SWT.Selection, new Event()); } } if (e.keyCode == SWT.ARROW_DOWN && (e.stateMask & SWT.SHIFT) != 0 && (e.stateMask & SWT.CTRL) != 0) { if (list.getElementAt(list.getTable().getSelectionIndex() + 1) instanceof ItemsListSeparator) list.getTable().setSelection(list.getTable().getSelectionIndex() + 1); list.getTable().notifyListeners(SWT.Selection, new Event()); } } }); createStatusArea(content); applyDialogFont(content); restoreDialog(getDialogSettings()); if (initialPatternText != null) { pattern.setText(initialPatternText); } switch (selectionMode) { case CARET_BEGINNING: pattern.setSelection(0, 0); break; case FULL_SELECTION: pattern.setSelection(0, initialPatternText.length()); break; } // apply filter even if pattern is empty (display history) applyFilter(); return dialogArea; }
From source file:com.redhat.ceylon.eclipse.code.open.FilteredItemsSelectionDialog.java
License:Open Source License
protected void createPatternInput(final Composite content) { GridData gd;// ww w .j a v a 2 s . com final Label headerLabel = createHeader(content); pattern = new Text(content, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); pattern.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent e) { e.result = LegacyActionTools.removeMnemonics(headerLabel.getText()); } }); gd = new GridData(GridData.FILL_HORIZONTAL); pattern.setLayoutData(gd); }
From source file:de.walware.ecommons.ui.util.MessageUtil.java
License:Open Source License
public static String removeMnemonics(final String label) { return LegacyActionTools.removeMnemonics(label); }
From source file:descent.internal.ui.text.java.ContentAssistProcessor.java
License:Open Source License
/** * Informs the user about the fact that there are no enabled categories in the default content * assist set and shows a link to the preferences. * /* w w w. ja va2 s.c o m*/ * @since 3.3 */ private boolean informUserAboutEmptyDefaultCategory() { if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) { final Shell shell = JavaPlugin.getActiveWorkbenchShell(); String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title; String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message; // see PreferencePage#createControl for the 'defaults' label final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$ final String linkMessage = Messages.format( JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel)); final int restoreId = IDialogConstants.CLIENT_ID + 10; final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) { /* * @see descent.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) */ protected Control createCustomArea(Composite composite) { // wrap link and checkbox in one composite without space Composite parent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; parent.setLayout(layout); Composite linkComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); linkComposite.setLayout(layout); Link link = new Link(linkComposite, SWT.NONE); link.setText(linkMessage); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { close(); PreferencesUtil .createPreferenceDialogOn(shell, "descent.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); // create checkbox and "don't show this message" prompt super.createCustomArea(parent); return parent; } /* * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { Button[] buttons = new Button[2]; buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false); buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); setButtons(buttons); } }; if (restoreId == dialog.open()) { IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault(); registry.reload(); return true; } } return false; }