From 79dd65c3216193931846e327da1772f08e3b1469 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sat, 17 Jul 2004 16:40:28 +0000 Subject: [PATCH 1/1] Cleaned up PHP Prefs (Code Assist, typing) --- .../AbstractConfigurationBlockPreferencePage.java | 127 ++ .../preferences/CodeAssistConfigurationBlock.java | 512 ++++++++ .../ui/preferences/CodeAssistPreferencePage.java | 56 + .../phpdt/internal/ui/preferences/ColorEditor.java | 122 ++ .../preferences/IPreferenceConfigurationBlock.java | 63 + .../ui/preferences/JavaEditorPreferencePage.java | 1261 ++++++++++---------- .../ui/preferences/PreferencesMessages.properties | 109 +- .../sourceforge/phpdt/ui/PreferenceConstants.java | 15 +- 8 files changed, 1560 insertions(+), 705 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistConfigurationBlock.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistPreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/ColorEditor.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/IPreferenceConfigurationBlock.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java new file mode 100644 index 0000000..c263688 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.help.WorkbenchHelp; + + + +/** + * Abstract preference page which is used to wrap a + * {@link org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock}. + * + * @since 3.0 + */ +public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + + private IPreferenceConfigurationBlock fConfigurationBlock; + private OverlayPreferenceStore fOverlayStore; + + + /** + * Creates a new preference page. + */ + public AbstractConfigurationBlockPreferencePage() { + setDescription(); + setPreferenceStore(); + fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {}); + fConfigurationBlock= createConfigurationBlock(fOverlayStore); + } + + protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore); + protected abstract String getHelpId(); + protected abstract void setDescription(); + protected abstract void setPreferenceStore(); + + /* + * @see IWorkbenchPreferencePage#init() + */ + public void init(IWorkbench workbench) { + } + + /* + * @see PreferencePage#createControl(Composite) + */ + public void createControl(Composite parent) { + super.createControl(parent); + WorkbenchHelp.setHelp(getControl(), getHelpId()); + } + + /* + * @see PreferencePage#createContents(Composite) + */ + protected Control createContents(Composite parent) { + + fOverlayStore.load(); + fOverlayStore.start(); + + fConfigurationBlock.createControl(parent); + + initialize(); + + Dialog.applyDialogFont(parent); + return parent; + } + + private void initialize() { + fConfigurationBlock.initialize(); + } + + /* + * @see PreferencePage#performOk() + */ + public boolean performOk() { + + fConfigurationBlock.performOk(); + + fOverlayStore.propagate(); + + PHPeclipsePlugin.getDefault().savePluginPreferences(); + + return true; + } + + /* + * @see PreferencePage#performDefaults() + */ + public void performDefaults() { + + fOverlayStore.loadDefaults(); + fConfigurationBlock.performDefaults(); + + super.performDefaults(); + } + + /* + * @see DialogPage#dispose() + */ + public void dispose() { + + fConfigurationBlock.dispose(); + + if (fOverlayStore != null) { + fOverlayStore.stop(); + fOverlayStore= null; + } + + super.dispose(); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistConfigurationBlock.java new file mode 100644 index 0000000..27e0702 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistConfigurationBlock.java @@ -0,0 +1,512 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.core.runtime.IStatus; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Text; + +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.preference.PreferencePage; + +import org.eclipse.jface.text.Assert; + +import net.sourceforge.phpdt.ui.PreferenceConstants; + +import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; +import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; +import net.sourceforge.phpdt.internal.ui.util.PixelConverter; + +/** + * Configures the code assist preferences. + * + * @since 3.0 + */ +class CodeAssistConfigurationBlock implements IPreferenceConfigurationBlock { + + + private OverlayPreferenceStore fStore; + private PreferencePage fMainPreferencePage; + + private List fContentAssistColorList; + private ColorEditor fContentAssistColorEditor; + private Control fAutoInsertDelayText; + private Control fAutoInsertJavaTriggerText; + private Control fAutoInsertJavaDocTriggerText; + private Control fAutoInsertHTMLTriggerText; + private Label fAutoInsertDelayLabel; + private Label fAutoInsertJavaTriggerLabel; + private Label fAutoInsertJavaDocTriggerLabel; + private Label fAutoInsertHTMLTriggerLabel; +// private Button fCompletionInsertsRadioButton; +// private Button fCompletionOverwritesRadioButton; + /** + * List of master/slave listeners when there's a dependency. + * + * @see #createDependency(Button, String, Control) + * @since 3.0 + */ + private ArrayList fMasterSlaveListeners= new ArrayList(); + + private final String[][] fContentAssistColorListModel= new String[][] { + {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND }, //$NON-NLS-1$ + {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND }, //$NON-NLS-1$ +// {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND }, //$NON-NLS-1$ +// {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND }, //$NON-NLS-1$ +// {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND }, //$NON-NLS-1$ +// {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND } //$NON-NLS-1$ + }; + + + private Map fCheckBoxes= new HashMap(); + private SelectionListener fCheckBoxListener= new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + } + public void widgetSelected(SelectionEvent e) { + Button button= (Button) e.widget; + fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + } + }; + + private Map fTextFields= new HashMap(); + private ModifyListener fTextFieldListener= new ModifyListener() { + public void modifyText(ModifyEvent e) { + Text text= (Text) e.widget; + fStore.setValue((String) fTextFields.get(text), text.getText()); + } + }; + + private ArrayList fNumberFields= new ArrayList(); + private ModifyListener fNumberFieldListener= new ModifyListener() { + public void modifyText(ModifyEvent e) { + numberFieldChanged((Text) e.widget); + } + }; + + + public CodeAssistConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) { + Assert.isNotNull(mainPreferencePage); + Assert.isNotNull(store); + fStore= store; + fStore.addKeys(createOverlayStoreKeys()); + fMainPreferencePage= mainPreferencePage; + } + + + private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { + + ArrayList overlayKeys= new ArrayList(); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_PREFIX_COMPLETION)); + + OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + overlayKeys.toArray(keys); + return keys; + } + + /** + * Creates page for hover preferences. + * + * @param parent the parent composite + * @return the control for the preference page + */ + public Control createControl(Composite parent) { + + PixelConverter pixelConverter= new PixelConverter(parent); + + Composite contentAssistComposite= new Composite(parent, SWT.NONE); + contentAssistComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layout= new GridLayout(); + layout.numColumns= 2; + contentAssistComposite.setLayout(layout); + +// addCompletionRadioButtons(contentAssistComposite); + + String label; +// label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$ +// addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.completePrefixes"); //$NON-NLS-1$ +// addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$ +// addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$ +// addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$ +// addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ +// Button master= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0); +// +// label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ +// Button slave= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0); +// createDependency(master, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, slave); +// + label= PreferencesMessages.getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$ + final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0); + autoactivation.addSelectionListener(new SelectionAdapter(){ + public void widgetSelected(SelectionEvent e) { + updateAutoactivationControls(); + } + }); + + Control[] labelledTextField; + label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$ + labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true); + fAutoInsertDelayLabel= getLabelControl(labelledTextField); + fAutoInsertDelayText= getTextControl(labelledTextField); + + label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$ + labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false); + fAutoInsertJavaTriggerLabel= getLabelControl(labelledTextField); + fAutoInsertJavaTriggerText= getTextControl(labelledTextField); + + label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$ + labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false); + fAutoInsertJavaDocTriggerLabel= getLabelControl(labelledTextField); + fAutoInsertJavaDocTriggerText= getTextControl(labelledTextField); + + label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForHTML"); //$NON-NLS-1$ + labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_HTML, 4, 0, false); + fAutoInsertHTMLTriggerLabel= getLabelControl(labelledTextField); + fAutoInsertHTMLTriggerText= getTextControl(labelledTextField); + + Label l= new Label(contentAssistComposite, SWT.LEFT); + l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$ + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gd.horizontalSpan= 2; + l.setLayoutData(gd); + + Composite editorComposite= new Composite(contentAssistComposite, SWT.NONE); + layout= new GridLayout(); + layout.numColumns= 2; + layout.marginHeight= 0; + layout.marginWidth= 0; + editorComposite.setLayout(layout); + gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); + gd.horizontalSpan= 2; + editorComposite.setLayoutData(gd); + + fContentAssistColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); + gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd.heightHint= pixelConverter.convertHeightInCharsToPixels(8); + fContentAssistColorList.setLayoutData(gd); + + Composite stylesComposite= new Composite(editorComposite, SWT.NONE); + layout= new GridLayout(); + layout.marginHeight= 0; + layout.marginWidth= 0; + layout.numColumns= 2; + stylesComposite.setLayout(layout); + stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + l= new Label(stylesComposite, SWT.LEFT); + l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$ + gd= new GridData(); + gd.horizontalAlignment= GridData.BEGINNING; + l.setLayoutData(gd); + + fContentAssistColorEditor= new ColorEditor(stylesComposite); + Button colorButton= fContentAssistColorEditor.getButton(); + gd= new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment= GridData.BEGINNING; + colorButton.setLayoutData(gd); + + fContentAssistColorList.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + handleContentAssistColorListSelection(); + } + }); + colorButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + int i= fContentAssistColorList.getSelectionIndex(); + String key= fContentAssistColorListModel[i][1]; + + PreferenceConverter.setValue(fStore, key, fContentAssistColorEditor.getColorValue()); + } + }); + + return contentAssistComposite; + } + + private void createDependency(final Button master, String masterKey, final Control slave) { + indent(slave); + boolean masterState= fStore.getBoolean(masterKey); + slave.setEnabled(masterState); + SelectionListener listener= new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + slave.setEnabled(master.getSelection()); + } + + public void widgetDefaultSelected(SelectionEvent e) {} + }; + master.addSelectionListener(listener); + fMasterSlaveListeners.add(listener); + } + + private static void indent(Control control) { + GridData gridData= new GridData(); + gridData.horizontalIndent= 20; + control.setLayoutData(gridData); + } + + private static Text getTextControl(Control[] labelledTextField){ + return (Text)labelledTextField[1]; + } + + private static Label getLabelControl(Control[] labelledTextField){ + return (Label)labelledTextField[0]; + } + + /** + * Returns an array of size 2: + * - first element is of type Label + * - second element is of type Text + * Use getLabelControl and getTextControl to get the 2 controls. + * + * @param composite the parent composite + * @param label the text field's label + * @param key the preference key + * @param textLimit the text limit + * @param indentation the field's indentation + * @param isNumber true iff this text field is used to e4dit a number + * @return + */ + private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { + + PixelConverter pixelConverter= new PixelConverter(composite); + + Label labelControl= new Label(composite, SWT.NONE); + labelControl.setText(label); + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= indentation; + labelControl.setLayoutData(gd); + + Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); + gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.widthHint= pixelConverter.convertWidthInCharsToPixels(textLimit + 1); + textControl.setLayoutData(gd); + textControl.setTextLimit(textLimit); + fTextFields.put(textControl, key); + if (isNumber) { + fNumberFields.add(textControl); + textControl.addModifyListener(fNumberFieldListener); + } else { + textControl.addModifyListener(fTextFieldListener); + } + + return new Control[]{labelControl, textControl}; + } + + private void addCompletionRadioButtons(Composite contentAssistComposite) { + Composite completionComposite= new Composite(contentAssistComposite, SWT.NONE); + GridData ccgd= new GridData(); + ccgd.horizontalSpan= 2; + completionComposite.setLayoutData(ccgd); + GridLayout ccgl= new GridLayout(); + ccgl.marginWidth= 0; + ccgl.numColumns= 2; + completionComposite.setLayout(ccgl); + +// SelectionListener completionSelectionListener= new SelectionAdapter() { +// public void widgetSelected(SelectionEvent e) { +// boolean insert= fCompletionInsertsRadioButton.getSelection(); +// fStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, insert); +// } +// }; +// +// fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); +// fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts")); //$NON-NLS-1$ +// fCompletionInsertsRadioButton.setLayoutData(new GridData()); +// fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener); +// +// fCompletionOverwritesRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); +// fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites")); //$NON-NLS-1$ +// fCompletionOverwritesRadioButton.setLayoutData(new GridData()); +// fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener); + } + + public void initialize() { + initializeFields(); + + for (int i= 0; i < fContentAssistColorListModel.length; i++) + fContentAssistColorList.add(fContentAssistColorListModel[i][0]); + fContentAssistColorList.getDisplay().asyncExec(new Runnable() { + public void run() { + if (fContentAssistColorList != null && !fContentAssistColorList.isDisposed()) { + fContentAssistColorList.select(0); + handleContentAssistColorListSelection(); + } + } + }); + + } + + void initializeFields() { + Iterator e= fCheckBoxes.keySet().iterator(); + while (e.hasNext()) { + Button b= (Button) e.next(); + String key= (String) fCheckBoxes.get(b); + b.setSelection(fStore.getBoolean(key)); + } + + e= fTextFields.keySet().iterator(); + while (e.hasNext()) { + Text t= (Text) e.next(); + String key= (String) fTextFields.get(t); + t.setText(fStore.getString(key)); + } + +// boolean completionInserts= fStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION); +// fCompletionInsertsRadioButton.setSelection(completionInserts); +// fCompletionOverwritesRadioButton.setSelection(! completionInserts); + + updateAutoactivationControls(); + + updateStatus(validatePositiveNumber("0")); //$NON-NLS-1$ + + // Update slaves + Iterator iter= fMasterSlaveListeners.iterator(); + while (iter.hasNext()) { + SelectionListener listener= (SelectionListener)iter.next(); + listener.widgetSelected(null); + } + } + + private void updateAutoactivationControls() { + boolean autoactivation= fStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION); + fAutoInsertDelayText.setEnabled(autoactivation); + fAutoInsertDelayLabel.setEnabled(autoactivation); + + fAutoInsertJavaTriggerText.setEnabled(autoactivation); + fAutoInsertJavaTriggerLabel.setEnabled(autoactivation); + + fAutoInsertJavaDocTriggerText.setEnabled(autoactivation); + fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation); + + fAutoInsertHTMLTriggerText.setEnabled(autoactivation); + fAutoInsertHTMLTriggerLabel.setEnabled(autoactivation); + } + + public void performOk() { + } + + public void performDefaults() { + handleContentAssistColorListSelection(); + initializeFields(); + } + + private void handleContentAssistColorListSelection() { + int i= fContentAssistColorList.getSelectionIndex(); + String key= fContentAssistColorListModel[i][1]; + RGB rgb= PreferenceConverter.getColor(fStore, key); + fContentAssistColorEditor.setColorValue(rgb); + } + + private void numberFieldChanged(Text textControl) { + String number= textControl.getText(); + IStatus status= validatePositiveNumber(number); + if (!status.matches(IStatus.ERROR)) + fStore.setValue((String) fTextFields.get(textControl), number); + updateStatus(status); + } + + private IStatus validatePositiveNumber(String number) { + StatusInfo status= new StatusInfo(); + if (number.length() == 0) { + status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$ + } else { + try { + int value= Integer.parseInt(number); + if (value < 0) + status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ + } catch (NumberFormatException e) { + status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ + } + } + return status; + } + + private void updateStatus(IStatus status) { + fMainPreferencePage.setValid(status.isOK()); + StatusUtil.applyToStatusLine(fMainPreferencePage, status); + } + + private Button addCheckBox(Composite parent, String label, String key, int indentation) { + Button checkBox= new Button(parent, SWT.CHECK); + checkBox.setText(label); + + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent= indentation; + gd.horizontalSpan= 2; + checkBox.setLayoutData(gd); + checkBox.addSelectionListener(fCheckBoxListener); + + fCheckBoxes.put(checkBox, key); + + return checkBox; + } + + /* + * @see DialogPage#dispose() + */ + public void dispose() { + // nothing to dispose + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistPreferencePage.java new file mode 100644 index 0000000..019607d --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeAssistPreferencePage.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + + + +/** + * Code Assist preference page. + *

+ * Note: Must be public since it is referenced from plugin.xml + *

+ * + * @since 3.0 + */ +public class CodeAssistPreferencePage extends AbstractConfigurationBlockPreferencePage { + + /* + * @see org.eclipse.jdt.internal.ui.preferences.AbstractConfigureationBlockPreferencePage#getHelpId() + */ + protected String getHelpId() { + return IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE; + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage#setDescription() + */ + protected void setDescription() { + // This page has no description + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage#setPreferenceStore() + */ + protected void setPreferenceStore() { + setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); + } + + /* + * @see org.eclipse.jdt.internal.ui.preferences.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.jdt.internal.ui.preferences.OverlayPreferenceStore) + */ + protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { + return new CodeAssistConfigurationBlock(this, overlayPreferenceStore); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/ColorEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/ColorEditor.java new file mode 100644 index 0000000..c833f53 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/ColorEditor.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package net.sourceforge.phpdt.internal.ui.preferences; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; + +import org.eclipse.jface.resource.JFaceResources; + +/** + * A "button" of a certain color determined by the color picker. + */ +public class ColorEditor { + + private Point fExtent; + private Image fImage; + private RGB fColorValue; + private Color fColor; + private Button fButton; + + public ColorEditor(Composite parent) { + + fButton= new Button(parent, SWT.PUSH); + fExtent= computeImageSize(parent); + fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); + + GC gc= new GC(fImage); + gc.setBackground(fButton.getBackground()); + gc.fillRectangle(0, 0, fExtent.x, fExtent.y); + gc.dispose(); + + fButton.setImage(fImage); + fButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + ColorDialog colorDialog= new ColorDialog(fButton.getShell()); + colorDialog.setRGB(fColorValue); + RGB newColor = colorDialog.open(); + if (newColor != null) { + fColorValue= newColor; + updateColorImage(); + } + } + }); + + fButton.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + if (fImage != null) { + fImage.dispose(); + fImage= null; + } + if (fColor != null) { + fColor.dispose(); + fColor= null; + } + } + }); + } + + public RGB getColorValue() { + return fColorValue; + } + + public void setColorValue(RGB rgb) { + fColorValue= rgb; + updateColorImage(); + } + + public Button getButton() { + return fButton; + } + + protected void updateColorImage() { + + Display display= fButton.getDisplay(); + + GC gc= new GC(fImage); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); + + if (fColor != null) + fColor.dispose(); + + fColor= new Color(display, fColorValue); + gc.setBackground(fColor); + gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); + gc.dispose(); + + fButton.setImage(fImage); + } + + protected Point computeImageSize(Control window) { + GC gc= new GC(window); + Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); + gc.setFont(f); + int height= gc.getFontMetrics().getHeight(); + gc.dispose(); + Point p= new Point(height * 3 - 6, height); + return p; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/IPreferenceConfigurationBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/IPreferenceConfigurationBlock.java new file mode 100644 index 0000000..423f680 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/IPreferenceConfigurationBlock.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package net.sourceforge.phpdt.internal.ui.preferences; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + + +/** + * Interface for preference configuration blocks which can either be + * wrapped by a {@link org.eclipse.jdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage} + * or be included some preference page. + *

+ * Clients may implement this interface. + *

+ * + * @since 3.0 + */ +public interface IPreferenceConfigurationBlock { + + /** + * Creates the preference control. + * + * @param parent the parent composite to which to add the preferences control + * @return the control that was added to parent + */ + Control createControl(Composite parent); + + /** + * Called after creating the control. Implementations should load the + * preferences values and update the controls accordingly. + */ + void initialize(); + + /** + * Called when the OK button is pressed on the preference + * page. Implementations should commit the configured preference settings + * into their form of preference storage. + */ + void performOk(); + + /** + * Called when the Defaults button is pressed on the + * preference page. Implementation should reset any preference settings to + * their default values and adjust the controls accordingly. + */ + void performDefaults(); + + /** + * Called when the preference page is being disposed. Implementations should + * free any resources they are holding on to. + */ + void dispose(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java index 99e8fa1..c7e7b17 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package net.sourceforge.phpdt.internal.ui.preferences; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -77,19 +78,23 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; + /** * The page for setting the editor options. */ -public class JavaEditorPreferencePage extends PreferencePage - implements - IWorkbenchPreferencePage { +public class JavaEditorPreferencePage extends PreferencePage implements + IWorkbenchPreferencePage { private static final String BOLD = PreferenceConstants.EDITOR_BOLD_SUFFIX; + private static final String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS; + private static final String DELIMITER = PreferencesMessages .getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$ + /** The keys of the overlay store. */ public final OverlayPreferenceStore.OverlayKey[] fKeys; - private final String[][] fSyntaxColorListModel = new String[][]{ + + private final String[][] fSyntaxColorListModel = new String[][] { // { // PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"), // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$ @@ -122,199 +127,217 @@ public class JavaEditorPreferencePage extends PreferencePage // { // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"), // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$ - { PreferencesMessages + { + PreferencesMessages .getString("PHPEditorPreferencePage.multiLineComment"), - PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR}, + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$ - { PreferencesMessages + { + PreferencesMessages .getString("PHPEditorPreferencePage.singleLineComment"), - PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR}, + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.tags"), - PreferenceConstants.EDITOR_PHP_TAG_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.tags"), + PreferenceConstants.EDITOR_PHP_TAG_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.keywords"), - PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR}, - {PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"), - PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.keywords"), + PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, + { PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"), + PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.variables"), - PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.variables"), + PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.constants"), - PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.constants"), + PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.types"), - PreferenceConstants.EDITOR_PHP_TYPE_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.types"), + PreferenceConstants.EDITOR_PHP_TYPE_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.strings"), - PreferenceConstants.EDITOR_STRING_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.strings"), + PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.others"), - PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR}, //$NON-NLS-1$ + { PreferencesMessages.getString("PHPEditorPreferencePage.others"), + PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), - PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR }, - //$NON-NLS-1$ - { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"), - PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR }, - //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), - PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR}, - //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), - PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR}, - //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"), - PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR}, - //$NON-NLS-1$ - {PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"), - PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR} //$NON-NLS-1$ - }; - private final String[][] fAppearanceColorListModel = new String[][]{ - { - PreferencesMessages - .getString("JavaEditorPreferencePage.lineNumberForegroundColor"), - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, + PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), - PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, + .getString("JavaEditorPreferencePage.returnKeyword"), + PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.currentLineHighlighColor"), - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, + .getString("PHPEditorPreferencePage.phpDocKeywords"), + PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.printMarginColor2"), - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, + .getString("PHPEditorPreferencePage.phpDocHtmlTags"), + PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$ - { - PreferencesMessages - .getString("JavaEditorPreferencePage.findScopeColor2"), - PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, + { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"), + PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$ - {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), - PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$ + { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"), + PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$ }; -// private final String[][] fAnnotationColorListModel; - private final String[][] fContentAssistColorListModel = new String[][]{ + + private final String[][] fAppearanceColorListModel = new String[][] { { PreferencesMessages - .getString("JavaEditorPreferencePage.backgroundForCompletionProposals"), - PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND}, + .getString("JavaEditorPreferencePage.lineNumberForegroundColor"), + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.foregroundForCompletionProposals"), - PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND}, + .getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), + PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.backgroundForMethodParameters"), - PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND}, + .getString("JavaEditorPreferencePage.currentLineHighlighColor"), + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.foregroundForMethodParameters"), - PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND}, + .getString("JavaEditorPreferencePage.printMarginColor2"), + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR }, //$NON-NLS-1$ { PreferencesMessages - .getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"), - PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND}, + .getString("JavaEditorPreferencePage.findScopeColor2"), + PreferenceConstants.EDITOR_FIND_SCOPE_COLOR }, //$NON-NLS-1$ - { - PreferencesMessages - .getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), - PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND} //$NON-NLS-1$ + { PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), + PreferenceConstants.EDITOR_LINK_COLOR }, //$NON-NLS-1$ }; -// private final String[][] fAnnotationDecorationListModel = new String[][]{ -// { -// PreferencesMessages -// .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"), -// AnnotationPreference.STYLE_NONE}, -// //$NON-NLS-1$ -// { -// PreferencesMessages -// .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"), -// AnnotationPreference.STYLE_SQUIGGLIES}, -// //$NON-NLS-1$ -// { -// PreferencesMessages -// .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"), -// AnnotationPreference.STYLE_UNDERLINE}, -// //$NON-NLS-1$ -// { -// PreferencesMessages -// .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"), -// AnnotationPreference.STYLE_BOX}, -// //$NON-NLS-1$ -// { -// PreferencesMessages -// .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"), -// AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$ -// }; + + // private final String[][] fAnnotationColorListModel; + + // private final String[][] fAnnotationDecorationListModel = new String[][]{ + // { + // PreferencesMessages + // .getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"), + // AnnotationPreference.STYLE_NONE}, + // //$NON-NLS-1$ + // { + // PreferencesMessages + // .getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLIES"), + // AnnotationPreference.STYLE_SQUIGGLIES}, + // //$NON-NLS-1$ + // { + // PreferencesMessages + // .getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"), + // AnnotationPreference.STYLE_UNDERLINE}, + // //$NON-NLS-1$ + // { + // PreferencesMessages + // .getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"), + // AnnotationPreference.STYLE_BOX}, + // //$NON-NLS-1$ + // { + // PreferencesMessages + // .getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"), + // AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$ + // }; private OverlayPreferenceStore fOverlayStore; + private JavaTextTools fJavaTextTools; + private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock; + private FoldingConfigurationBlock fFoldingConfigurationBlock; - + private Map fColorButtons = new HashMap(); + private Map fCheckBoxes = new HashMap(); + private SelectionListener fCheckBoxListener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } + public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; fOverlayStore.setValue((String) fCheckBoxes.get(button), button .getSelection()); } }; + private Map fTextFields = new HashMap(); + private ModifyListener fTextFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { Text text = (Text) e.widget; fOverlayStore.setValue((String) fTextFields.get(text), text.getText()); } }; + private ArrayList fNumberFields = new ArrayList(); + private ModifyListener fNumberFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); } }; + private List fSyntaxColorList; + private List fAppearanceColorList; - private List fContentAssistColorList; + + // private List fContentAssistColorList; private List fAnnotationList; + private ColorEditor fSyntaxForegroundColorEditor; + private ColorEditor fAppearanceColorEditor; + private ColorEditor fAnnotationForegroundColorEditor; + private ColorEditor fContentAssistColorEditor; + private ColorEditor fBackgroundColorEditor; + private Button fBackgroundDefaultRadioButton; + private Button fBackgroundCustomRadioButton; + private Button fBackgroundColorButton; + private Button fBoldCheckBox; - private Button fAddJavaDocTagsButton; - private Button fEscapeStringsButton; + +// private Button fAddJavaDocTagsButton; + +// private Button fEscapeStringsButton; + // private Button fGuessMethodArgumentsButton; private SourceViewer fPreviewViewer; + private Color fBackgroundColor; + private Control fAutoInsertDelayText; + private Control fAutoInsertJavaTriggerText; + private Control fAutoInsertJavaDocTriggerText; + private Label fAutoInsertDelayLabel; + private Label fAutoInsertJavaTriggerLabel; + private Label fAutoInsertJavaDocTriggerLabel; + private Button fShowInTextCheckBox; + private Combo fDecorationStyleCombo; + private Button fHighlightInTextCheckBox; + private Button fShowInOverviewRulerCheckBox; + private Button fShowInVerticalRulerCheckBox; + // private Text fBrowserLikeLinksKeyModifierText; // private Button fBrowserLikeLinksCheckBox; // private StatusInfo fBrowserLikeLinksKeyModifierStatus; @@ -331,8 +354,10 @@ public class JavaEditorPreferencePage extends PreferencePage MarkerAnnotationPreferences markerAnnotationPreferences = new MarkerAnnotationPreferences(); fKeys = createOverlayStoreKeys(markerAnnotationPreferences); fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), fKeys); -// fAnnotationColorListModel = createAnnotationTypeListModel(markerAnnotationPreferences); + // fAnnotationColorListModel = + // createAnnotationTypeListModel(markerAnnotationPreferences); } + private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys( MarkerAnnotationPreferences preferences) { ArrayList overlayKeys = new ArrayList(); @@ -369,13 +394,15 @@ public class JavaEditorPreferencePage extends PreferencePage overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD)); - - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.STRING, - PreferenceConstants.EDITOR_PHP_TAG_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_PHP_TAG_BOLD)); + + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, + PreferenceConstants.EDITOR_PHP_TAG_COLOR)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_PHP_TAG_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR)); @@ -400,11 +427,13 @@ public class JavaEditorPreferencePage extends PreferencePage overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_TYPE_BOLD)); - - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( @@ -425,17 +454,17 @@ public class JavaEditorPreferencePage extends PreferencePage // overlayKeys.add(new // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, - PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, + PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_PHP_OPERATOR_BOLD)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, @@ -467,18 +496,21 @@ public class JavaEditorPreferencePage extends PreferencePage overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.STRING, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.STRING, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.INT, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.INT, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); @@ -502,12 +534,14 @@ public class JavaEditorPreferencePage extends PreferencePage overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.STRING, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey( - OverlayPreferenceStore.BOOLEAN, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.STRING, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); + overlayKeys + .add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS)); @@ -569,12 +603,12 @@ public class JavaEditorPreferencePage extends PreferencePage .add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP)); overlayKeys .add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, @@ -586,21 +620,21 @@ public class JavaEditorPreferencePage extends PreferencePage .add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_ESCAPE_STRINGS)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_ESCAPE_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); - overlayKeys.add(new - OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, - PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey( + OverlayPreferenceStore.BOOLEAN, + PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE)); // overlayKeys.add(new // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, // PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); @@ -647,8 +681,10 @@ public class JavaEditorPreferencePage extends PreferencePage } /* * @see IWorkbenchPreferencePage#init() */ + public void init(IWorkbench workbench) { } + /* * @see PreferencePage#createControl(Composite) */ @@ -657,6 +693,7 @@ public class JavaEditorPreferencePage extends PreferencePage WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); } + private void handleSyntaxColorListSelection() { int i = fSyntaxColorList.getSelectionIndex(); String key = fSyntaxColorListModel[i][1]; @@ -664,68 +701,64 @@ public class JavaEditorPreferencePage extends PreferencePage fSyntaxForegroundColorEditor.setColorValue(rgb); fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD)); } + private void handleAppearanceColorListSelection() { int i = fAppearanceColorList.getSelectionIndex(); String key = fAppearanceColorListModel[i][1]; RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); fAppearanceColorEditor.setColorValue(rgb); } - private void handleContentAssistColorListSelection() { - int i = fContentAssistColorList.getSelectionIndex(); - String key = fContentAssistColorListModel[i][1]; - RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); - fContentAssistColorEditor.setColorValue(rgb); - } -// private void handleAnnotationListSelection() { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][1]; -// RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); -// fAnnotationForegroundColorEditor.setColorValue(rgb); -// key = fAnnotationColorListModel[i][2]; -// boolean showInText = fOverlayStore.getBoolean(key); -// fShowInTextCheckBox.setSelection(showInText); -// key = fAnnotationColorListModel[i][6]; -// if (key != null) { -// fDecorationStyleCombo.setEnabled(showInText); -// for (int j = 0; j < fAnnotationDecorationListModel.length; j++) { -// String value = fOverlayStore.getString(key); -// if (fAnnotationDecorationListModel[j][1].equals(value)) { -// fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]); -// break; -// } -// } -// } else { -// fDecorationStyleCombo.setEnabled(false); -// fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set -// // selection -// // to -// // squigglies -// // if -// // the -// // key -// // is -// // not -// // there -// // (legacy -// // support) -// } -// key = fAnnotationColorListModel[i][3]; -// fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); -// key = fAnnotationColorListModel[i][4]; -// if (key != null) { -// fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key)); -// fHighlightInTextCheckBox.setEnabled(true); -// } else -// fHighlightInTextCheckBox.setEnabled(false); -// key = fAnnotationColorListModel[i][5]; -// if (key != null) { -// fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); -// fShowInVerticalRulerCheckBox.setEnabled(true); -// } else { -// fShowInVerticalRulerCheckBox.setSelection(true); -// fShowInVerticalRulerCheckBox.setEnabled(false); -// } -// } + + // private void handleAnnotationListSelection() { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][1]; + // RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); + // fAnnotationForegroundColorEditor.setColorValue(rgb); + // key = fAnnotationColorListModel[i][2]; + // boolean showInText = fOverlayStore.getBoolean(key); + // fShowInTextCheckBox.setSelection(showInText); + // key = fAnnotationColorListModel[i][6]; + // if (key != null) { + // fDecorationStyleCombo.setEnabled(showInText); + // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) { + // String value = fOverlayStore.getString(key); + // if (fAnnotationDecorationListModel[j][1].equals(value)) { + // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]); + // break; + // } + // } + // } else { + // fDecorationStyleCombo.setEnabled(false); + // fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set + // // selection + // // to + // // squigglies + // // if + // // the + // // key + // // is + // // not + // // there + // // (legacy + // // support) + // } + // key = fAnnotationColorListModel[i][3]; + // fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); + // key = fAnnotationColorListModel[i][4]; + // if (key != null) { + // fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key)); + // fHighlightInTextCheckBox.setEnabled(true); + // } else + // fHighlightInTextCheckBox.setEnabled(false); + // key = fAnnotationColorListModel[i][5]; + // if (key != null) { + // fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); + // fShowInVerticalRulerCheckBox.setEnabled(true); + // } else { + // fShowInVerticalRulerCheckBox.setSelection(true); + // fShowInVerticalRulerCheckBox.setEnabled(false); + // } + // } private Control createSyntaxPage(Composite parent) { Composite colorComposite = new Composite(parent, SWT.NULL); colorComposite.setLayout(new GridLayout()); @@ -740,6 +773,7 @@ public class JavaEditorPreferencePage extends PreferencePage fOverlayStore.setValue( PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom); } + public void widgetDefaultSelected(SelectionEvent e) { } }; @@ -812,6 +846,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { handleSyntaxColorListSelection(); } @@ -820,6 +855,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { int i = fSyntaxColorList.getSelectionIndex(); String key = fSyntaxColorListModel[i][1]; @@ -831,6 +867,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor @@ -841,6 +878,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { int i = fSyntaxColorList.getSelectionIndex(); String key = fSyntaxColorListModel[i][1]; @@ -849,14 +887,19 @@ public class JavaEditorPreferencePage extends PreferencePage }); return colorComposite; } + private Control createPreviewer(Composite parent) { Preferences coreStore = createTemporaryCorePreferenceStore(); fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false); - IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); - IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore }); - - fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); - + IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); + IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { + fOverlayStore, + new PreferencesAdapter(createTemporaryCorePreferenceStore()), + generalTextStore }); + + fPreviewViewer = new JavaSourceViewer(parent, null, null, false, + SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); + fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null)); // Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); @@ -871,11 +914,13 @@ public class JavaEditorPreferencePage extends PreferencePage fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); } + private Preferences createTemporaryCorePreferenceStore() { Preferences result = new Preferences(); result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$ return result; } + private Control createAppearancePage(Composite parent) { Composite appearanceComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -887,17 +932,22 @@ public class JavaEditorPreferencePage extends PreferencePage PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true); label = PreferencesMessages .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$ - addTextField(appearanceComposite, label, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, - true); + addTextField( + appearanceComposite, + label, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, + 3, 0, true); label = PreferencesMessages .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$ - addCheckBox(appearanceComposite, label, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0); + addCheckBox( + appearanceComposite, + label, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, + 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, @@ -905,11 +955,11 @@ public class JavaEditorPreferencePage extends PreferencePage label = PreferencesMessages .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$ // Button master= addCheckBox(appearanceComposite, label, @@ -966,6 +1016,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { handleAppearanceColorListSelection(); } @@ -974,6 +1025,7 @@ public class JavaEditorPreferencePage extends PreferencePage public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + public void widgetSelected(SelectionEvent e) { int i = fAppearanceColorList.getSelectionIndex(); String key = fAppearanceColorListModel[i][1]; @@ -983,185 +1035,193 @@ public class JavaEditorPreferencePage extends PreferencePage }); return appearanceComposite; } -// private Control createAnnotationsPage(Composite parent) { -// Composite composite = new Composite(parent, SWT.NULL); -// GridLayout layout = new GridLayout(); -// layout.numColumns = 2; -// composite.setLayout(layout); -// String text = PreferencesMessages -// .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$ -// addCheckBox(composite, text, -// PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); -// text = PreferencesMessages -// .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$ -// addCheckBox(composite, text, -// PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0); -// addFiller(composite); -// Label label = new Label(composite, SWT.LEFT); -// label.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$ -// GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); -// gd.horizontalSpan = 2; -// label.setLayoutData(gd); -// Composite editorComposite = new Composite(composite, SWT.NONE); -// layout = new GridLayout(); -// layout.numColumns = 2; -// layout.marginHeight = 0; -// layout.marginWidth = 0; -// editorComposite.setLayout(layout); -// gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); -// gd.horizontalSpan = 2; -// editorComposite.setLayoutData(gd); -// fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL -// | SWT.BORDER); -// gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING -// | GridData.FILL_HORIZONTAL); -// gd.heightHint = convertHeightInCharsToPixels(10); -// fAnnotationList.setLayoutData(gd); -// Composite optionsComposite = new Composite(editorComposite, SWT.NONE); -// layout = new GridLayout(); -// layout.marginHeight = 0; -// layout.marginWidth = 0; -// layout.numColumns = 2; -// optionsComposite.setLayout(layout); -// optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); -// fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK); -// fShowInTextCheckBox.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$ -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// gd.horizontalSpan = 2; -// fShowInTextCheckBox.setLayoutData(gd); -// fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY); -// for (int i = 0; i < fAnnotationDecorationListModel.length; i++) -// fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]); -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// gd.horizontalSpan = 2; -// gd.horizontalIndent = 20; -// fDecorationStyleCombo.setLayoutData(gd); -// fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK); -// fHighlightInTextCheckBox.setText(PreferencesMessages -// .getString("TextEditorPreferencePage.annotations.highlightInText")); //$NON-NLS-1$ -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// gd.horizontalSpan = 2; -// fHighlightInTextCheckBox.setLayoutData(gd); -// fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK); -// fShowInOverviewRulerCheckBox.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$ -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// gd.horizontalSpan = 2; -// fShowInOverviewRulerCheckBox.setLayoutData(gd); -// fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK); -// fShowInVerticalRulerCheckBox.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); //$NON-NLS-1$ -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// gd.horizontalSpan = 2; -// fShowInVerticalRulerCheckBox.setLayoutData(gd); -// label = new Label(optionsComposite, SWT.LEFT); -// label.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$ -// gd = new GridData(); -// gd.horizontalAlignment = GridData.BEGINNING; -// label.setLayoutData(gd); -// fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite); -// Button foregroundColorButton = fAnnotationForegroundColorEditor.getButton(); -// gd = new GridData(GridData.FILL_HORIZONTAL); -// gd.horizontalAlignment = GridData.BEGINNING; -// foregroundColorButton.setLayoutData(gd); -// fAnnotationList.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// handleAnnotationListSelection(); -// } -// }); -// fShowInTextCheckBox.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][2]; -// fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection()); -// String decorationKey = fAnnotationColorListModel[i][6]; -// fDecorationStyleCombo.setEnabled(decorationKey != null -// && fShowInTextCheckBox.getSelection()); -// } -// }); -// fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][4]; -// fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection()); -// } -// }); -// fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][3]; -// fOverlayStore -// .setValue(key, fShowInOverviewRulerCheckBox.getSelection()); -// } -// }); -// fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][5]; -// fOverlayStore -// .setValue(key, fShowInVerticalRulerCheckBox.getSelection()); -// } -// }); -// foregroundColorButton.addSelectionListener(new SelectionListener() { -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][1]; -// PreferenceConverter.setValue(fOverlayStore, key, -// fAnnotationForegroundColorEditor.getColorValue()); -// } -// }); -// fDecorationStyleCombo.addSelectionListener(new SelectionListener() { -// /** -// * {@inheritdoc} -// */ -// public void widgetDefaultSelected(SelectionEvent e) { -// // do nothing -// } -// /** -// * {@inheritdoc} -// */ -// public void widgetSelected(SelectionEvent e) { -// int i = fAnnotationList.getSelectionIndex(); -// String key = fAnnotationColorListModel[i][6]; -// if (key != null) { -// for (int j = 0; j < fAnnotationDecorationListModel.length; j++) { -// if (fAnnotationDecorationListModel[j][0] -// .equals(fDecorationStyleCombo.getText())) { -// fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]); -// break; -// } -// } -// } -// } -// }); -// return composite; -// } + + // private Control createAnnotationsPage(Composite parent) { + // Composite composite = new Composite(parent, SWT.NULL); + // GridLayout layout = new GridLayout(); + // layout.numColumns = 2; + // composite.setLayout(layout); + // String text = PreferencesMessages + // .getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); + // //$NON-NLS-1$ + // addCheckBox(composite, text, + // PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); + // text = PreferencesMessages + // .getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$ + // addCheckBox(composite, text, + // PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0); + // addFiller(composite); + // Label label = new Label(composite, SWT.LEFT); + // label.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotationPresentationOptions")); + // //$NON-NLS-1$ + // GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + // gd.horizontalSpan = 2; + // label.setLayoutData(gd); + // Composite editorComposite = new Composite(composite, SWT.NONE); + // layout = new GridLayout(); + // layout.numColumns = 2; + // layout.marginHeight = 0; + // layout.marginWidth = 0; + // editorComposite.setLayout(layout); + // gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); + // gd.horizontalSpan = 2; + // editorComposite.setLayoutData(gd); + // fAnnotationList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL + // | SWT.BORDER); + // gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING + // | GridData.FILL_HORIZONTAL); + // gd.heightHint = convertHeightInCharsToPixels(10); + // fAnnotationList.setLayoutData(gd); + // Composite optionsComposite = new Composite(editorComposite, SWT.NONE); + // layout = new GridLayout(); + // layout.marginHeight = 0; + // layout.marginWidth = 0; + // layout.numColumns = 2; + // optionsComposite.setLayout(layout); + // optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + // fShowInTextCheckBox = new Button(optionsComposite, SWT.CHECK); + // fShowInTextCheckBox.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotations.showInText")); + // //$NON-NLS-1$ + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // gd.horizontalSpan = 2; + // fShowInTextCheckBox.setLayoutData(gd); + // fDecorationStyleCombo = new Combo(optionsComposite, SWT.READ_ONLY); + // for (int i = 0; i < fAnnotationDecorationListModel.length; i++) + // fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]); + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // gd.horizontalSpan = 2; + // gd.horizontalIndent = 20; + // fDecorationStyleCombo.setLayoutData(gd); + // fHighlightInTextCheckBox = new Button(optionsComposite, SWT.CHECK); + // fHighlightInTextCheckBox.setText(PreferencesMessages + // .getString("TextEditorPreferencePage.annotations.highlightInText")); + // //$NON-NLS-1$ + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // gd.horizontalSpan = 2; + // fHighlightInTextCheckBox.setLayoutData(gd); + // fShowInOverviewRulerCheckBox = new Button(optionsComposite, SWT.CHECK); + // fShowInOverviewRulerCheckBox.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); + // //$NON-NLS-1$ + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // gd.horizontalSpan = 2; + // fShowInOverviewRulerCheckBox.setLayoutData(gd); + // fShowInVerticalRulerCheckBox = new Button(optionsComposite, SWT.CHECK); + // fShowInVerticalRulerCheckBox.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); + // //$NON-NLS-1$ + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // gd.horizontalSpan = 2; + // fShowInVerticalRulerCheckBox.setLayoutData(gd); + // label = new Label(optionsComposite, SWT.LEFT); + // label.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$ + // gd = new GridData(); + // gd.horizontalAlignment = GridData.BEGINNING; + // label.setLayoutData(gd); + // fAnnotationForegroundColorEditor = new ColorEditor(optionsComposite); + // Button foregroundColorButton = + // fAnnotationForegroundColorEditor.getButton(); + // gd = new GridData(GridData.FILL_HORIZONTAL); + // gd.horizontalAlignment = GridData.BEGINNING; + // foregroundColorButton.setLayoutData(gd); + // fAnnotationList.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // handleAnnotationListSelection(); + // } + // }); + // fShowInTextCheckBox.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][2]; + // fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection()); + // String decorationKey = fAnnotationColorListModel[i][6]; + // fDecorationStyleCombo.setEnabled(decorationKey != null + // && fShowInTextCheckBox.getSelection()); + // } + // }); + // fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][4]; + // fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection()); + // } + // }); + // fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][3]; + // fOverlayStore + // .setValue(key, fShowInOverviewRulerCheckBox.getSelection()); + // } + // }); + // fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][5]; + // fOverlayStore + // .setValue(key, fShowInVerticalRulerCheckBox.getSelection()); + // } + // }); + // foregroundColorButton.addSelectionListener(new SelectionListener() { + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][1]; + // PreferenceConverter.setValue(fOverlayStore, key, + // fAnnotationForegroundColorEditor.getColorValue()); + // } + // }); + // fDecorationStyleCombo.addSelectionListener(new SelectionListener() { + // /** + // * {@inheritdoc} + // */ + // public void widgetDefaultSelected(SelectionEvent e) { + // // do nothing + // } + // /** + // * {@inheritdoc} + // */ + // public void widgetSelected(SelectionEvent e) { + // int i = fAnnotationList.getSelectionIndex(); + // String key = fAnnotationColorListModel[i][6]; + // if (key != null) { + // for (int j = 0; j < fAnnotationDecorationListModel.length; j++) { + // if (fAnnotationDecorationListModel[j][0] + // .equals(fDecorationStyleCombo.getText())) { + // fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]); + // break; + // } + // } + // } + // } + // }); + // return composite; + // } private String[][] createAnnotationTypeListModel( MarkerAnnotationPreferences preferences) { ArrayList listModelItems = new ArrayList(); @@ -1184,100 +1244,102 @@ public class JavaEditorPreferencePage extends PreferencePage Iterator e = sortedPreferences.iterator(); while (e.hasNext()) { AnnotationPreference info = (AnnotationPreference) e.next(); - listModelItems.add(new String[]{info.getPreferenceLabel(), + listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), - info.getTextStylePreferenceKey()}); + info.getTextStylePreferenceKey() }); } String[][] items = new String[listModelItems.size()][]; listModelItems.toArray(items); return items; } + private Control createTypingPage(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; composite.setLayout(layout); - String label= - PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode"); - //$NON-NLS-1$ - addCheckBox(composite, label, - PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1); - addFiller(composite); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd"); - //$NON-NLS-1$ - addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, - 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation"); - //$NON-NLS-1$ - addCheckBox(composite, label, - PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1); - addFiller(composite); + String label; +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.overwriteMode"); +// //$NON-NLS-1$ +// addCheckBox(composite, label, +// PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1); +// addFiller(composite); +// +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.smartHomeEnd"); +// //$NON-NLS-1$ +// addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1); +// +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.subWordNavigation"); +// //$NON-NLS-1$ +// addCheckBox(composite, label, +// PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1); +// addFiller(composite); Group group = new Group(composite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; group.setLayout(layout); group.setText(PreferencesMessages .getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$ - label= - PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings"); - //$NON-NLS-1$ - Button button= addCheckBox(group, label, - PreferenceConstants.EDITOR_WRAP_STRINGS, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings"); - //$NON-NLS-1$ - fEscapeStringsButton= addCheckBox(group, label, - PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1); - createDependency(button, fEscapeStringsButton); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste"); - //$NON-NLS-1$ - addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs"); - //$NON-NLS-1$ - addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, - 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings"); - //$NON-NLS-1$ - addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets"); - //$NON-NLS-1$ - addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces"); - //$NON-NLS-1$ - addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs"); - //$NON-NLS-1$ - button= addCheckBox(group, label, - PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1); - - label= - PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); - //$NON-NLS-1$ - fAddJavaDocTagsButton= addCheckBox(group, label, - PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1); - createDependency(button, fAddJavaDocTagsButton); + +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.wrapStrings"); +// //$NON-NLS-1$ +// Button button = addCheckBox(group, label, +// PreferenceConstants.EDITOR_WRAP_STRINGS, 1); +// +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.escapeStrings"); +// //$NON-NLS-1$ +// fEscapeStringsButton = addCheckBox(group, label, +// PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1); +// createDependency(button, fEscapeStringsButton); + +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.smartPaste"); +// //$NON-NLS-1$ +// addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1); + + label = PreferencesMessages + .getString("JavaEditorPreferencePage.insertSpaceForTabs"); + //$NON-NLS-1$ + addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1); + + label = PreferencesMessages + .getString("JavaEditorPreferencePage.closeStrings"); + //$NON-NLS-1$ + addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS_PHP, 1); + + label = PreferencesMessages + .getString("JavaEditorPreferencePage.closeBrackets"); + //$NON-NLS-1$ + addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP, 1); + +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.closeBraces"); +// //$NON-NLS-1$ +// addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1); +// +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.closeJavaDocs"); +// //$NON-NLS-1$ +// button = addCheckBox(group, label, +// PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1); +// +// label = PreferencesMessages +// .getString("JavaEditorPreferencePage.addJavaDocTags"); +// //$NON-NLS-1$ +// fAddJavaDocTagsButton = addCheckBox(group, label, +// PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1); +// createDependency(button, fAddJavaDocTagsButton); return composite; } + private void addFiller(Composite composite) { Label filler = new Label(composite, SWT.LEFT); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); @@ -1285,143 +1347,25 @@ public class JavaEditorPreferencePage extends PreferencePage gd.heightHint = convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); } + private static void indent(Control control) { GridData gridData = new GridData(); gridData.horizontalIndent = 20; control.setLayoutData(gridData); } + private static void createDependency(final Button master, final Control slave) { indent(slave); master.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { slave.setEnabled(master.getSelection()); } + public void widgetDefaultSelected(SelectionEvent e) { } }); } - private Control createContentAssistPage(Composite parent) { - Composite contentAssistComposite = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - contentAssistComposite.setLayout(layout); - addCompletionRadioButtons(contentAssistComposite); - String label; - label = PreferencesMessages - .getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$ - addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_AUTOINSERT, 0); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$ - addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$ - addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$ - addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_ADDIMPORT, 0); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ - Button button = addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ - // fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, - // PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0); - // createDependency(button, fGuessMethodArgumentsButton); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$ - final Button autoactivation = addCheckBox(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0); - autoactivation.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateAutoactivationControls(); - } - }); - Control[] labelledTextField; - label = PreferencesMessages - .getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$ - labelledTextField = addLabelledTextField(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true); - fAutoInsertDelayLabel = getLabelControl(labelledTextField); - fAutoInsertDelayText = getTextControl(labelledTextField); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$ - labelledTextField = addLabelledTextField(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, - false); - fAutoInsertJavaTriggerLabel = getLabelControl(labelledTextField); - fAutoInsertJavaTriggerText = getTextControl(labelledTextField); - label = PreferencesMessages - .getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$ - labelledTextField = addLabelledTextField(contentAssistComposite, label, - PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, - false); - fAutoInsertJavaDocTriggerLabel = getLabelControl(labelledTextField); - fAutoInsertJavaDocTriggerText = getTextControl(labelledTextField); - Label l = new Label(contentAssistComposite, SWT.LEFT); - l.setText(PreferencesMessages - .getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$ - GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan = 2; - l.setLayoutData(gd); - Composite editorComposite = new Composite(contentAssistComposite, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 0; - layout.marginWidth = 0; - editorComposite.setLayout(layout); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); - gd.horizontalSpan = 2; - editorComposite.setLayoutData(gd); - fContentAssistColorList = new List(editorComposite, SWT.SINGLE - | SWT.V_SCROLL | SWT.BORDER); - gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING - | GridData.FILL_HORIZONTAL); - gd.heightHint = convertHeightInCharsToPixels(8); - fContentAssistColorList.setLayoutData(gd); - Composite stylesComposite = new Composite(editorComposite, SWT.NONE); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 2; - stylesComposite.setLayout(layout); - stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - l = new Label(stylesComposite, SWT.LEFT); - l.setText(PreferencesMessages - .getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$ - gd = new GridData(); - gd.horizontalAlignment = GridData.BEGINNING; - l.setLayoutData(gd); - fContentAssistColorEditor = new ColorEditor(stylesComposite); - Button colorButton = fContentAssistColorEditor.getButton(); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment = GridData.BEGINNING; - colorButton.setLayoutData(gd); - fContentAssistColorList.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - public void widgetSelected(SelectionEvent e) { - handleContentAssistColorListSelection(); - } - }); - colorButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - public void widgetSelected(SelectionEvent e) { - int i = fContentAssistColorList.getSelectionIndex(); - String key = fContentAssistColorListModel[i][1]; - PreferenceConverter.setValue(fOverlayStore, key, - fContentAssistColorEditor.getColorValue()); - } - }); - return contentAssistComposite; - } + private void addCompletionRadioButtons(Composite contentAssistComposite) { Composite completionComposite = new Composite(contentAssistComposite, SWT.NONE); @@ -1454,6 +1398,7 @@ public class JavaEditorPreferencePage extends PreferencePage // fCompletionOverwritesRadioButton.setLayoutData(new GridData()); // fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener); } + private Control createNavigationPage(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); @@ -1550,6 +1495,7 @@ public class JavaEditorPreferencePage extends PreferencePage // }); return composite; } + private void handleBrowserLikeLinksKeyModifierModified() { // String modifiers= fBrowserLikeLinksKeyModifierText.getText(); // int stateMask= computeStateMask(modifiers); @@ -1570,6 +1516,7 @@ public class JavaEditorPreferencePage extends PreferencePage // updateStatus(fBrowserLikeLinksKeyModifierStatus); // } } + // private IStatus getBrowserLikeLinksKeyModifierStatus() { // if (fBrowserLikeLinksKeyModifierStatus == null) // fBrowserLikeLinksKeyModifierStatus= new StatusInfo(); @@ -1579,8 +1526,8 @@ public class JavaEditorPreferencePage extends PreferencePage * Computes the state mask for the given modifier string. * * @param modifiers - * the string with the modifiers, separated by '+', '-', ';', ',' - * or '.' + * the string with the modifiers, separated by '+', '-', ';', ',' or + * '.' * @return the state mask or -1 if the input is invalid */ private int computeStateMask(String modifiers) { @@ -1600,12 +1547,13 @@ public class JavaEditorPreferencePage extends PreferencePage } return stateMask; } + /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { initializeDefaultColors(); - fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore); + fFoldingConfigurationBlock = new FoldingConfigurationBlock(fOverlayStore); fOverlayStore.load(); fOverlayStore.start(); TabFolder folder = new TabFolder(parent, SWT.NONE); @@ -1619,35 +1567,39 @@ public class JavaEditorPreferencePage extends PreferencePage item.setText(PreferencesMessages .getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$ item.setControl(createSyntaxPage(folder)); - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist")); - //$NON-NLS-1$ - item.setControl(createContentAssistPage(folder)); -// item = new TabItem(folder, SWT.NONE); -// item.setText(PreferencesMessages -// .getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$ -// item.setControl(createAnnotationsPage(folder)); - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle")); - //$NON-NLS-1$ - item.setControl(createTypingPage(folder)); - - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title")); - //$NON-NLS-1$ - fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore); - item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder)); -// item= new TabItem(folder, SWT.NONE); -// item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$ -// item.setControl(createNavigationPage(folder)); - item= new TabItem(folder, SWT.NONE); - item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$ - item.setControl(fFoldingConfigurationBlock.createControl(folder)); + + // item = new TabItem(folder, SWT.NONE); + // item.setText(PreferencesMessages + // .getString("JavaEditorPreferencePage.annotationsTab.title")); + // //$NON-NLS-1$ + // item.setControl(createAnnotationsPage(folder)); + item = new TabItem(folder, SWT.NONE); + item.setText(PreferencesMessages + .getString("JavaEditorPreferencePage.typing.tabTitle")); + //$NON-NLS-1$ + item.setControl(createTypingPage(folder)); + + item = new TabItem(folder, SWT.NONE); + item.setText(PreferencesMessages + .getString("JavaEditorPreferencePage.hoverTab.title")); + //$NON-NLS-1$ + fJavaEditorHoverConfigurationBlock = new JavaEditorHoverConfigurationBlock( + this, fOverlayStore); + item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder)); + // item= new TabItem(folder, SWT.NONE); + // item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); + // //$NON-NLS-1$ + // item.setControl(createNavigationPage(folder)); + item = new TabItem(folder, SWT.NONE); + item.setText(PreferencesMessages + .getString("JavaEditorPreferencePage.folding.title")); //$NON-NLS-1$ + item.setControl(fFoldingConfigurationBlock.createControl(folder)); initialize(); Dialog.applyDialogFont(folder); return folder; } + private void initialize() { initializeFields(); for (int i = 0; i < fSyntaxColorListModel.length; i++) @@ -1670,16 +1622,16 @@ public class JavaEditorPreferencePage extends PreferencePage } } }); -// for (int i = 0; i < fAnnotationColorListModel.length; i++) -// fAnnotationList.add(fAnnotationColorListModel[i][0]); -// fAnnotationList.getDisplay().asyncExec(new Runnable() { -// public void run() { -// if (fAnnotationList != null && !fAnnotationList.isDisposed()) { -// fAnnotationList.select(0); -// handleAnnotationListSelection(); -// } -// } -// }); + // for (int i = 0; i < fAnnotationColorListModel.length; i++) + // fAnnotationList.add(fAnnotationColorListModel[i][0]); + // fAnnotationList.getDisplay().asyncExec(new Runnable() { + // public void run() { + // if (fAnnotationList != null && !fAnnotationList.isDisposed()) { + // fAnnotationList.select(0); + // handleAnnotationListSelection(); + // } + // } + // }); // for (int i= 0; i < fContentAssistColorListModel.length; i++) // fContentAssistColorList.add(fContentAssistColorListModel[i][0]); // fContentAssistColorList.getDisplay().asyncExec(new Runnable() { @@ -1693,6 +1645,7 @@ public class JavaEditorPreferencePage extends PreferencePage // }); fFoldingConfigurationBlock.initialize(); } + private void initializeFields() { Iterator e = fColorButtons.keySet().iterator(); while (e.hasNext()) { @@ -1721,10 +1674,11 @@ public class JavaEditorPreferencePage extends PreferencePage fBackgroundDefaultRadioButton.setSelection(default_); fBackgroundCustomRadioButton.setSelection(!default_); fBackgroundColorButton.setEnabled(!default_); - boolean closeJavaDocs= - fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS); - fAddJavaDocTagsButton.setEnabled(closeJavaDocs); - fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS)); +// boolean closeJavaDocs = fOverlayStore +// .getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS); +// fAddJavaDocTagsButton.setEnabled(closeJavaDocs); +// fEscapeStringsButton.setEnabled(fOverlayStore +// .getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS)); // boolean fillMethodArguments= // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES); // fGuessMethodArgumentsButton.setEnabled(fillMethodArguments); @@ -1739,6 +1693,7 @@ public class JavaEditorPreferencePage extends PreferencePage // fStickyOccurrencesButton.setEnabled(markOccurrences); updateAutoactivationControls(); } + private void initializeDefaultColors() { if (!getPreferenceStore().contains( PreferenceConstants.EDITOR_BACKGROUND_COLOR)) { @@ -1759,6 +1714,7 @@ public class JavaEditorPreferencePage extends PreferencePage PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb); } } + private void updateAutoactivationControls() { // boolean autoactivation= // fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION); @@ -1770,18 +1726,20 @@ public class JavaEditorPreferencePage extends PreferencePage // fAutoInsertJavaDocTriggerText.setEnabled(autoactivation); // fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation); } + /* * @see PreferencePage#performOk() */ public boolean performOk() { // fJavaEditorHoverConfigurationBlock.performOk(); - fFoldingConfigurationBlock.performOk(); + fFoldingConfigurationBlock.performOk(); // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, // computeStateMask(fBrowserLikeLinksKeyModifierText.getText())); fOverlayStore.propagate(); PHPeclipsePlugin.getDefault().savePluginPreferences(); return true; } + /* * @see PreferencePage#performDefaults() */ @@ -1790,19 +1748,20 @@ public class JavaEditorPreferencePage extends PreferencePage initializeFields(); handleSyntaxColorListSelection(); handleAppearanceColorListSelection(); -// handleAnnotationListSelection(); + // handleAnnotationListSelection(); // handleContentAssistColorListSelection(); // fJavaEditorHoverConfigurationBlock.performDefaults(); fFoldingConfigurationBlock.performDefaults(); super.performDefaults(); fPreviewViewer.invalidateTextPresentation(); } + /* * @see DialogPage#dispose() */ public void dispose() { - fFoldingConfigurationBlock.dispose(); - + fFoldingConfigurationBlock.dispose(); + if (fJavaTextTools != null) { fJavaTextTools.dispose(); fJavaTextTools = null; @@ -1815,6 +1774,7 @@ public class JavaEditorPreferencePage extends PreferencePage fBackgroundColor.dispose(); super.dispose(); } + private Button addCheckBox(Composite parent, String label, String key, int indentation) { Button checkBox = new Button(parent, SWT.CHECK); @@ -1827,21 +1787,26 @@ public class JavaEditorPreferencePage extends PreferencePage fCheckBoxes.put(checkBox, key); return checkBox; } + private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber)); } + private static Label getLabelControl(Control[] labelledTextField) { return (Label) labelledTextField[0]; } + private static Text getTextControl(Control[] labelledTextField) { return (Text) labelledTextField[1]; } + /** * Returns an array of size 2: - first element is of type Label- - * second element is of type Text Use getLabelControl - * and getTextControl to get the 2 controls. + * second element is of type Text Use + * getLabelControl and getTextControl to get the + * 2 controls. */ private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { @@ -1862,8 +1827,9 @@ public class JavaEditorPreferencePage extends PreferencePage } else { textControl.addModifyListener(fTextFieldListener); } - return new Control[]{labelControl, textControl}; + return new Control[] { labelControl, textControl }; } + private String loadPreviewContentFromFile(String filename) { String line; String separator = System.getProperty("line.separator"); //$NON-NLS-1$ @@ -1888,6 +1854,7 @@ public class JavaEditorPreferencePage extends PreferencePage } return buffer.toString(); } + private void numberFieldChanged(Text textControl) { String number = textControl.getText(); IStatus status = validatePositiveNumber(number); @@ -1895,6 +1862,7 @@ public class JavaEditorPreferencePage extends PreferencePage fOverlayStore.setValue((String) fTextFields.get(textControl), number); updateStatus(status); } + private IStatus validatePositiveNumber(String number) { StatusInfo status = new StatusInfo(); if (number.length() == 0) { @@ -1913,6 +1881,7 @@ public class JavaEditorPreferencePage extends PreferencePage } return status; } + void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { for (int i = 0; i < fNumberFields.size(); i++) { @@ -1929,4 +1898,4 @@ public class JavaEditorPreferencePage extends PreferencePage setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } -} +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties index 3800019..6363cbc 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties @@ -11,8 +11,8 @@ BuildPathsPropertyPage.error.message=An error occurred while setting the build path BuildPathsPropertyPage.error.title=Error Setting Build Path -BuildPathsPropertyPage.no_java_project.message=Not a Java project. -BuildPathsPropertyPage.closed_project.message=Java information is not available for a closed project. +BuildPathsPropertyPage.no_java_project.message=Not a PHP project. +BuildPathsPropertyPage.closed_project.message=PHP information is not available for a closed project. ClasspathVariablesPreferencePage.title=Classpath Variables ClasspathVariablesPreferencePage.description=A classpath variable can be added to a project's class path. It can be used to define the location of a JAR file that isn't part of the workspace. The reserved class path variables JRE_LIB, JRE_SRC, JRE_SRCROOT are set internally depending on the JRE setting. @@ -52,9 +52,9 @@ ImportOrganizeInputDialog.error.enterName=Enter a package name. ImportOrganizeInputDialog.error.invalidName=Not a valid package name. {0} ImportOrganizeInputDialog.error.entryExists=Package name already exists in list. -JavaBasePreferencePage.description=General settings for Java development: +JavaBasePreferencePage.description=General settings for PHP development: -JavaBasePreferencePage.updateJavaViews=Update Java views +JavaBasePreferencePage.updateJavaViews=Update PHP views JavaBasePreferencePage.onSave=On &save only JavaBasePreferencePage.whileEditing=While &editing JavaBasePreferencePage.note=Note: @@ -67,7 +67,7 @@ JavaBasePreferencePage.doubleclick.action=Action on double click in the Package JavaBasePreferencePage.doubleclick.gointo=&Go into the selected element JavaBasePreferencePage.doubleclick.expand=E&xpand the selected element -NewJavaProjectPreferencePage.description=Specify the classpath entries used as default by the New Java Project creation wizard: +NewJavaProjectPreferencePage.description=Specify the classpath entries used as default by the New PHP Project creation wizard: NewJavaProjectPreferencePage.sourcefolder.label=Source and output folder NewJavaProjectPreferencePage.sourcefolder.project=&Project @@ -75,22 +75,16 @@ NewJavaProjectPreferencePage.sourcefolder.folder=&Folders NewJavaProjectPreferencePage.folders.src=&Source folder name: NewJavaProjectPreferencePage.folders.bin=&Output folder name: -NewJavaProjectPreferencePage.jrelibrary.label=As &JRE library use: -NewJavaProjectPreferencePage.jre_variable.description=JRE_LIB variable -NewJavaProjectPreferencePage.jre_container.description=JRE container - NewJavaProjectPreferencePage.folders.error.namesempty=Enter folder names. NewJavaProjectPreferencePage.folders.error.invalidsrcname=Invalid source folder name: {0} NewJavaProjectPreferencePage.folders.error.invalidbinname=Invalid output folder name: {0} NewJavaProjectPreferencePage.folders.error.invalidcp=Settings will result in an invalid build path. Check for nested folders. -NewJavaProjectPreferencePage.error.decode=Error while decoding JRE entry - JavaEditorPreferencePage.annotationsTab.title= Annotation&s JavaEditorPreferencePage.showQuickFixables= Indicate annotations solvable with &Quick Fix in vertical ruler JavaEditorPreferencePage.analyseAnnotationsWhileTyping= Analyze annotations &while typing JavaEditorPreferencePage.annotationPresentationOptions= Annotation &presentation: -JavaEditorPreferencePage.description=Java Editor settings: +JavaEditorPreferencePage.description=PHP Editor settings: JavaEditorPreferencePage.annotations.bookmarks= Bookmarks JavaEditorPreferencePage.annotations.searchResults= Search Results JavaEditorPreferencePage.annotations.errors= Errors @@ -111,10 +105,10 @@ JavaEditorPreferencePage.others=Others JavaEditorPreferencePage.methodNames=Method names JavaEditorPreferencePage.operators=Operators and brackets JavaEditorPreferencePage.javaCommentTaskTags=Task Tags -JavaEditorPreferencePage.javaDocKeywords=Javadoc keywords -JavaEditorPreferencePage.javaDocHtmlTags=Javadoc HTML tags -JavaEditorPreferencePage.javaDocLinks=Javadoc links -JavaEditorPreferencePage.javaDocOthers=Javadoc others +JavaEditorPreferencePage.javaDocKeywords=PHPdoc keywords +JavaEditorPreferencePage.javaDocHtmlTags=PHPdoc HTML tags +JavaEditorPreferencePage.javaDocLinks=PHPdoc links +JavaEditorPreferencePage.javaDocOthers=PHPdoc others JavaEditorPreferencePage.backgroundColor=Background color JavaEditorPreferencePage.systemDefault=S&ystem Default JavaEditorPreferencePage.custom=C&ustom: @@ -139,8 +133,9 @@ JavaEditorPreferencePage.completionOverwrites=Completion over&writes JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion=&Fill argument names on method completion JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion=&Guess filled argument names JavaEditorPreferencePage.autoActivationDelay=A&uto activation delay: -JavaEditorPreferencePage.autoActivationTriggersForJava=Auto activation &triggers for Java: -JavaEditorPreferencePage.autoActivationTriggersForJavaDoc=Auto activation triggers for &Javadoc: +JavaEditorPreferencePage.autoActivationTriggersForJava=Auto activation &triggers for PHP: +JavaEditorPreferencePage.autoActivationTriggersForJavaDoc=Auto activation triggers for &PHPdoc: +JavaEditorPreferencePage.autoActivationTriggersForHTML=Auto activation triggers for &HTML: JavaEditorPreferencePage.codeAssist.colorOptions= Code assist colo&r options: JavaEditorPreferencePage.codeAssist.color= C&olor: @@ -175,15 +170,15 @@ JavaEditorPreferencePage.typing.description= Select options for automatic text m JavaEditorPreferencePage.closeStrings= Close strin&gs JavaEditorPreferencePage.closeBrackets= Close &brackets and parenthesis JavaEditorPreferencePage.closeBraces= Cl&ose braces -JavaEditorPreferencePage.closeJavaDocs= Close Java&docs and comments -JavaEditorPreferencePage.wrapStrings= Wra&p Java strings +JavaEditorPreferencePage.closeJavaDocs= Close PHP&docs and comments +JavaEditorPreferencePage.wrapStrings= Wra&p PHP strings JavaEditorPreferencePage.escapeStrings= &Escape text when pasting into a string literal -JavaEditorPreferencePage.addJavaDocTags= Add Javadoc &tags +JavaEditorPreferencePage.addJavaDocTags= Add PHPdoc &tags JavaEditorPreferencePage.smartPaste= Pasting fo&r correct indentation JavaEditorPreferencePage.smartHomeEnd= S&mart cursor positioning at line start and end -JavaEditorPreferencePage.subWordNavigation= Smart cursor positioning in &Java names -JavaEditorPreferencePage.overwriteMode= Disable over&write typing mode in Java editors +JavaEditorPreferencePage.subWordNavigation= Smart cursor positioning in &PHP names +JavaEditorPreferencePage.overwriteMode= Disable over&write typing mode in PHP editors JavaEditorPreferencePage.hoverTab.title= Ho&vers @@ -230,49 +225,49 @@ JavaElementInfoPage.variable=variable JavaElementInfoPage.variable_path=Variable path: JavaElementInfoPage.location=Location: -JavadocConfigurationPropertyPage.IsPackageFragmentRoot.description=Specify the location (URL) of the documentation generated by Javadoc. The Javadoc location will contain a file called 'package-list'. -JavadocConfigurationPropertyPage.IsIncorrectElement.description=Javadoc location can only be attached to Java projects or JAR files in Java projects -JavadocConfigurationPropertyPage.IsJavaProject.description=Specify the location of the project\'s Javadoc documentation. This location is used by the Javadoc export wizard as the default value and by the \'Open External Javadoc\' action. For example: \'c:/myworkspace/myproject/doc\'. +JavadocConfigurationPropertyPage.IsPackageFragmentRoot.description=Specify the location (URL) of the documentation generated by PHPdoc. The PHPdoc location will contain a file called 'package-list'. +JavadocConfigurationPropertyPage.IsIncorrectElement.description=PHPdoc location can only be attached to PHP projects or JAR files in PHP projects +JavadocConfigurationPropertyPage.IsJavaProject.description=Specify the location of the project\'s PHPdoc documentation. This location is used by the PHPdoc export wizard as the default value and by the \'Open External PHPdoc\' action. For example: \'c:/myworkspace/myproject/doc\'. JavadocConfigurationBlock.browse.button=&Browse... JavadocConfigurationBlock.error.notafolder=Location does not exist. JavadocConfigurationBlock.warning.packagelistnotfound=Location does not contain file 'package-list'. -JavadocConfigurationBlock.javadocFolderDialog.label=Javadoc Location Selection -JavadocConfigurationBlock.javadocFolderDialog.message=Select Javadoc location: -JavadocConfigurationBlock.javadocArchiveDialog.label=Javadoc Archive Selection +JavadocConfigurationBlock.javadocFolderDialog.label=PHPdoc Location Selection +JavadocConfigurationBlock.javadocFolderDialog.message=Select PHPdoc location: +JavadocConfigurationBlock.javadocArchiveDialog.label=PHPdoc Archive Selection JavadocConfigurationBlock.MalformedURL.error=Invalid URL JavadocConfigurationBlock.validate.button=&Validate... JavadocConfigurationBlock.InvalidLocation.message= Location is invalid. Location contains neither the file \'package-list\' nor \'index.html'. JavadocConfigurationBlock.ValidLocation.message= Location is valid. Files \'package-list\' and \'index.html\' found. Click OK to open in browser. JavadocConfigurationBlock.UnableToValidateLocation.message=Unable to validate location -JavadocConfigurationBlock.MessageDialog.title=Validating Javadoc Location -JavadocConfigurationBlock.location.type.path.label=Javadoc URL (e.g. \'http://www.sample-url.org/doc/\' or 'file:/c:/myworkspace/myproject/doc\') -JavadocConfigurationBlock.location.type.jar.label=Javadoc in archive -JavadocConfigurationBlock.location.path.label=Javadoc &location path: +JavadocConfigurationBlock.MessageDialog.title=Validating PHPdoc Location +JavadocConfigurationBlock.location.type.path.label=PHPdoc URL (e.g. \'http://www.sample-url.org/doc/\' or 'file:/c:/myworkspace/myproject/doc\') +JavadocConfigurationBlock.location.type.jar.label=PHPdoc in archive +JavadocConfigurationBlock.location.path.label=PHPdoc &location path: JavadocConfigurationBlock.location.jar.label=Archive &path: JavadocConfigurationBlock.jar.path.label=Path &within archive: -JavadocConfigurationBlock.zipImportSource.title=Javadoc Archive Selection -JavadocConfigurationBlock.location_in_jarorzip.message=&Select the folder that is the root of the Javadoc documentation: -JavadocConfigurationBlock.browse_jarorzip_path.title=Javadoc Root Location +JavadocConfigurationBlock.zipImportSource.title=PHPdoc Archive Selection +JavadocConfigurationBlock.location_in_jarorzip.message=&Select the folder that is the root of the PHPdoc documentation: +JavadocConfigurationBlock.browse_jarorzip_path.title=PHPdoc Root Location JavadocConfigurationBlock.error.notafile=Archive does not exist -JavadocPreferencePage.description=Specify the location of the Javadoc command to be used by the Javadoc export wizard. Location must be an absolute path. -JavadocPreferencePage.command.label=&Javadoc command: +JavadocPreferencePage.description=Specify the location of the PHPdoc command to be used by the PHPdoc export wizard. Location must be an absolute path. +JavadocPreferencePage.command.label=&PHPdoc command: JavadocPreferencePage.command.button=&Browse... -JavadocPreferencePage.error.notexists=Javadoc command does not exist -JavadocPreferencePage.info.notset=Set to enable Javadoc generation tool. +JavadocPreferencePage.error.notexists=PHPdoc command does not exist +JavadocPreferencePage.info.notset=Set to enable PHPdoc generation tool. -JavadocPreferencePage.browsedialog.title=Javadoc Command Selection +JavadocPreferencePage.browsedialog.title=PHPdoc Command Selection SourceAttachmentPropertyPage.error.title=Error Attaching Source SourceAttachmentPropertyPage.error.message=An error occurred while associating the source -SourceAttachmentPropertyPage.noarchive.message=Source can only be attached to JAR files in Java projects. +SourceAttachmentPropertyPage.noarchive.message=Source can only be attached to JAR files in PHP projects. SourceAttachmentPropertyPage.containerentry.message=JAR belongs to the container ''{0}''.\nTo configure the source attachment, go directly to the corresponding configuration page (For example for JREs go to ''Installed JREs'' page in the preferences). -AppearancePreferencePage.description= Appearance of Java elements in viewers: +AppearancePreferencePage.description= Appearance of PHP elements in viewers: AppearancePreferencePage.methodreturntype.label= Show &method return types AppearancePreferencePage.overrideindicator.label= Show &override indicators in outline and hierarchy AppearancePreferencePage.pkgNamePatternEnable.label= &Compress all package name segments, except the final segment @@ -303,12 +298,12 @@ CodeFormatterPreferencePage.tab_char.label=Insert &tabs for indentation, not spa CodeFormatterPreferencePage.tab_size.label=&Number of spaces representing an indentation level: CodeFormatterPreferencePage.comment_format.label=&Format comments CodeFormatterPreferencePage.comment_formathtml.label=Format HTML &tags -CodeFormatterPreferencePage.comment_formatsource.label=Format Java code &snippets -CodeFormatterPreferencePage.comment_indentroottags.label=&Indent Javadoc tags -CodeFormatterPreferencePage.comment_newlineparam.label=&New line after Javadoc tag parameters -CodeFormatterPreferencePage.comment_separateroottags.label=&Empty line before Javadoc tag block +CodeFormatterPreferencePage.comment_formatsource.label=Format PHP code &snippets +CodeFormatterPreferencePage.comment_indentroottags.label=&Indent PHPdoc tags +CodeFormatterPreferencePage.comment_newlineparam.label=&New line after PHPdoc tag parameters +CodeFormatterPreferencePage.comment_separateroottags.label=&Empty line before PHPdoc tag block CodeFormatterPreferencePage.comment_formatheader.label=Format &header comment -CodeFormatterPreferencePage.comment_indentparamdesc.label= Indent Javadoc parameter &descriptions +CodeFormatterPreferencePage.comment_indentparamdesc.label= Indent PHPdoc parameter &descriptions CodeFormatterPreferencePage.tab.newline.tabtitle=Ne&w Lines CodeFormatterPreferencePage.tab.linesplit.tabtitle=Line Len>h @@ -324,7 +319,7 @@ TodoTaskPropertyPage.useprojectsettings.label=Use pr&oject settings TodoTaskConfigurationBlock.markers.tasks.high.priority=High TodoTaskConfigurationBlock.markers.tasks.normal.priority=Normal TodoTaskConfigurationBlock.markers.tasks.low.priority=Low -TodoTaskConfigurationBlock.markers.tasks.label=&Strings indicating tasks in Java comments: +TodoTaskConfigurationBlock.markers.tasks.label=&Strings indicating tasks in PHP comments: TodoTaskConfigurationBlock.markers.tasks.add.button=&New... TodoTaskConfigurationBlock.markers.tasks.remove.button=&Remove TodoTaskConfigurationBlock.markers.tasks.edit.button=&Edit... @@ -348,7 +343,7 @@ TodoTaskInputDialog.error.entryExists=Entry with the same name already exists. TodoTaskInputDialog.error.noSpace=Name can not start or end with a whitespace. CompilerPreferencePage.title=Compiler -CompilerPreferencePage.description=Options for the Java compiler:\nNote that a full rebuild is required to make changes effective. +CompilerPreferencePage.description=Options for the PHP compiler:\nNote that a full rebuild is required to make changes effective. CompilerPropertyPage.useworkspacesettings.label=Use &workspace settings CompilerPropertyPage.useworkspacesettings.change=&Configure Workspace Settings... @@ -359,7 +354,7 @@ CompilerConfigurationBlock.unused.tabtitle=&Unused Code CompilerConfigurationBlock.common.tabtitle=&Style CompilerConfigurationBlock.compliance.tabtitle=&Compliance and Classfiles CompilerConfigurationBlock.others.tabtitle=Build &Path -CompilerConfigurationBlock.javadoc.tabtitle=&Javadoc +CompilerConfigurationBlock.javadoc.tabtitle=&PHPdoc CompilerConfigurationBlock.common.description=Select the severity level for the following problems: CompilerConfigurationBlock.unused.description=Select the severity level for the following problems: @@ -428,15 +423,15 @@ CompilerConfigurationBlock.pb_unused_throwing_exception.label=Unnecessary declar CompilerConfigurationBlock.pb_unused_throwing_exception_when_overriding.label=Check &overriding and implementing methods CompilerConfigurationBlock.javadoc.description=Select the severity level for the following problems: -CompilerConfigurationBlock.pb_invalid_javadoc.label=Mal&formed Javadoc comments: +CompilerConfigurationBlock.pb_invalid_javadoc.label=Mal&formed PHPdoc comments: CompilerConfigurationBlock.pb_invalid_javadoc_tags.label=Report e&rrors in tags CompilerConfigurationBlock.pb_invalid_javadoc_tags_visibility.label=On&ly consider members as visible as: -CompilerConfigurationBlock.pb_missing_javadoc.label=Missing Javadoc &tags: +CompilerConfigurationBlock.pb_missing_javadoc.label=Missing PHPdoc &tags: CompilerConfigurationBlock.pb_missing_javadoc_tags_visibility.label=O&nly consider members as visible as: CompilerConfigurationBlock.pb_missing_javadoc_tags_overriding.label=C&heck overriding and implementing methods -CompilerConfigurationBlock.pb_missing_comments.label=&Missing Javadoc comments: +CompilerConfigurationBlock.pb_missing_comments.label=&Missing PHPdoc comments: CompilerConfigurationBlock.pb_missing_comments_visibility.label=&Only consider members as visible as: CompilerConfigurationBlock.pb_missing_comments_overriding.label=Ch&eck overriding and implementing methods @@ -556,7 +551,7 @@ CodeTemplateBlock.templates.code.node=Code CodeTemplateBlock.catchblock.label=Catch block body CodeTemplateBlock.methodstub.label=Method body CodeTemplateBlock.constructorstub.label=Constructor body -CodeTemplateBlock.newtype.label=New Java files +CodeTemplateBlock.newtype.label=New PHP files CodeTemplateBlock.typecomment.label=Types CodeTemplateBlock.fieldcomment.label=Fields CodeTemplateBlock.methodcomment.label=Methods @@ -627,7 +622,7 @@ WorkInProgress.quickdiff.addedLineColor= Added lines background WorkInProgress.quickdiff.deletedLineColor= Deleted lines indicator WorkInProgress.quickdiff.appearanceOptions= Appearance color options: WorkInProgress.editor=Editor -WorkInProgress.formatComments= Enable formatting of Javadoc, multi- and single line comments (reopen editor for activation) +WorkInProgress.formatComments= Enable formatting of PHPdoc, multi- and single line comments (reopen editor for activation) WorkInProgress.smartTyping.label= Enable the following functions in Smart Insert typing mode WorkInProgress.smartTyping.smartSemicolon= Smart &Semicolon WorkInProgress.smartTyping.smartOpeningBrace= Smart Opening &Brace @@ -647,7 +642,7 @@ WorkInProgress.newsearch.option=Use new search view WorkInProgress.search.ignore_imports=Ignore references in imports statements WorkInProgress.rollover= Enable annotation &roll-over (does not affect already open editors) -JavadocPreferencePage.title=Javadoc +JavadocPreferencePage.title=PHPdoc SpellingPreferencePage.description=Options for Spelling: SpellingPreferencePage.title=Spelling diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java index e9a271f..ab65d86 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/PreferenceConstants.java @@ -773,7 +773,17 @@ public class PreferenceConstants { * @since 3.0 */ public final static String EDITOR_ESCAPE_STRINGS= "escapeStrings"; //$NON-NLS-1$ - + /** + * A named preference that controls if content assist inserts the common + * prefix of all proposals before presenting choices. + *

+ * Value is of type Boolean. + *

+ * + * @since 3.0 + */ + public final static String CODEASSIST_PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$ + /** * A named preference that controls whether the 'close braces' feature is * enabled. @@ -2360,7 +2370,8 @@ public final static String EDITOR_TEXT_FONT= "net.sourceforge.phpdt.ui.editors.t store.setDefault(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, true); store.setDefault(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, false); store.setDefault(PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, true); - + store.setDefault(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, false); + store.setDefault(PreferenceConstants.EDITOR_SMART_HOME_END, true); store.setDefault(PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, true); store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true); -- 1.7.1