private void createBooleanFieldEditor( Composite parent, String label, String preferenceName ) { FieldEditor editor = new BooleanFieldEditor( preferenceName, label, parent ); addField( editor ); } }
protected void doFillIntoGrid(Composite parent, int numColumns) { String text = getLabelText(); switch (style) { case SEPARATE_LABEL: getLabelControl(parent); numColumns--; text = null; //$FALL-THROUGH$ default: checkBox = getChangeControl(parent); GridData gd = new GridData(); gd.horizontalSpan = numColumns; checkBox.setLayoutData(gd); if (text != null) { checkBox.setText(text); } } }
@Override protected Control createDialogArea(Composite parent) { Composite top = (Composite) super.createDialogArea(parent); Composite editArea = new Composite(top, SWT.NONE); editArea.setLayout(new GridLayout()); editArea.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); verboseEditor = new BooleanFieldEditor("verbose", ProgressMessages.JobsViewPreferenceDialog_Note, editArea);//$NON-NLS-1$ verboseEditor.setPreferenceName(IWorkbenchPreferenceConstants.SHOW_SYSTEM_JOBS); verboseEditor.setPreferenceStore(PrefUtil.getAPIPreferenceStore()); verboseEditor.load(); Dialog.applyDialogFont(top); return top; }
/** * Returns the control responsible for displaying this field editor's label. * This method can be used to set a tooltip for a * <code>BooleanFieldEditor</code>. Note that the normal pattern of * <code>getLabelControl(parent).setToolTipText(tooltipText)</code> does not * work for boolean field editors, as it can lead to duplicate text (see bug * 259952). * * @param parent * the parent composite * @return the control responsible for displaying the label * * @since 3.5 */ public Control getDescriptionControl(Composite parent) { if (style == SEPARATE_LABEL) { return getLabelControl(parent); } return getChangeControl(parent); }
private void updateFieldEnablement() { boolean arePotentialMatchesIgnored= fIgnorePotentialMatchesCheckbox.getBooleanValue(); fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored, getFieldEditorParent()); fColorEditor.setEnabled(!arePotentialMatchesIgnored && fEmphasizedCheckbox.getBooleanValue(), getFieldEditorParent()); }
/** * 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. */ public void createFieldEditors() { clangFormatPath = new FileFieldEditor(CppStyleConstants.CLANG_FORMAT_PATH, "Clang-format path:", getFieldEditorParent()); addField(clangFormatPath); cpplintPath = new FileFieldEditor(CppStyleConstants.CPPLINT_PATH, "Cpplint path:", getFieldEditorParent()); addField(cpplintPath); enableCpplintOnSave = new BooleanFieldEditor(CppStyleConstants.ENABLE_CPPLINT_ON_SAVE, CppStyleConstants.ENABLE_CPPLINT_TEXT, getFieldEditorParent()); if (!checkPathExist(CppStyle.getCpplintPath())) { enableCpplintOnSave.setEnabled(false, getFieldEditorParent()); } addField(enableCpplintOnSave); enableClangFormatOnSave = new BooleanFieldEditor(CppStyleConstants.ENABLE_CLANGFORMAT_ON_SAVE, CppStyleConstants.ENABLE_CLANGFORMAT_TEXT, getFieldEditorParent()); if (!checkPathExist(ClangFormatFormatter.getClangFormatPath())) { enableClangFormatOnSave.setEnabled(false, getFieldEditorParent()); } addField(enableClangFormatOnSave); }
addField(new BooleanFieldEditor(MavenPreferenceConstants.P_OFFLINE, Messages.preferencesOffline, getFieldEditorParent())); addField(new BooleanFieldEditor(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER, Messages.preferencesGlobalUpdateNever, getFieldEditorParent())); addField(new BooleanFieldEditor(MavenPreferenceConstants.P_DEBUG_OUTPUT, // Messages.preferencesDebugOutput, getFieldEditorParent())); BooleanFieldEditor downloadSourcesField = new BooleanFieldEditor(MavenPreferenceConstants.P_DOWNLOAD_SOURCES, // Messages.preferencesDownloadSources, getFieldEditorParent()); downloadSourcesField.getDescriptionControl(getFieldEditorParent()) .setToolTipText(Messages.preferencesDownloadSourcesTooltip); addField(downloadSourcesField); addField(new BooleanFieldEditor(MavenPreferenceConstants.P_DOWNLOAD_JAVADOC, // Messages.preferencesDownloadJavadoc, getFieldEditorParent())); addField(new BooleanFieldEditor(MavenPreferenceConstants.P_UPDATE_INDEXES, // addField(new BooleanFieldEditor(MavenPreferenceConstants.P_UPDATE_PROJECTS, // addField(new BooleanFieldEditor(MavenPreferenceConstants.P_AUTO_UPDATE_CONFIGURATION, // addField(new BooleanFieldEditor(MavenPreferenceConstants.P_HIDE_FOLDERS_OF_NESTED_PROJECTS, // Messages.MavenPreferencePage_hide, getFieldEditorParent())); BooleanFieldEditor nullSchedulingRule = new BooleanFieldEditor( MavenPreferenceConstants.P_BUILDER_USE_NULL_SCHEDULING_RULE, Messages.preferencesNullSchedulingRule,
BooleanFieldEditor editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_HEX, DebugUIMessages.JavaDebugPreferencePage_Display__hexadecimal_values__byte__short__char__int__long__3, composite); editor.setPreferenceStore(preferenceStore); fEdtiors.add(editor); editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_CHAR, DebugUIMessages.JavaDebugPreferencePage_Display_ASCII__character_values__byte__short__int__long__4, composite); editor.setPreferenceStore(preferenceStore); fEdtiors.add(editor); editor = new BooleanFieldEditor(IJDIPreferencesConstants.PREF_SHOW_UNSIGNED, DebugUIMessages.JavaDebugPreferencePage_Display__unsigned_values__byte__5, composite); editor.setPreferenceStore(preferenceStore); fEdtiors.add(editor);
addField(editor); workspacejre = new BooleanFieldEditor(IAntUIPreferenceConstants.USE_WORKSPACE_JRE, AntPreferencesMessages.always_run_in_workspace_jre, getFieldEditorParent()); workspacejre.fillIntoGrid(getFieldEditorParent(), 3); addField(workspacejre); label.setLayoutData(gd); label.setFont(font); fToolsWarningEditor = new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_TOOLS_JAR_WARNING, AntPreferencesMessages.AntPreferencePage_1, getFieldEditorParent()); addField(fToolsWarningEditor); createSpace(); addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_ERROR_DIALOG, AntPreferencesMessages.AntPreferencePage_12, getFieldEditorParent())); createSpace(); addField(new BooleanFieldEditor(IAntUIPreferenceConstants.ANT_CREATE_MARKERS, AntPreferencesMessages.AntPreferencePage_15, getFieldEditorParent())); label = new Label(getFieldEditorParent(), SWT.WRAP); label.setText(AntPreferencesMessages.AntPreferencePage_16);
/** * Because the autoscroll value is in another plugin we must update the preference store manually */ protected void updateAutoScrollLockEditor() { autoScrollLockEditor.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore()); autoScrollLockEditor.load(); }
/** * @see org.eclipse.jface.preference.BooleanFieldEditor#getChangeControl(Composite) */ @Override public Button getChangeControl(Composite parent) { if (fChangeControl == null) { fChangeControl = super.getChangeControl(parent); } return fChangeControl; }
/** * Returns the change button for this field editor. * * @param parent * The Composite to create the receiver in. * * @return the change button */ protected Button getChangeControl(Composite parent) { if (checkBox == null) { checkBox = new Button(parent, SWT.CHECK | SWT.LEFT); checkBox.setFont(parent.getFont()); checkBox.addSelectionListener(widgetSelectedAdapter(e -> { boolean isSelected = checkBox.getSelection(); valueChanged(wasSelected, isSelected); wasSelected = isSelected; })); checkBox.addDisposeListener(event -> checkBox = null); } else { checkParent(checkBox, parent); } return checkBox; }
/** * Set the values of the component widgets based on the * values in the preference store */ private void loadValues() { Iterator iterator = fEdtiors.iterator(); while (iterator.hasNext()) { BooleanFieldEditor editor = (BooleanFieldEditor) iterator.next(); editor.load(); } }
private void cpplintPathChange(String newPath) { if (!checkPathExist(newPath)) { enableCpplintOnSave.setEnabled(false, getFieldEditorParent()); this.setValid(false); this.setErrorMessage("Cpplint path \"" + newPath + "\" does not exist"); } else { enableCpplintOnSave.setEnabled(true, getFieldEditorParent()); this.setValid(true); this.setErrorMessage(null); } } }
/** * Returns the change button for this field editor. * * @param parent * The Composite to create the receiver in. * * @return the change button */ protected Button getChangeControl(Composite parent) { if (checkBox == null) { checkBox = new Button(parent, SWT.CHECK | SWT.LEFT); checkBox.setFont(parent.getFont()); checkBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean isSelected = checkBox.getSelection(); valueChanged(wasSelected, isSelected); wasSelected = isSelected; } }); checkBox.addDisposeListener(event -> checkBox = null); } else { checkParent(checkBox, parent); } return checkBox; }
@Override protected void createFieldEditors() { addField(new BooleanFieldEditor(REUSE_EDITOR, SearchMessages.SearchPreferencePage_reuseEditor, getFieldEditorParent())); addField(new BooleanFieldEditor(BRING_VIEW_TO_FRONT, SearchMessages.SearchPreferencePage_bringToFront, getFieldEditorParent())); fIgnorePotentialMatchesCheckbox= new BooleanFieldEditor( IGNORE_POTENTIAL_MATCHES, SearchMessages.SearchPreferencePage_ignorePotentialMatches, addField(fIgnorePotentialMatchesCheckbox); fEmphasizedCheckbox= new BooleanFieldEditor( EMPHASIZE_POTENTIAL_MATCHES, SearchMessages.SearchPreferencePage_emphasizePotentialMatches, addField(fColorEditor); fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored(), getFieldEditorParent()); fColorEditor.setEnabled(!arePotentialMatchesIgnored() && arePotentialMatchesEmphasized(), getFieldEditorParent());
.applyTo(formattingGroup); BooleanFieldEditor hardWrap = new BooleanFieldEditor( UIPreferences.COMMIT_DIALOG_HARD_WRAP_MESSAGE, UIText.CommitDialogPreferencePage_hardWrapMessage, formattingGroup); hardWrap.getDescriptionControl(formattingGroup).setToolTipText( UIText.CommitDialogPreferencePage_hardWrapMessageTooltip); addField(hardWrap); .applyTo(footersGroup); BooleanFieldEditor signedOffBy = new BooleanFieldEditor( UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY, UIText.CommitDialogPreferencePage_signedOffBy, footersGroup); signedOffBy .getDescriptionControl(footersGroup) .setToolTipText( UIText.CommitDialogPreferencePage_signedOffByTooltip); addField(historySize); BooleanFieldEditor includeUntracked = new BooleanFieldEditor( UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED, UIText.CommitDialogPreferencePage_includeUntrackedFiles, main); includeUntracked.getDescriptionControl(main).setToolTipText( UIText.CommitDialogPreferencePage_includeUntrackedFilesTooltip); addField(includeUntracked);
/** * Returns the control responsible for displaying this field editor's label. * This method can be used to set a tooltip for a * <code>BooleanFieldEditor</code>. Note that the normal pattern of * <code>getLabelControl(parent).setToolTipText(tooltipText)</code> does not * work for boolean field editors, as it can lead to duplicate text (see bug * 259952). * * @param parent * the parent composite * @return the control responsible for displaying the label * * @since 3.5 */ public Control getDescriptionControl(Composite parent) { if (style == SEPARATE_LABEL) { return getLabelControl(parent); } return getChangeControl(parent); }
private void updateFieldEnablement() { boolean arePotentialMatchesIgnored= fIgnorePotentialMatchesCheckbox.getBooleanValue(); fEmphasizedCheckbox.setEnabled(!arePotentialMatchesIgnored, getFieldEditorParent()); fColorEditor.setEnabled(!arePotentialMatchesIgnored && fEmphasizedCheckbox.getBooleanValue(), getFieldEditorParent()); }
@Override public void setEnabled(boolean enabled, Composite parent) { // Only call super if there is a label already if (style == SEPARATE_LABEL) { super.setEnabled(enabled, parent); } getChangeControl(parent).setEnabled(enabled); }