List of usage examples for org.eclipse.jface.resource JFaceResources getString
public static String getString(String key)
From source file:code_generate.preferences.TextAreaEditor.java
License:Open Source License
/** * Creates a string field editor.// w w w . j av a 2s .c o m * Use the method <code>setTextLimit</code> to limit the text. * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param width the width of the text input field in characters, * or <code>UNLIMITED</code> for no limit * @param strategy either <code>VALIDATE_ON_KEY_STROKE</code> to perform * on the fly checking (the default), or <code>VALIDATE_ON_FOCUS_LOST</code> to * perform validation only after the text has been typed in * @param parent the parent of the field editor's control * @since 2.0 */ public TextAreaEditor(String name, String labelText, int width, int strategy, Composite parent) { init(name, labelText); widthInChars = width; setValidateStrategy(strategy); isValid = false; errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$ createControl(parent); }
From source file:com.agynamix.platform.frontend.preferences.ApplicationChooserFieldEditor.java
License:Open Source License
protected boolean checkState() { String msg = null;//from w w w . ja v a 2 s .co 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()) || ((PlatformUtils.isMacOs()) && (file.isDirectory()))) { if (enforceAbsolute && !file.isAbsolute()) { msg = JFaceResources.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$ } } else { if (SimidudeUtils.findProgram(path) == null) { msg = getErrorMessage(); } } } if (msg != null) { // error showErrorMessage(msg); return false; } // OK! clearErrorMessage(); return true; }
From source file:com.agynamix.platform.frontend.preferences.PasswordFieldEditor.java
License:Open Source License
/** * Creates a string field editor. Use the method <code>setTextLimit</code> * to limit the text.//w ww. j a v a2 s . c om * * @param name * the name of the preference this field editor works on * @param labelText * the label text of the field editor * @param width * the width of the text input field in characters, or * <code>UNLIMITED</code> for no limit * @param strategy * either <code>VALIDATE_ON_KEY_STROKE</code> to perform on the * fly checking (the default), or * <code>VALIDATE_ON_FOCUS_LOST</code> to perform validation * only after the text has been typed in * @param parent * the parent of the field editor's control * @since 2.0 */ public PasswordFieldEditor(String name, String labelText, int width, int strategy, Composite parent) { init(name, labelText); widthInChars = width; setValidateStrategy(strategy); isValid = false; errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$ createControl(parent); }
From source file:com.aptana.ide.core.ui.widgets.TextFieldEditor.java
License:Open Source License
/** * Creates a string field editor. Use the method <code>setTextLimit</code> to limit the text. * /* w ww . jav a 2 s . c om*/ * @param name * the name of the preference this field editor works on * @param labelText * the label text of the field editor * @param width * the width of the text input field in characters, or <code>UNLIMITED</code> for * no limit * @param strategy * either <code>VALIDATE_ON_KEY_STROKE</code> to perform on the fly checking (the * default), or <code>VALIDATE_ON_FOCUS_LOST</code> to perform validation only * after the text has been typed in * @param parent * the parent of the field editor's control * @param swtStyle The SWT text style commands * @since 2.0 */ public TextFieldEditor(String name, String labelText, int width, int strategy, Composite parent, int swtStyle) { init(name, labelText); widthInChars = width; setValidateStrategy(strategy); isValid = false; errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$ style = swtStyle; createControl(parent); }
From source file:com.aptana.ide.editors.internal.ui.preferences.TableViewerEditor.java
License:Open Source License
/** * Helper method to create a push button. * //from w ww.j a va2s . c o m * @param parent * the parent control * @param key * the resource name used to supply the button's label text * @return Button */ private Button createPushButton(Composite parent, String key) { Button button = new Button(parent, SWT.PUSH); button.setText(JFaceResources.getString(key)); button.setFont(parent.getFont()); GridData data = new GridData(GridData.FILL_HORIZONTAL); int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); button.addSelectionListener(getSelectionListener()); return button; }
From source file:com.axmor.eclipse.typescript.core.ui.ErrorDialog.java
License:Open Source License
@Override protected Control createMessageArea(Composite composite) { // create composite // create image Image image = getImage();//from w ww .j ava2 s . co m if (image != null) { imageLabel = new Label(composite, SWT.NULL); image.setBackground(imageLabel.getBackground()); imageLabel.setImage(image); imageLabel.getAccessible().addAccessibleListener(new AccessibleAdapter() { @Override public void getName(AccessibleEvent event) { final String accessibleMessage = JFaceResources.getString("error"); if (accessibleMessage == null) { return; } event.result = accessibleMessage; } }); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel); } // create message if (message != null) { FormToolkit toolkit = new FormToolkit(Display.getDefault()); Composite toolkitComp = toolkit.createComposite(composite); toolkitComp.setLayout(new FillLayout(SWT.HORIZONTAL | SWT.VERTICAL)); FormText text = toolkit.createFormText(toolkitComp, false); text.setText(message, true, true); text.setBackground(composite.getBackground()); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false) .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT) .applyTo(toolkitComp); text.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent event) { try { URI uri = URI.create((String) event.data); IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport() .createBrowser("error_editor_dialog"); browser.openURL(uri.toURL()); } catch (Exception e) { Activator.error(e); } } }); } return composite; }
From source file:com.bdaum.zoom.ui.preferences.AbstractPreferencePage.java
License:Open Source License
private static ToolBar createHelpImageButton(final Composite parent, Image image) { ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS); ((GridLayout) parent.getLayout()).numColumns++; toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER)); final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND); toolBar.setCursor(cursor);//from w w w .j a va 2s . c om toolBar.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { cursor.dispose(); } }); ToolItem item = new ToolItem(toolBar, SWT.NONE); item.setImage(image); item.setToolTipText(JFaceResources.getString("helpToolTip")); //$NON-NLS-1$ item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { helpPressed(parent); } }); return toolBar; }
From source file:com.blackducksoftware.integration.eclipseplugin.preferences.BlackDuckPreferences.java
License:Apache License
private StringFieldEditor createStringField(String preferenceName, String label, Composite composite, boolean integerValidation) { StringFieldEditor editor;/*w w w. j a v a2s. c o m*/ if (integerValidation) { // String field editor w/ integer validation, we can make this a separate class if we need to. editor = new StringFieldEditor(preferenceName, label, composite) { @Override protected boolean checkState() { setErrorMessage(JFaceResources.getString(INTEGER_FIELD_EDITOR_ERROR_STRING)); Text text = getTextControl(); if (text == null) { return false; } String intString = text.getText(); if (intString.isEmpty()) { clearErrorMessage(); return true; } try { Integer.valueOf(intString).intValue(); } catch (NumberFormatException nfe) { showErrorMessage(); } return false; } }; } else { editor = new StringFieldEditor(preferenceName, label, composite); } editor.setPage(this); editor.setPreferenceStore(this.getPreferenceStore()); editor.fillIntoGrid(composite, NUM_COLUMNS); editor.load(); return editor; }
From source file:com.codesourcery.internal.installer.ui.WizardDialog.java
License:Open Source License
/** * Creates and return a new wizard closing dialog without opening it. * /*www . j a v a2 s . co m*/ * @return MessageDalog */ private MessageDialog createWizardClosingDialog() { MessageDialog result = new MessageDialog(getShell(), JFaceResources.getString("WizardClosingDialog.title"), //$NON-NLS-1$ null, JFaceResources.getString("WizardClosingDialog.message"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return result; }
From source file:com.codesourcery.internal.installer.ui.WizardDialog.java
License:Open Source License
/** * Update the receiver for the new page. * /* w ww . j a v a 2 s . co m*/ * @param page */ private void updateForPage(IWizardPage page) { // ensure this page belongs to the current wizard if (wizard != page.getWizard()) { setWizard(page.getWizard()); } // ensure that page control has been created // (this allows lazy page control creation) if (page.getControl() == null) { page.createControl(pageContainer); // the page is responsible for ensuring the created control is // accessible via getControl. Assert.isNotNull(page.getControl(), JFaceResources.format(JFaceResources.getString("WizardDialog.missingSetControl"), //$NON-NLS-1$ new Object[] { page.getName() })); // ensure the dialog is large enough for this page updateSize(page); } // make the new page visible IWizardPage oldPage = currentPage; currentPage = page; currentPage.setVisible(true); if (oldPage != null) { oldPage.setVisible(false); } // update the dialog controls update(); }