List of usage examples for org.eclipse.jface.preference StringFieldEditor StringFieldEditor
public StringFieldEditor(String name, String labelText, int width, Composite parent)
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java
License:Open Source License
private void createCertAuthSection() { ExpandableComposite section = createSection(innerComposite, Messages.AbstractRepositorySettingsPage_certificate_settings); certAuthComp = toolkit.createComposite(section, SWT.NONE); certAuthComp.setBackground(compositeContainer.getBackground()); section.setClient(certAuthComp);/*from ww w .ja v a2 s . c o m*/ certAuthButton = new Button(certAuthComp, SWT.CHECK); GridDataFactory.fillDefaults().indent(0, 5).align(SWT.LEFT, SWT.TOP).span(3, SWT.DEFAULT) .applyTo(certAuthButton); certAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_certificate_authentification); certAuthButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { setCertAuth(certAuthButton.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) { // ignore } }); certAuthFileNameEditor = new StringFieldEditor("", Messages.AbstractRepositorySettingsPage_CertificateFile_, //$NON-NLS-1$ StringFieldEditor.UNLIMITED, certAuthComp) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 2; } }; certBrowseButton = new Button(certAuthComp, SWT.PUSH); certBrowseButton.setText(Messages.AbstractRepositorySettingsPage_ChooseCertificateFile_); certBrowseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); fileDialog.setFilterPath(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$ String returnFile = fileDialog.open(); if (returnFile != null) { certAuthFileNameEditor.setStringValue(returnFile); } } }); certAuthPasswordEditor = new RepositoryStringFieldEditor("", //$NON-NLS-1$ Messages.AbstractRepositorySettingsPage_CertificatePassword_, StringFieldEditor.UNLIMITED, certAuthComp) { @Override public int getNumberOfControls() { return 2; } }; ((RepositoryStringFieldEditor) certAuthPasswordEditor).getTextControl().setEchoChar('*'); saveCertPasswordButton = new Button(certAuthComp, SWT.CHECK); saveCertPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password); certAuthFileNameEditor.setEnabled(certAuthButton.getSelection(), certAuthComp); certBrowseButton.setEnabled(certAuthButton.getSelection()); certAuthPasswordEditor.setEnabled(certAuthButton.getSelection(), certAuthComp); saveCertPasswordButton.setEnabled(certAuthButton.getSelection()); if (repository != null) { saveCertPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.CERTIFICATE)); } else { saveCertPasswordButton.setSelection(false); } setCertAuth(oldCertAuthPassword != null || oldCertAuthFileName != null); section.setExpanded(certAuthButton.getSelection()); GridLayout gridLayout2 = new GridLayout(); gridLayout2.numColumns = 3; gridLayout2.marginWidth = 0; certAuthComp.setLayout(gridLayout2); }
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java
License:Open Source License
private void createHttpAuthSection() { ExpandableComposite section = createSection(innerComposite, Messages.AbstractRepositorySettingsPage_Http_Authentication); httpAuthComp = toolkit.createComposite(section, SWT.NONE); httpAuthComp.setBackground(compositeContainer.getBackground()); section.setClient(httpAuthComp);//from www. j a v a2s. c o m httpAuthButton = new Button(httpAuthComp, SWT.CHECK); GridDataFactory.fillDefaults().indent(0, 5).align(SWT.LEFT, SWT.TOP).span(3, SWT.DEFAULT) .applyTo(httpAuthButton); httpAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_http_authentication); httpAuthButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { setHttpAuth(httpAuthButton.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) { // ignore } }); httpAuthUserNameEditor = new StringFieldEditor("", Messages.AbstractRepositorySettingsPage_User_ID_, //$NON-NLS-1$ StringFieldEditor.UNLIMITED, httpAuthComp) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 3; } }; httpAuthPasswordEditor = new RepositoryStringFieldEditor("", //$NON-NLS-1$ Messages.AbstractRepositorySettingsPage_Password_, StringFieldEditor.UNLIMITED, httpAuthComp) { @Override public int getNumberOfControls() { return 2; } }; ((RepositoryStringFieldEditor) httpAuthPasswordEditor).getTextControl().setEchoChar('*'); saveHttpPasswordButton = new Button(httpAuthComp, SWT.CHECK); saveHttpPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password); httpAuthUserNameEditor.setEnabled(httpAuthButton.getSelection(), httpAuthComp); httpAuthPasswordEditor.setEnabled(httpAuthButton.getSelection(), httpAuthComp); saveHttpPasswordButton.setEnabled(httpAuthButton.getSelection()); if (repository != null) { saveHttpPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.HTTP)); } else { saveHttpPasswordButton.setSelection(false); } setHttpAuth(oldHttpAuthPassword != null || oldHttpAuthUserId != null); section.setExpanded(httpAuthButton.getSelection()); GridLayout gridLayout2 = new GridLayout(); gridLayout2.numColumns = 3; gridLayout2.marginWidth = 0; httpAuthComp.setLayout(gridLayout2); }
From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java
License:Open Source License
private void createProxySection() { ExpandableComposite section = createSection(innerComposite, Messages.AbstractRepositorySettingsPage_Proxy_Server_Configuration); proxyAuthComp = toolkit.createComposite(section, SWT.NONE); GridLayout gridLayout2 = new GridLayout(); gridLayout2.verticalSpacing = 0;//from w w w. ja v a 2s.c o m gridLayout2.numColumns = 3; proxyAuthComp.setLayout(gridLayout2); proxyAuthComp.setBackground(compositeContainer.getBackground()); section.setClient(proxyAuthComp); Composite systemSettingsComposite = new Composite(proxyAuthComp, SWT.NULL); GridLayout gridLayout3 = new GridLayout(); gridLayout3.verticalSpacing = 0; gridLayout3.numColumns = 2; gridLayout3.marginWidth = 0; systemSettingsComposite.setLayout(gridLayout3); systemProxyButton = new Button(systemSettingsComposite, SWT.CHECK); GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).span(3, SWT.DEFAULT) .applyTo(systemSettingsComposite); systemProxyButton .setText(Messages.AbstractRepositorySettingsPage_Use_global_Network_Connections_preferences); systemProxyButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { setUseDefaultProxy(systemProxyButton.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) { // ignore } }); changeProxySettingsLink = toolkit.createHyperlink(systemSettingsComposite, Messages.AbstractRepositorySettingsPage_Change_Settings, SWT.NULL); changeProxySettingsLink.setBackground(compositeContainer.getBackground()); changeProxySettingsLink.addHyperlinkListener(new IHyperlinkListener() { public void linkActivated(HyperlinkEvent e) { PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(getShell(), PREFS_PAGE_ID_NET_PROXY, new String[] { PREFS_PAGE_ID_NET_PROXY }, null); dlg.open(); } public void linkEntered(HyperlinkEvent e) { // ignore } public void linkExited(HyperlinkEvent e) { // ignore } }); proxyHostnameEditor = new StringFieldEditor("", Messages.AbstractRepositorySettingsPage_Proxy_host_address_, //$NON-NLS-1$ StringFieldEditor.UNLIMITED, proxyAuthComp) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 3; } }; proxyHostnameEditor.setStringValue(oldProxyHostname); proxyPortEditor = new RepositoryStringFieldEditor("", //$NON-NLS-1$ Messages.AbstractRepositorySettingsPage_Proxy_host_port_, StringFieldEditor.UNLIMITED, proxyAuthComp) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 3; } }; proxyPortEditor.setStringValue(oldProxyPort); proxyHostnameEditor.setEnabled(systemProxyButton.getSelection(), proxyAuthComp); proxyPortEditor.setEnabled(systemProxyButton.getSelection(), proxyAuthComp); // ************* PROXY AUTHENTICATION ************** proxyAuthButton = new Button(proxyAuthComp, SWT.CHECK); GridDataFactory.fillDefaults().span(3, SWT.DEFAULT).applyTo(proxyAuthButton); proxyAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_proxy_authentication); proxyAuthButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { setProxyAuth(proxyAuthButton.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) { // ignore } }); proxyUserNameEditor = new StringFieldEditor("", Messages.AbstractRepositorySettingsPage_User_ID_, //$NON-NLS-1$ StringFieldEditor.UNLIMITED, proxyAuthComp) { @Override protected boolean doCheckState() { return true; } @Override protected void valueChanged() { super.valueChanged(); if (getWizard() != null) { getWizard().getContainer().updateButtons(); } } @Override public int getNumberOfControls() { return 3; } }; proxyPasswordEditor = new RepositoryStringFieldEditor("", Messages.AbstractRepositorySettingsPage_Password_, //$NON-NLS-1$ StringFieldEditor.UNLIMITED, proxyAuthComp) { @Override public int getNumberOfControls() { return 2; } }; ((RepositoryStringFieldEditor) proxyPasswordEditor).getTextControl().setEchoChar('*'); // proxyPasswordEditor.setEnabled(httpAuthButton.getSelection(), // advancedComp); // ((StringFieldEditor) // httpAuthPasswordEditor).setEnabled(httpAuthButton.getSelection(), // advancedComp); // need to increase column number here, because above string editor will use them if declared beforehand ((GridLayout) (proxyAuthComp.getLayout())).numColumns++; saveProxyPasswordButton = new Button(proxyAuthComp, SWT.CHECK); saveProxyPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password); saveProxyPasswordButton.setEnabled(proxyAuthButton.getSelection()); if (repository != null) { saveProxyPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.PROXY)); } else { saveProxyPasswordButton.setSelection(false); } setProxyAuth(oldProxyUsername != null || oldProxyPassword != null); setUseDefaultProxy(repository != null ? repository.isDefaultProxyEnabled() : true); section.setExpanded(!systemProxyButton.getSelection()); }
From source file:org.eclipse.stem.ui.preferences.VisualizationPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *///from ww w . j a v a2s. c o m @Override protected void createFieldEditors() { initialAttributeNameFieldEditor1 = new StringFieldEditor( PreferenceConstants.INITIAL_ATTRIBUTE_NAME_STRING_PREFERENCE, Messages.getString("VizPPage.InitialName1"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); initialAttributeNameFieldEditor2 = new StringFieldEditor( PreferenceConstants.INITIAL_ATTRIBUTE_NAME_STRING_PREFERENCE2, Messages.getString("VizPPage.InitialName2"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For Color Assignment foregroundColorFieldEditorDefault = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_DEFAULT, Messages.getString("VizPPage.fgcd"), getFieldEditorParent()); foregroundColorFieldEditor1 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_1, Messages.getString("VizPPage.fgc1"), getFieldEditorParent()); foregroundColorFieldEditor2 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_2, Messages.getString("VizPPage.fgc2"), getFieldEditorParent()); foregroundColorFieldEditor3 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_3, Messages.getString("VizPPage.fgc3"), getFieldEditorParent()); foregroundColorFieldEditor4 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_4, Messages.getString("VizPPage.fgc4"), getFieldEditorParent()); foregroundColorFieldEditor5 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_5, Messages.getString("VizPPage.fgc5"), getFieldEditorParent()); foregroundColorFieldEditor6 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_6, Messages.getString("VizPPage.fgc6"), getFieldEditorParent()); foregroundColorFieldEditor7 = new ColorFieldEditor(PreferenceConstants.FOREGROUND_COLOR_LABEL_7, Messages.getString("VizPPage.fgc7"), getFieldEditorParent()); // Do NOT add the label field editor for name DEFAULT // This must be hard coded and not exposed /* * foregroundLabelFieldEditorDefault = new StringFieldEditor( * PreferenceConstants.FOREGROUND_STRING_LABEL_DEFAULT, * Messages.getString("VizPPage.BGdefaultName"), * ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); */ // For label name BG1Name = S (see messages.properties) foregroundLabelFieldEditor1 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_1, Messages.getString("VizPPage.BG1Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG2Name = E (see messages.properties) foregroundLabelFieldEditor2 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_2, Messages.getString("VizPPage.BG2Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG3Name = I (see messages.properties) foregroundLabelFieldEditor3 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_3, Messages.getString("VizPPage.BG3Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG4Name = R (see messages.properties) foregroundLabelFieldEditor4 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_4, Messages.getString("VizPPage.BG4Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG5Name = P (see messages.properties) foregroundLabelFieldEditor5 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_5, Messages.getString("VizPPage.BG5Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG6Name = IR (see messages.properties) foregroundLabelFieldEditor6 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_6, Messages.getString("VizPPage.BG6Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // For label name BG7Name = IF (see messages.properties) foregroundLabelFieldEditor7 = new StringFieldEditor(PreferenceConstants.FOREGROUND_STRING_LABEL_7, Messages.getString("VizPPage.BG7Name"), ATTRIBUTE_NAME_FIELD_WIDTH, getFieldEditorParent()); // add all components addField(initialAttributeNameFieldEditor1); addField(initialAttributeNameFieldEditor2); // Add the color field editors addField(foregroundColorFieldEditorDefault); // Do NOT add the label field editor for name DEFAULT // This must be hard coded and not exposed // addField(foregroundLabelFieldEditorDefault); addField(foregroundColorFieldEditor1); addField(foregroundLabelFieldEditor1); addField(foregroundColorFieldEditor2); addField(foregroundLabelFieldEditor2); addField(foregroundColorFieldEditor3); addField(foregroundLabelFieldEditor3); addField(foregroundColorFieldEditor4); addField(foregroundLabelFieldEditor4); addField(foregroundColorFieldEditor5); addField(foregroundLabelFieldEditor5); addField(foregroundColorFieldEditor6); addField(foregroundLabelFieldEditor6); addField(foregroundColorFieldEditor7); addField(foregroundLabelFieldEditor7); }
From source file:org.eclipse.stem.ui.views.geographic.map.preferences.MapViewPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *///from w w w. j ava2 s . c om @Override protected void createFieldEditors() { backgroundColorFieldEditor = new ColorFieldEditor(PreferenceConstants.BACKGROUND_COLOR_PREFERENCE, Messages.getString("MapVPPage.bgc"), getFieldEditorParent()); foregroundColorRelativeValueZeroFieldEditor = new ColorFieldEditor( PreferenceConstants.FOREGROUND_RELATIVE_VALUE_ZERO_COLOR_PREFERENCE, Messages.getString("MapVPPage.fgrvzeroc"), getFieldEditorParent()); enableMultiColorDisplayFieldEditor = new BooleanFieldEditor( PreferenceConstants.MULTI_COLOR_DISPLAY_BOOLEAN_PREFERENCE, Messages.getString("MapVPPage.multicolordisplay"), getFieldEditorParent()); sFactorFieldEditor = new StringFieldEditor(PreferenceConstants.S_COLOR_WEIGHT_PREFERENCE, Messages.getString("MapVPPage.ScolorWeight"), FIELD_WIDTH, getFieldEditorParent()); sFactorFieldEditor.setEmptyStringAllowed(false); eFactorFieldEditor = new StringFieldEditor(PreferenceConstants.E_COLOR_WEIGHT_PREFERENCE, Messages.getString("MapVPPage.EcolorWeight"), FIELD_WIDTH, getFieldEditorParent()); eFactorFieldEditor.setEmptyStringAllowed(false); iFactorFieldEditor = new StringFieldEditor(PreferenceConstants.I_COLOR_WEIGHT_PREFERENCE, Messages.getString("MapVPPage.IcolorWeight"), FIELD_WIDTH, getFieldEditorParent()); iFactorFieldEditor.setEmptyStringAllowed(false); rFactorFieldEditor = new StringFieldEditor(PreferenceConstants.R_COLOR_WEIGHT_PREFERENCE, Messages.getString("MapVPPage.RcolorWeight"), FIELD_WIDTH, getFieldEditorParent()); rFactorFieldEditor.setEmptyStringAllowed(false); guiScalingFactorFieldEditor = new StringFieldEditor( PreferenceConstants.GUI_SCALING_FACTOR_DOUBLE_PREFERENCE, Messages.getString("MapVPPage.gsf"), FIELD_WIDTH, getFieldEditorParent()); guiScalingFactorFieldEditor.setEmptyStringAllowed(false); addField(backgroundColorFieldEditor); addField(foregroundColorRelativeValueZeroFieldEditor); addField(enableMultiColorDisplayFieldEditor); addField(sFactorFieldEditor); addField(eFactorFieldEditor); addField(iFactorFieldEditor); addField(rFactorFieldEditor); addField(guiScalingFactorFieldEditor); }
From source file:org.eclipse.stem.ui.views.geographic.preferences.GeographicPreferencePage.java
License:Open Source License
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *//* w w w .ja v a2 s . c o m*/ @Override protected void createFieldEditors() { drawPolygonBordersFieldEditor = new BooleanFieldEditor( PreferenceConstants.DRAW_POLYGON_BORDERS_BOOLEAN_PREFERENCE, Messages.getString("GeoPPage.drawpolyborders"), getFieldEditorParent()); borderColorFieldEditor = new ColorFieldEditor(PreferenceConstants.BORDER_COLOR_PREFERENCE, Messages.getString("GeoPPage.bc"), getFieldEditorParent()); logScaleFieldEditor = new BooleanFieldEditor(PreferenceConstants.LOGSCALE_BOOLEAN_PREFERENCE, Messages.getString("GeoPPage.logscale"), getFieldEditorParent()); gainFactorFieldEditor = new StringFieldEditor(PreferenceConstants.GAIN_FACTOR_PREFERENCE, Messages.getString("GeoPPage.gainf"), FIELD_WIDTH, getFieldEditorParent()); gainFactorFieldEditor.setEmptyStringAllowed(false); addField(drawPolygonBordersFieldEditor); addField(borderColorFieldEditor); addField(logScaleFieldEditor); addField(gainFactorFieldEditor); }
From source file:org.eclipse.titan.executor.preferences.ExecutorPreferencePage.java
License:Open Source License
@Override protected void createFieldEditors() { Composite parent = getFieldEditorParent(); setLogFolder = new BooleanFieldEditor(PreferenceConstants.SET_LOG_FOLDER, PreferenceConstants.SET_LOG_FOLDER_LABEL, parent); addField(setLogFolder);// w w w. ja v a 2s . c o m logFolderPath = new StringFieldEditor(PreferenceConstants.LOG_FOLDER_PATH_NAME, PreferenceConstants.LOG_FOLDER_PATH_LABEL, StringFieldEditor.UNLIMITED, parent); addField(logFolderPath); deleteLogFiles = new BooleanFieldEditor(PreferenceConstants.DELETE_LOG_FILES_NAME, PreferenceConstants.DELETE_LOG_FILES_LABEL, parent); addField(deleteLogFiles); automaticMerge = new BooleanFieldEditor(PreferenceConstants.AUTOMATIC_MERGE_NAME, PreferenceConstants.AUTOMATIC_MERGE_LABEL, parent); addField(automaticMerge); }
From source file:org.fastcode.preferences.CreateSimilarPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common * GUI blocks needed to manipulate various types of preferences. Each field * editor knows how to save and restore itself. *//*from ww w.j a v a 2s. c o m*/ @Override public void createFieldEditors() { this.project = getPreferenceStore().getString(getPreferenceLabel(P_PROJECT, this.preferenceId)); String configItems = null; final GlobalSettings globalSettings = getInstance(); final String classType = getPreferenceStoreValueString(P_CLASS_TYPE, this.preferenceId); final boolean isClass = CLASS_TYPE.getClassType(classType) == CLASS_TYPE.CLASS; if (getPreferenceStore().contains(getPreferenceLabel(P_CONFIG_ITEMS, this.preferenceId))) { configItems = getPreferenceStore().getString(getPreferenceLabel(P_CONFIG_ITEMS, this.preferenceId)); } String[] configItemArr = null; if (!isEmpty(configItems)) { configItemArr = configItems.split(COLON); } this.numConfigs = configItemArr == null ? this.numMaxConfigs : configItemArr.length; if (!isCreateNew()) { this.fromPattern = new StringFieldEditor(getPreferenceLabel(P_FROM_PATTERN, this.preferenceId), "From Clasees :", 60, getFieldEditorParent()); this.fromPattern.setEmptyStringAllowed(false); addField(this.fromPattern); } if (!isClass) { new Separator(SWT.SEPARATOR | SWT.HORIZONTAL).doFillIntoGrid(getFieldEditorParent(), 10, convertHeightInCharsToPixels(2)); } this.toPattern = new StringFieldEditor(getPreferenceLabel(P_TO_PATTERN, this.preferenceId), "To classes :", 40, getFieldEditorParent()); this.toPattern.setEmptyStringAllowed(false); addField(this.toPattern); this.classTypeRadio = new RadioGroupFieldEditor(getPreferenceLabel(P_CLASS_TYPE, this.preferenceId), "This is a : ", CLASS_CHOICE_TYPES.length, CLASS_CHOICE_TYPES, getFieldEditorParent(), true); addField(this.classTypeRadio); this.classTypeRadio.setEnabled(false, getFieldEditorParent()); final String[][] projects = getAllProjects(); this.projectComboList = new ComboFieldEditor(getPreferenceLabel(P_PROJECT, this.preferenceId), "Project:", projects, getFieldEditorParent()); addField(this.projectComboList); if (!globalSettings.isUseDefaultForPath()) { // String[][] sourcePaths = // getSourcePathsForProject(getPreferenceStore().getString(getPreferenceLabel(P_PROJECT, // preferenceId))); final String[][] sourcePaths = getAllSourcePathsInWorkspace(); this.sourceComboList = new ComboFieldEditor(getPreferenceLabel(P_SOURCE_PATH, this.preferenceId), "Source Paths:", sourcePaths, getFieldEditorParent()); addField(this.sourceComboList); } if (isCreateNew()) { this.packageFieldEditor = new StringButtonFieldEditor(getPreferenceLabel(P_PACKAGE, this.preferenceId), "Package :", getFieldEditorParent()) { @Override protected String changePressed() { try { final IJavaProject javaProject = getJavaProject(CreateSimilarPreferencePage.this.project); final SelectionDialog selectionDialog = JavaUI.createPackageDialog(getShell(), javaProject, 0, EMPTY_STR); final int ret = selectionDialog.open(); if (ret == Window.CANCEL) { return null; } final IPackageFragment packageFragment = (IPackageFragment) selectionDialog.getResult()[0]; return packageFragment.getElementName(); } catch (final JavaModelException e) { e.printStackTrace(); } return null; } }; // final IJavaProject javaProject = // getJavaProject(CreateSimilarPreferencePage.this.project); // this.packageFieldEditor = new // FastCodeListEditor(getPreferenceLabel(P_PACKAGE, // this.preferenceId), "Package", getFieldEditorParent(), // IJavaElement.PACKAGE_FRAGMENT, javaProject); addField(this.packageFieldEditor); this.packageFieldEditor.setEnabled(!isEmpty(CreateSimilarPreferencePage.this.project), getFieldEditorParent()); } // classBodyPattern = new // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_BODY_PATTERN, // preferenceId), "To Class Pattern :", getFieldEditorParent()); // addField(classBodyPattern); // new // AutoCompleteField(classBodyPattern.getTextControl(getFieldEditorParent()), // new TextContentAdapter(), keyWords); if (!isForValueBeans()) { if (!isClass) { this.createImplCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_IMPLEMENT_INT, this.preferenceId), "Create an &Implementation of above interface :", getFieldEditorParent()); addField(this.createImplCheckBox); this.implSubPkg = new StringFieldEditor(getPreferenceLabel(P_IMPL_SUB_PACKAGE, this.preferenceId), "Implementation &Sub Package :", 10, getFieldEditorParent()); addField(this.implSubPkg); this.implSubPkg.setEnabled( getPreferenceStore().getBoolean(getPreferenceLabel(P_IMPLEMENT_INT, this.preferenceId)), getFieldEditorParent()); } this.finalCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_FINAL_CLASS, this.preferenceId), "Make this Class final :", getFieldEditorParent()); addField(this.finalCheckBox); if (this.preferenceId.equals(CREATE_NEW_PREFERENCE_SERVICE_ID)) { this.finalCheckBox.setEnabled(false, getFieldEditorParent()); } // this.classHeader = new // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_HEADER, // preferenceId), "Code Before Class (Header) :", // getFieldEditorParent()); // addField(this.classHeader); this.classInsideBody = new MultiStringFieldEditor( getPreferenceLabel(P_CLASS_INSIDE_BODY, this.preferenceId), "Code In the Class (&Body) :", getFieldEditorParent()); addField(this.classInsideBody); this.implSuperClass = new FastCodeListEditor(getPreferenceLabel(P_SUPER_CLASS, this.preferenceId), "Implementation &Super Class :", getFieldEditorParent(), IJavaElementSearchConstants.CONSIDER_CLASSES, null); addField(this.implSuperClass); // this.implSuperClass.setEnabled(getPreferenceStore().getBoolean(getPreferenceLabel(P_IMPLEMENT_INTERFACES, // preferenceId)), getFieldEditorParent()); //this.implSuperClass.setChangeButtonText(BUTTON_TEXT_BROWSE); this.interfaces = new FastCodeListEditor(getPreferenceLabel(P_IMPLEMENT_INTERFACES, this.preferenceId), "Interfaces To &Implement:", getFieldEditorParent(), CONSIDER_INTERFACES, null); addField(this.interfaces); this.classImports = new FastCodeListEditor(getPreferenceLabel(P_CLASS_IMPORTS, this.preferenceId), "Clases To I&mport:", getFieldEditorParent(), CONSIDER_ALL_TYPES, null); addField(this.classImports); this.inclInstanceCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_INCLUDE_INSTACE_FROM, this.preferenceId), "Include an in&stance of the from class :", getFieldEditorParent()); addField(this.inclInstanceCheckBox); this.inclInstanceCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent()); this.createDefaultConstructor = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_DEFAULT_CONSTRUCTOR, this.preferenceId), "Create Default Co&nstructor :", getFieldEditorParent()); addField(this.createDefaultConstructor); this.createInstanceConstructor = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_INSTANCE_CONSTRUCTOR, this.preferenceId), "Create Instance Co&nstructor :", getFieldEditorParent()); addField(this.createInstanceConstructor); this.inclGetterSetterCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_INCLUDE_GETTER_SETTER_INSTACE_FROM, this.preferenceId), "Generate &getter/setters for private fields :", getFieldEditorParent()); addField(this.inclGetterSetterCheckBox); this.copyMethodCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_COPY_METHODS, this.preferenceId), "Copy &methods from the from Class", getFieldEditorParent()); addField(this.copyMethodCheckBox); this.copyMethodCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent()); this.createMethodBody = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_METHOD_BODY, this.preferenceId), "Create &method Body", getFieldEditorParent()); addField(this.createMethodBody); this.createMethodBody.setEnabled(!isCreateNew(), getFieldEditorParent()); this.addionalFieldsCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_FIELDS, this.preferenceId), "Create &Additional Fields", getFieldEditorParent()); addField(this.addionalFieldsCheckBox); this.addionalFieldsNameField = new StringFieldEditor( getPreferenceLabel(P_CREATE_FIELDS_NAME, this.preferenceId), "Name/Pattern for &Additional Fields", getFieldEditorParent()); addField(this.addionalFieldsNameField); this.includePattern = new StringFieldEditor(getPreferenceLabel(P_INCLUDE_PATTERN, this.preferenceId), "Include Methods/Fields:", 20, getFieldEditorParent()); addField(this.includePattern); this.includePattern.setEnabled(!isCreateNew(), getFieldEditorParent()); this.excludePattern = new StringFieldEditor(getPreferenceLabel(P_EXCLUDE_PATTERN, this.preferenceId), "Exclude Methods/Fields:", 20, getFieldEditorParent()); addField(this.excludePattern); this.excludePattern.setEnabled(!isCreateNew(), getFieldEditorParent()); this.classAnnotations = new FastCodeListEditor( getPreferenceLabel(P_CLASS_ANNOTATIONS, this.preferenceId), "Class &Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.classAnnotations); this.fieldAnnotations = new FastCodeListEditor( getPreferenceLabel(P_FIELD_ANNOTATIONS, this.preferenceId), "Field &Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.fieldAnnotations); this.methodAnnotations = new FastCodeListEditor( getPreferenceLabel(P_METHOD_ANNOTATIONS, this.preferenceId), "Method &Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.methodAnnotations); /* this.assignReturnCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_RETURN_VARIABLE, this.preferenceId), "Assign &return type to a variable :", getFieldEditorParent()); addField(this.assignReturnCheckBox); this.assignReturnCheckBox.setEnabled(!isCreateNew(),getFieldEditorParent()); this.returnVariableName = new StringFieldEditor(getPreferenceLabel(P_RETURN_VARIABLE_NAME, this.preferenceId), "&Return variable name :", 20, getFieldEditorParent()); this.returnVariableName.setEmptyStringAllowed(!this.assignReturnCheckBox.getBooleanValue()); addField(this.returnVariableName); this.returnVariableName.setEnabled(!isCreateNew(),getFieldEditorParent());*/ this.convertMethodParamCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_CONVERT_METHOD_PARAM, this.preferenceId), "Convert Method &Parameter:", getFieldEditorParent()); addField(this.convertMethodParamCheckBox); this.convertMethodParamCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent()); this.convertMethodParamFromField = new StringFieldEditor( getPreferenceLabel(P_CONVERT_METHOD_PARAM_FROM, this.preferenceId), "Convert Method &Parameter From :", 50, getFieldEditorParent()); addField(this.convertMethodParamFromField); this.convertMethodParamFromField.setEnabled(!isCreateNew(), getFieldEditorParent()); this.convertMethodParamToField = new StringFieldEditor( getPreferenceLabel(P_CONVERT_METHOD_PARAM_TO, this.preferenceId), "Convert Method &Parameter To :", 50, getFieldEditorParent()); addField(this.convertMethodParamToField); this.convertMethodParamToField.setEnabled(!isCreateNew(), getFieldEditorParent()); this.createUnitTestCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_UNIT_TEST, this.preferenceId), "Create &Unit Test of the Target Class:", getFieldEditorParent()); addField(this.createUnitTestCheckBox); this.createUnitTestCheckBox.setEnabled(false, getFieldEditorParent()); } else { // classHeader = new // MultiStringFieldEditor(getPreferenceLabel(P_CLASS_HEADER, // preferenceId), "Code Before Class (Header) :", // getFieldEditorParent()); // addField(classHeader); this.finalCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_FINAL_CLASS, this.preferenceId), "Make this Class final :", getFieldEditorParent()); addField(this.finalCheckBox); this.classInsideBody = new MultiStringFieldEditor( getPreferenceLabel(P_CLASS_INSIDE_BODY, this.preferenceId), "Code In the Class (&Body) :", getFieldEditorParent()); addField(this.classInsideBody); this.implSuperClass = new FastCodeListEditor(getPreferenceLabel(P_SUPER_CLASS, this.preferenceId), "Implementation &Super Class :", getFieldEditorParent(), IJavaElementSearchConstants.CONSIDER_CLASSES, null); addField(this.implSuperClass); this.interfaces = new FastCodeListEditor(getPreferenceLabel(P_IMPLEMENT_INTERFACES, this.preferenceId), "Interfaces To &Implement:", getFieldEditorParent(), CONSIDER_INTERFACES, null); addField(this.interfaces); this.classImports = new FastCodeListEditor(getPreferenceLabel(P_CLASS_IMPORTS, this.preferenceId), "Clases To I&mport:", getFieldEditorParent(), CONSIDER_ALL_TYPES, null); addField(this.classImports); this.createDefaultConstructor = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_DEFAULT_CONSTRUCTOR, this.preferenceId), "Create Default &Constructor :", getFieldEditorParent()); addField(this.createDefaultConstructor); this.createInstanceConstructor = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_INSTANCE_CONSTRUCTOR, this.preferenceId), "Create Instance &Constructor :", getFieldEditorParent()); addField(this.createInstanceConstructor); this.copyFieldsCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_COPY_FIELDS, this.preferenceId), "Copy &Fields from the from Class :", getFieldEditorParent()); addField(this.copyFieldsCheckBox); this.copyFieldsCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent()); this.breakDateFieldsCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_BREAK_DATE_FIELDS, this.preferenceId), "Break &Date Fields :", getFieldEditorParent()); addField(this.breakDateFieldsCheckBox); this.breakDateFieldsCheckBox.setEnabled(!isCreateNew(), getFieldEditorParent()); this.classAnnotations = new FastCodeListEditor( getPreferenceLabel(P_CLASS_ANNOTATIONS, this.preferenceId), "Class &Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.classAnnotations); this.fieldAnnotations = new FastCodeListEditor( getPreferenceLabel(P_FIELD_ANNOTATIONS, this.preferenceId), "Field &Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.fieldAnnotations); this.includePattern = new StringFieldEditor(getPreferenceLabel(P_INCLUDE_PATTERN, this.preferenceId), "Include Methods/Fields:", getFieldEditorParent()); addField(this.includePattern); this.excludePattern = new StringFieldEditor(getPreferenceLabel(P_EXCLUDE_PATTERN, this.preferenceId), "Exclude Methods/Fields:", getFieldEditorParent()); addField(this.excludePattern); } this.createWorkingSetCheckBox = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_WORKING_SET, this.preferenceId), "Automatically Create a Working Set :", 30, getFieldEditorParent()); addField(this.createWorkingSetCheckBox); this.workingSetName = new StringFieldEditor(getPreferenceLabel(P_WORKING_SET_NAME, this.preferenceId), "Working Set Name :", 30, getFieldEditorParent()); addField(this.workingSetName); final String[][] configTypes = new String[this.configPattern.getConfigs().length][2]; for (int k = 0; k < configTypes.length; k++) { configTypes[k][0] = configTypes[k][1] = this.configPattern.getConfigs()[k].getConfigType(); } final String[][] configFileConvTypes = new String[4][2]; configFileConvTypes[0][0] = configFileConvTypes[0][1] = CONVERSION_NONE; configFileConvTypes[1][0] = configFileConvTypes[1][1] = CONVERSION_LOWER_CASE; configFileConvTypes[2][0] = configFileConvTypes[2][1] = CONVERSION_CAMEL_CASE; configFileConvTypes[3][0] = configFileConvTypes[3][1] = CONVERSION_CAMEL_CASE_HYPHEN; // Create the configuration file items. for (int configCount = 0; configCount < this.numMaxConfigs; configCount++) { final String configType = this.configPattern.getConfigs()[configCount].getConfigType(); if (!(isStringInArray(configType, configItemArr) || isStringInArray(configType, this.configPattern.getConfigTypes().get(this.preferenceId)))) { continue; } new Separator(SWT.SEPARATOR | SWT.HORIZONTAL).doFillIntoGrid(getFieldEditorParent(), 100, convertHeightInCharsToPixels(2)); this.createConfigCheckBox[configCount] = new BooleanFieldEditor( getPreferenceLabel(P_CREATE_CONFIG, this.preferenceId) + configCount, "Create configuration file :", getFieldEditorParent()); addField(this.createConfigCheckBox[configCount]); final boolean enableConfigParts = getPreferenceStore() .getBoolean(getPreferenceLabel(P_CREATE_CONFIG, this.preferenceId) + configCount); FieldEditor fieldEditor; fieldEditor = createRadioGroupFieldEditor( getPreferenceLabel(P_CONFIG_TYPE, this.preferenceId) + configCount, "Configuration Type", this.configPattern.getConfigs().length, configTypes, getFieldEditorParent(), true); this.createSimilarConfigurationPart.setConfigTypeRadio(configCount, (RadioGroupFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(false, getFieldEditorParent()); fieldEditor = createStringFieldEditor( getPreferenceLabel(P_CONFIG_LOCATION, this.preferenceId) + configCount, "Configuration Location :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigLocation(configCount, (StringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); // ((StringFieldEditor)fieldEditor).setEmptyStringAllowed(enableConfigParts // ? false : true); fieldEditor = createStringFieldEditor( getPreferenceLabel(P_CONFIG_FILE_NAME, this.preferenceId) + configCount, "Configuration File Name :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigFile(configCount, (StringFieldEditor) fieldEditor); // configFile[configCount] = new // StringFieldEditor(getPreferenceLabel(P_CONFIG_FILE_NAME, // preferenceId)+configCount, "Configuration File Name :", // getFieldEditorParent()); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); ((StringFieldEditor) fieldEditor).setEmptyStringAllowed(enableConfigParts ? false : true); fieldEditor = new RadioGroupFieldEditor( getPreferenceLabel(P_CONFIG_FILE_CONV_TYPES, this.preferenceId) + configCount, "Convert the File Name :", configFileConvTypes.length, configFileConvTypes, getFieldEditorParent(), true); this.createSimilarConfigurationPart.setConfigFileNameConversion(configCount, (RadioGroupFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); if (!isEmpty(this.configPattern.getConfigs()[configCount].getConfigLocale())) { fieldEditor = new StringFieldEditor( getPreferenceLabel(P_CONFIG_LOCALE, this.preferenceId) + configCount, "Configuration Locale :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigLocale(configCount, (StringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); } fieldEditor = createMultiStringFieldEditor( getPreferenceLabel(P_CONFIG_HEADER_PATTERN, this.preferenceId) + configCount, "Configuration Header :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigHeaderPattern(configCount, (MultiStringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); fieldEditor = createMultiStringFieldEditor( getPreferenceLabel(P_CONFIG_START_PATTERN, this.preferenceId) + configCount, "Configuration Start :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigStartPattern(configCount, (MultiStringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); fieldEditor = createStringFieldEditor( getPreferenceLabel(P_CONFIG_END_PATTERN, this.preferenceId) + configCount, "Configuration End :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigEndPattern(configCount, (StringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); fieldEditor = createMultiStringFieldEditor( getPreferenceLabel(P_CONFIG_PATTERN, this.preferenceId) + configCount, "Configuration Pattern :", getFieldEditorParent()); this.createSimilarConfigurationPart.setConfigBodyPattern(configCount, (MultiStringFieldEditor) fieldEditor); addField(fieldEditor); fieldEditor.setEnabled(enableConfigParts, getFieldEditorParent()); ((MultiStringFieldEditor) fieldEditor).setEmptyStringAllowed(enableConfigParts ? false : true); } this.removeConfigCheckBox = new BooleanFieldEditor(getPreferenceLabel(P_REMOVE_CONFIG, this.preferenceId), "Remove unused configurations :", BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent()); if (this.numConfigs > 1) { // removeConfig should be always off. addField(this.removeConfigCheckBox); getPreferenceStore().setValue(getPreferenceLabel(P_REMOVE_CONFIG, this.preferenceId), false); this.removeConfigCheckBox.load(); } final Button restoreConfigButton = new Button(getFieldEditorParent(), SWT.PUSH); restoreConfigButton.setText("Restore configurations"); if (this.numConfigs == this.numMaxConfigs) { restoreConfigButton.setEnabled(false); } restoreConfigButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final MessageDialogWithToggle dialogWithToggle = MessageDialogWithToggle.openYesNoQuestion( CreateSimilarPreferencePage.this.getShell(), "Restore configurations", "Restore configurations, this will close the preference dialog, You have reopen it.", "Remember Decision", false, CreateSimilarPreferencePage.this.getPreferenceStore(), getPreferenceLabel(P_RESTORE_CONFIG_ITEMS, CreateSimilarPreferencePage.this.preferenceId)); if (dialogWithToggle.getReturnCode() != MESSAGE_DIALOG_RETURN_YES) { return; } CreateSimilarPreferencePage.this.getPreferenceStore().setValue( getPreferenceLabel(P_CONFIG_ITEMS, CreateSimilarPreferencePage.this.preferenceId), ""); CreateSimilarPreferencePage.this.getShell().close(); // getShell().open(); } }); }
From source file:org.fastcode.preferences.JUnitPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common * GUI blocks needed to manipulate various types of preferences. Each field * editor knows how to save and restore itself. *//*from w w w . ja va 2 s.com*/ @Override public void createFieldEditors() { // getFieldEditorParent().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); // applyFont(); this.junitProfiles = new ComboFieldEditor(P_JUNIT_TEST_PROFILE, "JUnit Test Profiles:", this.allTestProfiles, getFieldEditorParent()); addField(this.junitProfiles); this.createNewProfCheckBox = new BooleanFieldEditor(P_JUNIT_CREATE_NEW_PROF, "Create A New Profile :", getFieldEditorParent()); addField(this.createNewProfCheckBox); this.deleteCurrentProfCheckBox = new BooleanFieldEditor(P_JUNIT_DELETE_CURR_PROF, "Delete Current Profile :", getFieldEditorParent()); addField(this.deleteCurrentProfCheckBox); if (this.allTestProfiles.length == 1) { this.deleteCurrentProfCheckBox.setEnabled(false, getFieldEditorParent()); } this.junitProfileName = new StringFieldEditor(getPreferenceName(P_JUNIT_PROFILE_NAME), "Junit Test Profile Name :", 30, getFieldEditorParent()); addField(this.junitProfileName); this.junitProfileName.setEnabled(false, getFieldEditorParent()); //this.junitProfileName.setEmptyStringAllowed(false); this.junitProfilePattern = new StringFieldEditor(getPreferenceName(P_JUNIT_PROFILE_PATTERN), "Class Name Pattern :", 30, getFieldEditorParent()); addField(this.junitProfilePattern); this.junitProfilePattern.setEnabled(false, getFieldEditorParent()); //this.junitProfilePattern.setEmptyStringAllowed(false); final GlobalSettings globalSettings = getInstance(); final String[][] junitTypes = { { "Junit 4", P_JUNIT_TYPE_4 }, { "Junit 3", P_JUNIT_TYPE_3 }, { "TestNG", P_JUNIT_TYPE_TESTNG }, { "Custom", P_JUNIT_TYPE_CUSTOM } }; this.junitTypeRadio = new RadioGroupFieldEditor(getPreferenceName(P_JUNIT_TYPE), "Junit Type", 4, junitTypes, getFieldEditorParent(), true); addField(this.junitTypeRadio); this.junitTestClass = new StringFieldEditor(getPreferenceName(P_JUNIT_TEST_CLASS), "Junit Test Class Name :", 30, getFieldEditorParent()); addField(this.junitTestClass); this.junitTestClass.setEmptyStringAllowed(false); this.junitTestMethod = new StringFieldEditor(getPreferenceName(P_JUNIT_TEST_METHOD), "Junit Test Method Name :", 30, getFieldEditorParent()); addField(this.junitTestMethod); this.junitTestMethod.setEmptyStringAllowed(false); this.junitSuperClass = new StringButtonFieldEditor(getPreferenceName(P_BASE_TEST), "Base Test Class :", getFieldEditorParent()) { @Override protected String changePressed() { setTextLimit(200); try { final SelectionDialog selectionDialog = createTypeDialog(getShell(), null, createWorkspaceScope(), CONSIDER_CLASSES, false, "*TestCase"); if (selectionDialog.open() == SWT.CANCEL) { return EMPTY_STR; } final IType type = (IType) selectionDialog.getResult()[0]; JUnitPreferencePage.this.override = true; if (!isJunitTest(type)) { openError(getShell(), "Error", "This is not valid base class for Junit Tests. Please try again."); return EMPTY_STR; } return type.getFullyQualifiedName(); } catch (final JavaModelException e) { e.printStackTrace(); } return EMPTY_STR; } }; //this.junitSuperClass.setEmptyStringAllowed(false); this.junitSuperClass.setChangeButtonText(BUTTON_TEXT_BROWSE); addField(this.junitSuperClass); if (this.junitType.equals(P_JUNIT_TYPE_4)) { this.junitSuperClass.setEnabled(false, getFieldEditorParent()); } // this.showAllCheckBox = new BooleanFieldEditor(getPreferenceName(P_JUNIT_SHOW_ALL_PATHS), "Show All Paths", getFieldEditorParent()); // addField(this.showAllCheckBox); // boolean showAll = preferenceStore.getBoolean(P_JUNIT_SHOW_ALL_PATHS); // if (showAll) { // entryNamesAndValues = getAllSourcePaths(null); // } final String[][] projects = getAllProjects(); this.projectComboList = new ComboFieldEditor(getPreferenceName(P_JUNIT_TEST_PROJECT), "Project:", projects, getFieldEditorParent()); addField(this.projectComboList); final String[][] entryNamesAndValues = getSourcePathsForProject( this.preferenceStore.getString(getPreferenceName(P_JUNIT_TEST_PROJECT))); this.junitLocation = new ComboFieldEditor(getPreferenceName(P_JUNIT_TEST_LOCATION), "Test Location:", entryNamesAndValues, getFieldEditorParent()); addField(this.junitLocation); this.junitLocation.setEnabled(!globalSettings.isUseDefaultForPath(), getFieldEditorParent()); this.createInstance = new BooleanFieldEditor(getPreferenceName(P_JUNIT_ALWAYS_CREATE_INSTANCE), "Always Create an Instance at Class Level", getFieldEditorParent()); addField(this.createInstance); this.fieldAnnotations = new FastCodeListEditor(getPreferenceName(P_JUNIT_FIELD_ANNOTATIONS), "Field Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.fieldAnnotations); // this.junitTestFormat = new MultiStringFieldEditor(getPreferenceName(P_JUNIT_TEST_FORMAT), "Test Test Format:", getFieldEditorParent()); // addField(this.junitTestFormat); //((StringFieldEditor)junitTestFormat).setEmptyStringAllowed(false); this.classImports = new FastCodeListEditor(getPreferenceName(P_JUNIT_CLASS_IMPORTS), "Clases To Import:", getFieldEditorParent(), CONSIDER_ALL_TYPES, null); addField(this.classImports); this.classInsideBody = new MultiStringFieldEditor(getPreferenceName(P_JUNIT_CLASS_INSIDE_BODY), "Code Inside Class :", getFieldEditorParent()); addField(this.classInsideBody); this.classAnnotations = new FastCodeListEditor(getPreferenceName(P_JUNIT_CLASS_ANNOTATIONS), "Class Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.classAnnotations); this.methodAnnotations = new FastCodeListEditor(getPreferenceName(P_JUNIT_METHOD_ANNOTATIONS), "Test Method Annotations:", getFieldEditorParent(), CONSIDER_ANNOTATION_TYPES, null); addField(this.methodAnnotations); this.methodComment = new StringFieldEditor(getPreferenceName(P_JUNIT_METHOD_COMMENT), "Test Method Comment:", 60, getFieldEditorParent()); addField(this.methodComment); this.junitCreateMethodBody = new BooleanFieldEditor(getPreferenceName(P_JUNIT_CREATE_METHOD_BODY), "Create Method Body", getFieldEditorParent()); addField(this.junitCreateMethodBody); /*this.junitAlwaysCreateTryCatch = new BooleanFieldEditor(getPreferenceName(P_JUNIT_ALWAYS_CREATE_TRY_CATCH), "Always Create Try Catch Block", getFieldEditorParent()); addField(this.junitAlwaysCreateTryCatch);*/ this.exceptionBody = new MultiStringFieldEditor(getPreferenceName(P_JUNIT_EXCEPTION_BODY), "Body in the Catch Block (for happy tests)", getFieldEditorParent()); addField(this.exceptionBody); this.negativeBody = new MultiStringFieldEditor(getPreferenceName(P_JUNIT_NEGATIVE_BODY), "Test body for negative tests :", getFieldEditorParent()); addField(this.negativeBody); createImportExportButtons(getFieldEditorParent()); }
From source file:org.fhsolution.eclipse.plugins.csvedit.customeditor.preferences.CSVPreferencePage.java
License:Apache License
/** * Creates the field editors. Field editors are abstractions of the common * GUI blocks needed to manipulate various types of preferences. Each field * editor knows how to save and restore itself. * * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() *//*from w w w . j a v a 2s . c o m*/ public void createFieldEditors() { String[][] pagesLabelsAndValues = new String[2][2]; pagesLabelsAndValues[0][0] = "Table"; pagesLabelsAndValues[0][1] = "0"; pagesLabelsAndValues[1][0] = "Source"; pagesLabelsAndValues[1][1] = "1"; addField(new ComboFieldEditor(PreferenceConstants.DEFAULT_VIEW_PAGE, "Select the default tab to view csv file:", pagesLabelsAndValues, getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.USE_FIRST_LINE_AS_HEADER, "&Use the first line of the CSV file as the column headers", getFieldEditorParent())); StringFieldEditor customDelimiterField = new StringFieldEditor(PreferenceConstants.CUSTOM_DELIMITER, "Choose the delimiter to use:", 2, getFieldEditorParent()); customDelimiterField.setTextLimit(1); customDelimiterField.setEmptyStringAllowed(false); addField(customDelimiterField); StringFieldEditor textQualifierChar = new StringFieldEditor(PreferenceConstants.TEXT_QUALIFIER, "Define the character used as a text qualifier of the data:", 2, getFieldEditorParent()); customDelimiterField.setTextLimit(1); customDelimiterField.setEmptyStringAllowed(false); addField(textQualifierChar); addField(new BooleanFieldEditor(PreferenceConstants.USE_QUALIFIER, "For the text qualifier to be used for all fields", getFieldEditorParent())); StringFieldEditor commentChar = new StringFieldEditor(PreferenceConstants.COMMENT_CHAR, "Choose the character to use as a comment:", 2, getFieldEditorParent()); customDelimiterField.setTextLimit(1); customDelimiterField.setEmptyStringAllowed(true); addField(commentChar); addField(new BooleanFieldEditor(PreferenceConstants.CASE_SENSITIVE_SEARCH, "&make filtering case sensitive", getFieldEditorParent())); }