List of usage examples for org.eclipse.jface.preference StringFieldEditor StringFieldEditor
public StringFieldEditor(String name, String labelText, int width, Composite parent)
From source file:at.rc.tacos.client.wizard.ConnectionLoginPage.java
License:Open Source License
/** * Callback method to create the page content and initialize it *///from w w w . j a va 2s. c om @Override public void createControl(Composite parent) { // the parent container = new Composite(parent, SWT.NULL); // the layout GridLayout layout = new GridLayout(2, false); container.setLayout(layout); // the label and the input field for the username username = new StringFieldEditor("username", "Benutzername: ", 60, container) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }; username.setEmptyStringAllowed(false); // the password field password = new StringFieldEditor("password", "Passwort: ", 60, container) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); isPageComplete(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } }; password.getTextControl(container).setEchoChar('*'); password.setEmptyStringAllowed(false); // Required to avoid an error in the system setControl(container); setPageComplete(false); }
From source file:au.gov.ansto.bragg.echidna.ui.preference.DRAPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { Label newProfileLabel = new Label(getFieldEditorParent(), SWT.NONE); newProfileLabel.setText("Configurations for data reduction"); GridDataFactory.fillDefaults().span(3, 1).grab(true, false).applyTo(newProfileLabel); final StringFieldEditor efficiencyFileText = new StringFieldEditor(PreferenceConstants.P_EFFICIENCY_FILE, "Detector efficiency file:", 40, getFieldEditorParent()); Button browseButton = new Button(getFieldEditorParent(), SWT.PUSH); browseButton.setText("Browse..."); browseButton.setToolTipText("Click to browse the file system"); addField(efficiencyFileText);//w ww.j a va2 s. co m GridDataFactory.fillDefaults().grab(true, false).applyTo(browseButton); browseButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String filename = Util.getFilenameFromShell(getShell(), "", ""); if (filename != null && filename.trim().length() > 0) { efficiencyFileText.setStringValue(filename); } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); final StringFieldEditor angularOffsetFileText = new StringFieldEditor( PreferenceConstants.P_ANGULAR_OFFSET_FILE, "Angular offset file:", 40, getFieldEditorParent()); Button browseButton2 = new Button(getFieldEditorParent(), SWT.PUSH); browseButton2.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); browseButton2.setToolTipText("Click to browse the file system"); browseButton2.setText("Browse..."); addField(angularOffsetFileText); GridDataFactory.fillDefaults().grab(true, false).applyTo(browseButton2); browseButton2.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String filename = Util.getFilenameFromShell(getShell(), "", ""); if (filename != null && filename.trim().length() > 0) { angularOffsetFileText.setStringValue(filename); } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); final ComboFieldEditor normRefCombo = new ComboFieldEditor(PreferenceConstants.P_NORM_REF, "Normalisation reference: ", new String[][] { { "bm1_counts", "bm1_counts" }, { "bm2_counts", "bm2_counts" }, { "bm3_counts", "bm3_counts" } }, getFieldEditorParent()); addField(normRefCombo); new Label(getFieldEditorParent(), SWT.NONE); final StringFieldEditor userOutputFileText = new StringFieldEditor( PreferenceConstants.P_USER_OUTPUT_DIRECTORY, "User Output Directory:", 40, getFieldEditorParent()); Button browseButton3 = new Button(getFieldEditorParent(), SWT.PUSH); browseButton3.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); browseButton3.setToolTipText("Click to browse the file system"); browseButton3.setText("Browse..."); addField(userOutputFileText); GridDataFactory.fillDefaults().grab(true, false).applyTo(browseButton3); browseButton3.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String filename = Util.selectDirectoryFromShell(getShell()); if (filename != null && filename.trim().length() > 0) { userOutputFileText.setStringValue(filename); } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); final StringFieldEditor calibrationOutputFileText = new StringFieldEditor( PreferenceConstants.P_CALIBRATION_OUTPUT_DIRECTORY, "Calibration Output Directory:", 40, getFieldEditorParent()); Button browseButton4 = new Button(getFieldEditorParent(), SWT.PUSH); browseButton4.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_HAND)); browseButton4.setToolTipText("Click to browse the file system"); browseButton4.setText("Browse..."); addField(calibrationOutputFileText); GridDataFactory.fillDefaults().grab(true, false).applyTo(browseButton4); browseButton4.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { String filename = Util.selectDirectoryFromShell(getShell()); if (filename != null && filename.trim().length() > 0) { calibrationOutputFileText.setStringValue(filename); } } @Override public void widgetDefaultSelected(SelectionEvent e) { } }); // GridDataFactory.fillDefaults().grab(false, false).span(2, 1).applyTo(normRefCombo.get); }
From source file:com.aptana.webserver.ui.preferences.LocalWebServerPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { List<String[]> addresses = new ArrayList<String[]>(); for (InetAddress i : SocketUtil.getLocalAddresses()) { addresses.add(new String[] { i.getHostAddress(), i.getHostAddress() }); }/* ww w . j a v a 2 s. co m*/ addField(new ComboFieldEditor(IWebServerPreferenceConstants.PREF_HTTP_SERVER_ADDRESS, StringUtil.makeFormLabel(Messages.LocalWebServerPreferencePage_Address_Label), addresses.toArray(new String[addresses.size()][]), getFieldEditorParent())); addField(new StringFieldEditor(IWebServerPreferenceConstants.PREF_HTTP_SERVER_PORTS, StringUtil.makeFormLabel(Messages.LocalWebServerPreferencePage_Port_Label), 11, getFieldEditorParent()) { { setErrorMessage(Messages.LocalWebServerPreferencePage_PortError_Message); setEmptyStringAllowed(true); } @Override protected boolean doCheckState() { Matcher matcher = PORTS_PATTERN.matcher(getStringValue()); if (matcher.matches()) { try { int start = Integer.parseInt(matcher.group(1)); if (matcher.group(2) != null) { int end = Integer.parseInt(matcher.group(3)); if (start < end) { return true; } } else { return true; } } catch (NumberFormatException e) { IdeLog.logError(WebServerUIPlugin.getDefault(), e); } } return false; } }); }
From source file:com.cloudbees.eclipse.ui.internal.preferences.GeneralPreferencePage.java
License:Open Source License
private void createCompositeLogin() { Group group = new Group(getFieldEditorParent(), SWT.SHADOW_ETCHED_IN); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout gl = new GridLayout(1, false); gl.marginLeft = 5;/*ww w. java 2s .c o m*/ gl.marginRight = 5; gl.marginTop = 5; gl.marginBottom = 5; gl.horizontalSpacing = 5; group.setLayout(gl); Composite groupInnerComp = new Composite(group, SWT.NONE); groupInnerComp.setLayout(new GridLayout(2, false)); groupInnerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setText(Messages.pref_group_login); final StringFieldEditor fieldEmail = new StringFieldEditor(PreferenceConstants.P_EMAIL, Messages.pref_email, 30, groupInnerComp); fieldEmail.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldEmail); final StringFieldEditor fieldPassword = new StringFieldEditor(PreferenceConstants.P_PASSWORD, Messages.pref_password, 30, groupInnerComp) { @Override protected void doLoad() { try { if (getTextControl() != null) { String value = CloudBeesUIPlugin.getDefault().readP(); getTextControl().setText(value); this.oldValue = value; } } catch (StorageException e) { // Ignore StorageException, very likely just // "No password provided." } } @Override protected void doStore() { try { CloudBeesUIPlugin.getDefault().storeP(getTextControl().getText()); } catch (Exception e) { CloudBeesUIPlugin.showError( "Saving password failed!\nPossible cause: Eclipse security master password is not set.", e); } } @Override protected void doFillIntoGrid(Composite parent, int numColumns) { super.doFillIntoGrid(parent, numColumns); getTextControl().setEchoChar('*'); } }; fieldPassword.getTextControl(groupInnerComp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); addField(fieldPassword); Composite signupAndValidateRow = new Composite(groupInnerComp, SWT.NONE); GridData signupRowData = new GridData(GridData.FILL_HORIZONTAL); signupRowData.horizontalSpan = 2; signupAndValidateRow.setLayoutData(signupRowData); GridLayout gl2 = new GridLayout(2, false); gl2.marginWidth = 0; gl2.marginHeight = 0; gl2.marginTop = 5; signupAndValidateRow.setLayout(gl2); createSignUpLink(signupAndValidateRow); Button b = new Button(signupAndValidateRow, SWT.PUSH); GridData validateButtonLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_END); validateButtonLayoutData.widthHint = 75; b.setLayoutData(validateButtonLayoutData); b.setText(Messages.pref_validate_login); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final String email = fieldEmail.getStringValue(); final String password = fieldPassword.getStringValue(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { try { monitor.beginTask("Validating CloudBees account...", 100); //TODO i18n monitor.subTask("Connecting...");//TODO i18n monitor.worked(10); GrandCentralService gcs = new GrandCentralService(); gcs.setAuthInfo(email, password); monitor.worked(20); monitor.subTask("Validating...");//TODO i18n final boolean loginValid = gcs.validateUser(monitor); monitor.worked(50); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { if (loginValid) { MessageDialog.openInformation( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation successful!");//TODO i18n } else { MessageDialog.openError( CloudBeesUIPlugin.getDefault().getWorkbench().getDisplay() .getActiveShell(), "Validation result", "Validation was not successful!\nWrong email or password?");//TODO i18n } } }); monitor.worked(20); } catch (CloudBeesException e1) { throw new RuntimeException(e1); } finally { monitor.done(); } } }); } catch (InvocationTargetException e1) { Throwable t1 = e1.getTargetException().getCause() != null ? e1.getTargetException().getCause() : e1.getTargetException(); Throwable t2 = t1.getCause() != null ? t1.getCause() : null; CloudBeesUIPlugin.showError("Failed to validate your account.", t1.getMessage(), t2); } catch (InterruptedException e1) { CloudBeesUIPlugin.showError("Failed to validate your account.", e1); } } }); }
From source file:com.ebmwebsourcing.petals.services.preferences.MavenPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); container.setLayout(layout);//w w w . java 2s . c o m container.setLayoutData(new GridData(GridData.FILL_BOTH)); // Petals Maven plug-in Group group = new Group(container, SWT.NONE); group.setLayout(new GridLayout(3, false)); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 3; layoutData.verticalIndent = 4; group.setLayoutData(layoutData); group.setText("Petals Maven plug-in"); Composite subContainer = new Composite(group, SWT.NONE); subContainer.setLayout(new GridLayout()); subContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.pluginVersionField = new StringFieldEditor(PreferencesManager.PREFS_MAVEN_PLUGIN_VERSION, "Plugin Version:", StringFieldEditor.UNLIMITED, subContainer); this.pluginVersionField.fillIntoGrid(subContainer, 3); this.pluginVersionField.setPage(this); this.pluginVersionField.setPreferenceStore(getPreferenceStore()); this.pluginVersionField.load(); this.groupIdField = new StringFieldEditor(PreferencesManager.PREFS_MAVEN_GROUP_ID, "Group ID:", StringFieldEditor.UNLIMITED, subContainer); this.groupIdField.fillIntoGrid(subContainer, 3); this.groupIdField.setPage(this); this.groupIdField.setPreferenceStore(getPreferenceStore()); this.groupIdField.load(); this.pomParentField = new FileUrlFieldEditor(PreferencesManager.PREFS_MAVEN_POM_PARENT, "POM Parent:", true, StringFieldEditor.VALIDATE_ON_KEY_STROKE, subContainer); this.pomParentField.setFileExtensions(new String[] { "*.xml" }); this.pomParentField.setPage(this); this.pomParentField.setPreferenceStore(getPreferenceStore()); this.pomParentField.load(); // Work with customized POM group = new Group(container, SWT.NONE); group.setLayout(new GridLayout(4, false)); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 3; layoutData.verticalIndent = 10; group.setLayoutData(layoutData); group.setText("POM customization"); subContainer = new Composite(group, SWT.NONE); subContainer.setLayout(new GridLayout()); subContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.defaultButton = new Button(subContainer, SWT.RADIO); this.defaultButton.setText("Use default POM"); layoutData = new GridData(); layoutData.horizontalSpan = 3; this.defaultButton.setLayoutData(layoutData); this.customizedButton = new Button(subContainer, SWT.RADIO); this.customizedButton.setText("Use customized POM"); layoutData = new GridData(); layoutData.horizontalSpan = 3; this.customizedButton.setLayoutData(layoutData); // The next field must only validate the location if it is enabled this.customizedPomLocationField = new DirectoryFieldEditor(PreferencesManager.PREFS_CUSTOMIZED_POM_LOCATION, "POM templates:", subContainer) { @Override protected boolean checkState() { boolean result = true; if (MavenPreferencePage.this.useCustomizedPom) result = super.checkState(); else clearErrorMessage(); return result; } @Override public void setEnabled(boolean enabled, Composite parent) { super.setEnabled(enabled, parent); valueChanged(); } }; this.customizedPomLocationField.setErrorMessage("The POM templates location is not a valid directory."); this.customizedPomLocationField.setPage(this); this.customizedPomLocationField.setPreferenceStore(getPreferenceStore()); this.customizedPomLocationField.load(); // Add a hyper link to generate the default POM final Link hyperlink = new Link(subContainer, SWT.NONE); hyperlink.setText("<A>Generate the default POM templates</A>"); layoutData = new GridData(SWT.TRAIL, SWT.DEFAULT, true, false); layoutData.horizontalSpan = 2; hyperlink.setLayoutData(layoutData); // Add the listeners this.customizedPomLocationField.setPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (FieldEditor.VALUE.equals(event.getProperty())) { boolean valid = MavenPreferencePage.this.customizedPomLocationField.isValid(); hyperlink.setEnabled(valid); setValid(valid); } } }); SelectionListener selectionListener = new SelectionListener() { public void widgetSelected(SelectionEvent e) { widgetDefaultSelected(e); } public void widgetDefaultSelected(SelectionEvent e) { MavenPreferencePage.this.useCustomizedPom = MavenPreferencePage.this.customizedButton .getSelection(); MavenPreferencePage.this.customizedPomLocationField.setEnabled( MavenPreferencePage.this.useCustomizedPom, MavenPreferencePage.this.customizedButton.getParent()); if (MavenPreferencePage.this.useCustomizedPom) hyperlink.setEnabled(MavenPreferencePage.this.customizedPomLocationField.isValid()); else hyperlink.setEnabled(false); } }; this.defaultButton.addSelectionListener(selectionListener); this.customizedButton.addSelectionListener(selectionListener); this.defaultButton.setSelection(!this.useCustomizedPom); this.customizedButton.setSelection(this.useCustomizedPom); this.customizedButton.notifyListeners(SWT.Selection, new Event()); hyperlink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // Get the situation File rootDirectory = new File(MavenPreferencePage.this.customizedPomLocationField.getStringValue()); File suPom = new File(rootDirectory, PetalsServicePomManager.DEFAULT_SU_POM); File saPom = new File(rootDirectory, PetalsServicePomManager.DEFAULT_SA_POM); boolean overwrite = false; if (suPom.exists() || saPom.exists()) { String msg = "Some of the default POM templates already exist.\nDo you want to overwrite them?"; overwrite = MessageDialog.openQuestion(hyperlink.getShell(), "Overwrite Templates", msg); } // Create the SU template boolean ok = true; if (!suPom.exists() || overwrite) { File tpl = getBundledTemplateFile(true); try { IoUtils.copyStream(tpl, suPom); } catch (IOException e1) { ok = false; PetalsServicesPlugin.log(e1, IStatus.ERROR); } } // Create the SA template if (!saPom.exists() || overwrite) { File tpl = getBundledTemplateFile(false); try { IoUtils.copyStream(tpl, saPom); } catch (IOException e1) { ok = false; PetalsServicesPlugin.log(e1, IStatus.ERROR); } } // Report the result if (ok) { MessageDialog.openInformation(hyperlink.getShell(), "Successful Creation", "The default POM templates were successfully created."); } else { MessageDialog.openError(hyperlink.getShell(), "Error during the Creation", "The default POM templates could not be created correctly.\nCheck the log for more details."); } } }); // Update POM dependencies automatically group = new Group(container, SWT.NONE); group.setLayout(new GridLayout()); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 3; layoutData.verticalIndent = 10; group.setLayoutData(layoutData); group.setText("POM dependencies"); subContainer = new Composite(group, SWT.NONE); subContainer.setLayout(new GridLayout()); this.autoPomUpdateField = new BooleanFieldEditor(PreferencesManager.PREFS_UPDATE_MAVEN_POM, "Update POM dependencies automatically (SA projects)", subContainer); this.autoPomUpdateField.setPage(this); this.autoPomUpdateField.setPreferenceStore(getPreferenceStore()); this.autoPomUpdateField.load(); return container; }
From source file:com.nokia.tracebuilder.preferences.GeneralPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { String formatGroupTitle = Messages.getString("GeneralPreferencePage.TraceFormatTitle"); //$NON-NLS-1$ TraceProjectAPIList apilist = TraceBuilderGlobals.getTraceModel().getExtension(TraceProjectAPIList.class); if (apilist != null) { Iterator<TraceProjectAPI> apis = apilist.getAPIs(); ArrayList<String[]> list = new ArrayList<String[]>(); while (apis.hasNext()) { TraceProjectAPI api = apis.next(); if (api.isVisibleInConfiguration()) { String name = api.getName(); String title = api.getTitle(); list.add(new String[] { title, name }); }/*w w w .j av a 2s . c om*/ } if (list.size() > 1) { String[][] formatters = new String[list.size()][]; list.toArray(formatters); addField(new RadioGroupFieldEditor(TraceBuilderConfiguration.FORMATTER_NAME, formatGroupTitle, FORMAT_COLUMNS, formatters, getFieldEditorParent(), true)); } } addField(new BooleanFieldEditor(TraceBuilderConfiguration.PRINTF_SUPPORT, Messages.getString("GeneralPreferencePage.PrintfParserSupportTitle"), //$NON-NLS-1$ getFieldEditorParent())); addField(new StringFieldEditor(TraceBuilderConfiguration.PRINTF_EXTENSION, Messages.getString("GeneralPreferencePage.PrintfMacroTitle"), //$NON-NLS-1$ StringFieldEditor.UNLIMITED, getFieldEditorParent())); }
From source file:edu.buffalo.cse.green.preferences.GreenPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *//*from ww w . j a v a 2 s. co m*/ public void createFieldEditors() { addField(new BooleanFieldEditor(P_FORCE_DIA_IN_PROJECT, "Create all diagram files in project root", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_AUTOGEN_MAIN, "Generate stubs for public static void main(String[] args)", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_AUTOGEN_SUPER_CONSTR, "Generate stubs for constructors from superclass", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_AUTOGEN_ABST_METHOD, "Generate stubs for inherited abstract methods", 0, getFieldEditorParent())); addField(new StringFieldEditor(P_GRID_SIZE, "Grid Size", 5, getFieldEditorParent())); addField(new BooleanFieldEditor(P_AUTOSAVE, "Save compilation units automatically after code modification", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_DISPLAY_RELATIONSHIP_SUBTYPES, "Show subtype names on relationship arcs", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_MANHATTAN_ROUTING, "Use Manhattan routing", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_DISPLAY_INCREMENTAL_EXPLORER_DIA, "Display Incremental Explorer Icons in Diagram Editor", 0, getFieldEditorParent())); addField( new BooleanFieldEditor(P_AUTOARRANGE, "Automatically Arrange Diagrams", 0, getFieldEditorParent())); addField(new ScaleFieldEditor(P_DRAW_LINE_WIDTH, "Relationship Line Width", getFieldEditorParent(), 0, 3, 1, 1)); adjustGridLayout(); }
From source file:edu.buffalo.cse.green.preferences.GreenPreferencePageClassBox.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *///from w w w . j a v a2s . com public void createFieldEditors() { addField(new StringFieldEditor(P_FIXED_HEIGHT, "Fixed height", 5, getFieldEditorParent())); addField(new StringFieldEditor(P_FIXED_WIDTH, "Fixed width", 5, getFieldEditorParent())); addField(new BooleanFieldEditor(P_DISPLAY_FQN_TYPE_NAMES, "Show fully-qualified type names", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_DISPLAY_METHOD_PARAMETERS, "Show method parameter names", 0, getFieldEditorParent())); addField(new BooleanFieldEditor(P_DISPLAY_ELEMENT_TOOLTIPS, "Show tooltips while hovering over elements", 0, getFieldEditorParent())); adjustGridLayout(); }
From source file:net.mldonkey.g2gui.view.pref.MLDonkeyOptions.java
License:Open Source License
/** * DOCUMENT ME!/* w w w . j a v a 2 s . com*/ */ protected void createFieldEditors() { Collections.sort( options, new OptionsComparator() ); Iterator it = options.iterator(); while ( it.hasNext() ) { parent = getFieldEditorParent(); OptionsInfo temp = ( OptionsInfo ) it.next(); if ( ( temp.getOptionType() == EnumTagType.BOOL ) || isBoolean( temp.getValue() ) ) { String description = temp.getDescription(); if ( description.equals( G2Gui.emptyString ) ) description = temp.getKey(); String optionHelp = temp.getOptionHelp(); if ( optionHelp.equals( G2Gui.emptyString ) ) optionHelp = temp.getKey(); /*create a boolean-editor and add to page*/ setupEditor( new BooleanFieldEditor( temp.getKey(), description, BooleanFieldEditor.SEPARATE_LABEL, parent ), optionHelp ); } else if ( ( temp.getOptionType() == EnumTagType.INT ) || isInteger( temp.getValue() ) ) { String description = temp.getDescription(); if ( description.equals( G2Gui.emptyString ) ) description = temp.getKey(); String optionHelp = temp.getOptionHelp(); if ( optionHelp.equals( G2Gui.emptyString ) ) optionHelp = temp.getKey(); /*create a IntegerFieldEditor and add to page * * this is kind of hacky, but i don't see another way to get the stuff * with the different-sized inputs done... */ setupEditor( new IntegerFieldEditor( temp.getKey(), description, parent ) { /* ( non-Javadoc ) * @see org.eclipse.jface.preference.StringFieldEditor# * doFillIntoGrid( org.eclipse.swt.widgets.Composite, int ) */ protected void doFillIntoGrid( Composite parent, int numColumns ) { getLabelControl( parent ); Text textField = getTextControl( parent ); GridData gd = new GridData(); gd.horizontalSpan = numColumns - 1; GC gc = new GC( textField ); try { Point extent = gc.textExtent( "X" ); gd.widthHint = inputFieldLength * extent.x; } finally { gc.dispose(); } textField.setLayoutData( gd ); } }, optionHelp ); } else { String description = temp.getDescription(); if ( description.equals( G2Gui.emptyString ) ) description = temp.getKey(); String optionHelp = temp.getOptionHelp(); if ( optionHelp.equals( G2Gui.emptyString ) ) optionHelp = temp.getKey(); // with a very long string, the pref pages looks bad. limit to inputFieldLength? setupEditor( new StringFieldEditor( temp.getKey(), description, inputFieldLength, parent ), optionHelp ); } } }
From source file:net.openchrom.msd.converter.supplier.csv.ui.preferences.PreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { addField(new SpacerFieldEditor(getFieldEditorParent())); addField(new StringFieldEditor(PreferenceSupplier.P_DELIMITER, "Delimiter character", 1, getFieldEditorParent()));//from w ww . j a va 2 s . c om addField(new BooleanFieldEditor(PreferenceSupplier.P_USE_TIC, "Export only TIC values.", getFieldEditorParent())); }