List of usage examples for org.eclipse.jface.resource JFaceResources getString
public static String getString(String key)
From source file:org.eclipse.gmf.runtime.common.ui.preferences.FontFieldEditor.java
License:Open Source License
/** * Creates a font field editor with an optional preview area. * /*from w w w.j a va2 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 previewAreaText the text used for the preview window. If it is * <code>null</code> there will be no preview area, * @param parent the parent of the field editor's control */ public FontFieldEditor(String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); }
From source file:org.eclipse.gmf.runtime.diagram.ui.internal.dialogs.sortfilter.SortFilterDialog.java
License:Open Source License
protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /* (non-Javadoc) * /* w w w . j av a 2 s . c o m*/ * @see org.eclipse.core.runtime.ISafeRunnable#run() */ public void run() { getButton(IDialogConstants.OK_ID).setEnabled(false); errorOccurred = false; boolean hasFailedOK = false; try { // Notify all the pages and give them a chance to abort Iterator nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator(); CompoundCommand cc = new CompoundCommand(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null) { if (page instanceof SortFilterPage) { Command cmd = ((SortFilterPage) page).getCommand(); if (cmd != null && cmd.canExecute()) cc.add(cmd); } else if (!page.performOk()) { hasFailedOK = true; return; } } } if (cc.canExecute()) commandStack.execute(cc); } catch (Exception e) { handleException(e); } finally { //Don't bother closing if the OK failed if (hasFailedOK) { setReturnCode(FAILED); getButton(IDialogConstants.OK_ID).setEnabled(true); return; } if (!errorOccurred) { //Give subclasses the choice to save the state of the //preference pages. handleSave(); } setReturnCode(OK); close(); } } /* (non-Javadoc) * * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ public void handleException(Throwable e) { errorOccurred = true; Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e)); setSelectedNodePreference(null); String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$ } }); }
From source file:org.eclipse.jst.jsf.facesconfig.ui.preference.ColorFontFieldEditor.java
License:Open Source License
/** * /*from w w w .ja va2s. c om*/ * Creates a font field editor with an optional preview area. * * * * @param name * the name of the preference this field editor works on * * @param labelText * the label text of the field editor * * @param previewAreaText * the text used for the preview window. If it is * * <code>null</code> there will be no preview area, * * @param parent * the parent of the field editor's control * */ public ColorFontFieldEditor( String name, String labelText, String previewAreaText, Composite parent) { init(name, labelText); previewText = previewAreaText; changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$ createControl(parent); }
From source file:org.eclipse.jst.jsf.ui.internal.classpath.WarningMessageDialog.java
License:Open Source License
/** * NOTE: copied from IconAndMessageDialog * @param image/* ww w.jav a2 s . co m*/ * @return an accesible string */ private String getAccessibleMessageFor(Image image) { if (image.equals(getErrorImage())) { return JFaceResources.getString("error");//$NON-NLS-1$ } if (image.equals(getWarningImage())) { return JFaceResources.getString("warning");//$NON-NLS-1$ } if (image.equals(getInfoImage())) { return JFaceResources.getString("info");//$NON-NLS-1$ } if (image.equals(getQuestionImage())) { return JFaceResources.getString("question"); //$NON-NLS-1$ } return null; }
From source file:org.eclipse.jubula.client.ui.preferences.DatabaseConnectionPreferencePage.java
License:Open Source License
/** * Displays a dialog for the given wizard. * //from w ww . j a v a 2 s .c o m * @param databaseConnectionWizard The wizard to display in the dialog. * @param display Used for registering/deregistering global listeners. * @return the result of {@link Window#open()}. */ private static int showDialog(DatabaseConnectionDialog databaseConnectionWizard, Display display) { WizardDialog dialog = new WizardDialog(display.getActiveShell(), databaseConnectionWizard) { protected void createButtonsForButtonBar(Composite parent) { super.createButtonsForButtonBar(parent); Button finishButton = getButton(IDialogConstants.FINISH_ID); finishButton.setText(JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY)); } }; databaseConnectionWizard.setWindowTitle(Messages.DatabaseConnectionDialogTitle); dialog.setHelpAvailable(true); display.addFilter(SWT.FocusIn, SELECT_ALL_LISTENER); display.addFilter(SWT.FocusOut, SELECT_ALL_LISTENER); display.addFilter(SWT.Traverse, SELECT_ALL_LISTENER); try { return dialog.open(); } finally { display.removeFilter(SWT.FocusIn, SELECT_ALL_LISTENER); display.removeFilter(SWT.FocusOut, SELECT_ALL_LISTENER); display.removeFilter(SWT.Traverse, SELECT_ALL_LISTENER); } }
From source file:org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil.java
License:Open Source License
/** * Open the message dialog.// w ww . j a v a2 s.com * <p><b>Use createMessageDialog(JBException ex, Object[] params, String[] details) * instead, if you want to get an entry in error log.</b></p> * @param messageID the actual messageID * @param params Parameter of the message text or null, if not needed. * @param details use null, or overwrite in MessageIDs hardcoded details. * @param parent the parent shell to use for this message dialog * @return the dialog. */ public static Dialog createMessageDialog(final Integer messageID, final Object[] params, final String[] details, final Shell parent) { String title = StringConstants.EMPTY; String message = StringConstants.EMPTY; String[] labels = new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY) }; int imageID = MessageDialog.INFORMATION; Message msg = MessageIDs.getMessageObject(messageID); String[] detail = lineFeed(msg.getDetails()); if (details != null) { detail = lineFeed(details); } switch (msg.getSeverity()) { case Message.ERROR: title = Messages.UtilsError; message = Messages.UtilsErrorOccurred; break; case Message.INFO: title = Messages.UtilsInfo1; message = Messages.UtilsInfo2; break; case Message.WARNING: title = Messages.UtilsWarning1; message = Messages.UtilsWarning2; break; case Message.QUESTION: title = Messages.UtilsRequest1; message = Messages.UtilsRequest2; labels = new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY), JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) }; imageID = MessageDialog.QUESTION; break; default: break; } IStatus[] status = new Status[detail.length]; for (int i = 0; i < detail.length; i++) { status[i] = new Status(msg.getSeverity(), Constants.PLUGIN_ID, IStatus.OK, detail[i], null); } if ((msg.getSeverity() == Message.INFO || msg.getSeverity() == Message.QUESTION)) { StringBuilder messageBuilder = new StringBuilder(message); messageBuilder.append(msg.getMessage(params)); messageBuilder.append(StringConstants.NEWLINE); for (IStatus s : status) { if (s.getMessage() != Message.NO_DETAILS) { messageBuilder.append(StringConstants.NEWLINE); messageBuilder.append(s.getMessage()); } } dlg = new MessageDialog(parent, title, null, messageBuilder.toString(), imageID, labels, 0); } else { dlg = new ErrorDialog(parent, title, message, new MultiStatus(Constants.PLUGIN_ID, IStatus.OK, status, msg.getMessage(params), null), IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR); } dlg.create(); DialogUtils.setWidgetNameForModalDialog(dlg); dlg.open(); return dlg; }
From source file:org.eclipse.mat.ui.internal.query.arguments.ImageTextEditor.java
License:Open Source License
private void createHelpControl(Composite parent) { button = new ImageHyperlink(parent, SWT.CENTER) { {//www. j a va 2s.c om marginHeight = 0; } }; button.setImage(MemoryAnalyserPlugin.getImage(MemoryAnalyserPlugin.ISharedImages.HELP)); button.setFont(item.getFont()); button.setBackground(item.getBackground()); button.setToolTipText(JFaceResources.getString("helpToolTip"));//$NON-NLS-1$ button.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { PlatformUI.getWorkbench().getHelpSystem().displayHelpResource( "/org.eclipse.mat.ui.help/reference/selectingqueries.html#ref_queryarguments__"//$NON-NLS-1$ + decorator.getHelpLink()); } }); }
From source file:org.eclipse.ocl.examples.modelregistry.ui.properties.PropertyPage.java
License:Open Source License
@Override public void createControl(Composite parent) { configurationBlock = new ConfigurationBlock(getFileHandle()); super.createControl(parent); ModelRegistryHelper.setHelp(getControl(), ModelRegistryHelpIds.PropertyPage.OVERVIEW); getDefaultsButton().setText(JFaceResources.getString("Revert")); }
From source file:org.eclipse.papyrus.infra.gmfdiag.preferences.PapyrusScopedPreferenceStore.java
License:Open Source License
public void firePropertyChangeEvent(String name, Object oldValue, 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;//www . ja v a2s . 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$ public void run() { listener.propertyChange(event); } }); } }
From source file:org.eclipse.php.internal.server.ui.launching.zend.DefaultServerTestMessageDialog.java
License:Open Source License
private String getAccessibleMessageFor(Image image) { if (image.equals(getErrorImage())) { return JFaceResources.getString("error"); //$NON-NLS-1$ }/*from www . j a v a2 s. c o m*/ if (image.equals(getWarningImage())) { return JFaceResources.getString("warning"); //$NON-NLS-1$ } if (image.equals(getInfoImage())) { return JFaceResources.getString("info"); //$NON-NLS-1$ } if (image.equals(getQuestionImage())) { return JFaceResources.getString("question"); //$NON-NLS-1$ } return null; }