List of usage examples for org.eclipse.jface.resource JFaceResources getString
public static String getString(String key)
From source file:com.twinsoft.convertigo.eclipse.wizards.import_export.ProjectFileFieldEditor.java
License:Open Source License
protected boolean checkState() { String msg = null;/*from w w w .j a va 2 s . c o m*/ String path = getTextControl().getText(); if (path != null) { path = path.trim(); } else { path = "";//$NON-NLS-1$ } if (path.length() == 0) { if (!isEmptyStringAllowed()) { msg = getErrorMessage(); } } else { File file = new File(path); if (file.isFile()) { if (enforceAbsolute && !file.isAbsolute()) { msg = JFaceResources.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$ } } else { msg = getErrorMessage(); } } if (msg != null) { // error showErrorMessage(msg); return false; } // OK! clearErrorMessage(); return true; }
From source file:com.twinsoft.convertigo.eclipse.wizards.util.FileFieldEditor.java
License:Open Source License
/** * Creates a file field editor./*from w w w. j a v a 2 s . co m*/ * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param enforceAbsolute <code>true</code> if the file path * must be absolute, and <code>false</code> otherwise * @param parent the parent of the field editor's control */ public FileFieldEditor(String name, String labelText, boolean enforceAbsolute, Composite parent) { init(name, labelText); this.enforceAbsolute = enforceAbsolute; setErrorMessage(JFaceResources.getString("FileFieldEditor.errorMessage"));//$NON-NLS-1$ setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$ setValidateStrategy(VALIDATE_ON_FOCUS_LOST); createControl(parent); }
From source file:custom.swt.widgets.PopupDialog.java
License:Open Source License
/** * Create the dialog's menu for the move and resize actions. * //from w w w. ja v a 2 s .co m * @param parent * The parent composite. */ private void createDialogMenu(Composite parent) { toolBar = new ToolBar(parent, SWT.FLAT); ToolItem viewMenuButton = new ToolItem(toolBar, SWT.PUSH, 0); GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar); viewMenuButton.setImage(JFaceResources.getImage(POPUP_IMG_MENU)); viewMenuButton.setDisabledImage(JFaceResources.getImage(POPUP_IMG_MENU_DISABLED)); viewMenuButton.setToolTipText(JFaceResources.getString("PopupDialog.menuTooltip")); //$NON-NLS-1$ viewMenuButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showDialogMenu(); } }); // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=177183 toolBar.addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { showDialogMenu(); } }); }
From source file:de.bht.fpa.mail.s000000.common.filter.FilterDialog.java
License:Open Source License
/** * Create contents of the button bar.// www . j ava2 s . co m * * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { String ok = JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY); String cancel = JFaceResources.getString(IDialogLabelKeys.CANCEL_LABEL_KEY); createButton(parent, IDialogConstants.OK_ID, ok, true); createButton(parent, IDialogConstants.CANCEL_ID, cancel, false); }
From source file:de.bht.fpa.mail.s000000.common.rcp.exception.ExceptionDetailsErrorDialog.java
License:Open Source License
/** * Create this dialog's drop-down list component. * //from w ww . ja v a 2 s .c o m * @param parent * the parent composite * @return the drop-down list component */ protected Text createDropDownList(Composite parent) { // create the list text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); // fill the list populateList(text); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL); // data.heightHint = text.getItemHeight() * LIST_ITEM_COUNT; data.horizontalSpan = 2; text.setLayoutData(data); text.setFont(parent.getFont()); Menu copyMenu = new Menu(text); MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE); copyItem.addSelectionListener(new SelectionListener() { /* * @see SelectionListener.widgetSelected (SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { copyToClipboard(); } /* * @see SelectionListener.widgetDefaultSelected(SelectionEvent) */ @Override public void widgetDefaultSelected(SelectionEvent e) { copyToClipboard(); } }); copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$ text.setMenu(copyMenu); listCreated = true; return text; }
From source file:de.fhg.igd.slf4jplus.ui.userstatus.StackTraceErrorDialog.java
License:Open Source License
/** * @see ErrorDialog#createDropDownList(Composite) *//*w w w. j av a 2 s . c o m*/ @Override protected List createDropDownList(Composite parent) { _list = super.createDropDownList(parent); _list.removeAll(); //replace context menu _list.getMenu().dispose(); Menu copyMenu = new Menu(_list); MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE); copyItem.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { copyToClipboard(); } @Override public void widgetSelected(SelectionEvent e) { copyToClipboard(); } }); copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$ _list.setMenu(copyMenu); //convert stack trace to string String stackTrace = stackTraceToString(_status.getException()); if (stackTrace != null) { //add stack trace to list stackTrace = stackTrace.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$ stackTrace = stackTrace.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$ String[] lines = stackTrace.split("\n"); //$NON-NLS-1$ for (String l : lines) { _list.add(l); } } return _list; }
From source file:de.walware.ecommons.preferences.ui.ScopedPreferenceStore.java
License:Open Source License
@Override public void firePropertyChangeEvent(final String name, final Object oldValue, final Object newValue) { // important: create intermediate array to protect against listeners // being added/removed during the notification final Object[] list = getListeners(); if (list.length == 0) { return;//from w w w. j a va 2 s . co m } final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue); for (int i = 0; i < list.length; i++) { final IPropertyChangeListener listener = (IPropertyChangeListener) list[i]; SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$ @Override public void run() { listener.propertyChange(event); } }); } }
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. * /*from w w w . j av a 2 s .c om*/ * @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; }
From source file:eu.esdihumboldt.hale.ui.io.util.KeyStrokeValidatingDirectoryFieldEditor.java
License:Open Source License
/** * Creates a directory field editor.// ww w . j ava 2 s . c o m * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param parent the parent of the field editor's control */ public KeyStrokeValidatingDirectoryFieldEditor(String name, String labelText, Composite parent) { super(); init(name, labelText); setErrorMessage(JFaceResources.getString("DirectoryFieldEditor.errorMessage"));//$NON-NLS-1$ setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$ setValidateStrategy(VALIDATE_ON_KEY_STROKE); createControl(parent); }
From source file:eu.esdihumboldt.hale.ui.io.util.SaveFileFieldEditor.java
License:Open Source License
/** * @see FileFieldEditor#checkState()/* w ww.j a v a 2 s .c om*/ */ @Override protected boolean checkState() { String msg = null; String path = getTextControl().getText(); if (path != null) { path = path.trim(); } else { path = "";//$NON-NLS-1$ } if (path.length() == 0) { if (!isEmptyStringAllowed()) { msg = getErrorMessage(); } } else { File file = null; if (allowUri) { // check if string is an uri try { URI uri = new URI(path); // check if the URI references a file try { file = new File(uri); // is a file, just continue with normal validity check } catch (IllegalArgumentException e) { // no file return isValid(uri); } } catch (URISyntaxException e) { // ignore - no URI, try file } } if (file == null) { file = new File(path); } if (isValid(file)) { if (enforceAbsolute && !file.isAbsolute()) { msg = JFaceResources.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$ } } else { msg = getErrorMessage(); } } if (msg != null) { // error showErrorMessage(msg); return false; } // OK! clearErrorMessage(); return true; }