/** * Creates the encoding field editor. * * @param composite the parent composite * @param string list with all controls */ private void encodingControl(Composite composite, String text) { Label label = new Label(composite, SWT.NONE); label.setText(text); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fEncodingEditorParent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; fEncodingEditorParent.setLayout(layout); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.horizontalIndent += SwtUtil.getIndent(); fEncodingEditorParent.setLayoutData(gd); encEditor = new EncodingFieldEditor(SPELLING_USER_DICTIONARY_ENCODING, "", null, fEncodingEditorParent); //$NON-NLS-1$ PreferenceStore store = new PreferenceStore(); String defaultEncoding = ResourcesPlugin.getEncoding(); store.setDefault(SPELLING_USER_DICTIONARY_ENCODING, defaultEncoding); String encoding = store.getString(SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(SPELLING_USER_DICTIONARY_ENCODING, encoding); encEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change listener DialogPage fakePage = new DialogPage() { public void createControl(Composite c) {} @Override public void setErrorMessage(String newMessage) { StatusInfo status = new StatusInfo(); if (newMessage != null) status.setError(newMessage); fEncodingFieldEditorStatus = status; fContext.statusChanged(StatusUtil .getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); } }; encEditor.setPage(fakePage); encEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) { encEditor.loadDefault(); } }
/** * Creates the encoding field editor. * * @param composite the parent composite * @param allControls list with all controls * @since 3.3 */ private void createEncodingFieldEditor(Composite composite, List<Control> allControls) { Label filler= new Label(composite, SWT.NONE); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 4; filler.setLayoutData(gd); Label label= new Label(composite, SWT.NONE); label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); allControls.add(label); fEncodingEditorParent= new Composite(composite, SWT.NONE); GridLayout layout= new GridLayout(2, false); layout.marginWidth= 0; layout.marginHeight= 0; fEncodingEditorParent.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 3; fEncodingEditorParent.setLayoutData(gd); fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); //$NON-NLS-1$ PreferenceStore store= new PreferenceStore(); String defaultEncoding= ResourcesPlugin.getEncoding(); store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding); String encoding= getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding); fEncodingEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change listener DialogPage fakePage= new DialogPage() { public void createControl(Composite c) { } @Override public void setErrorMessage(String newMessage) { StatusInfo status= new StatusInfo(); if (newMessage != null) status.setError(newMessage); fEncodingFieldEditorStatus= status; fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); } }; fEncodingEditor.setPage(fakePage); fEncodingEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) fEncodingEditor.loadDefault(); }