X-Git-Url: http://git.phpeclipse.com 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 a857b52..c702b12 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 @@ -21,10 +21,12 @@ import java.util.Map; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; + import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds; import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo; import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil; +import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter; import net.sourceforge.phpdt.internal.ui.util.TabFolderLayout; import net.sourceforge.phpdt.ui.PreferenceConstants; import net.sourceforge.phpdt.ui.text.JavaTextTools; @@ -33,10 +35,13 @@ import net.sourceforge.phpeclipse.phpeditor.EditorUtility; import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer; import net.sourceforge.phpeclipse.phpeditor.PHPSourceViewerConfiguration; import net.sourceforge.phpeclipse.preferences.ColorEditor; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.action.Action; +import net.sourceforge.phpdt.internal.ui.preferences.FoldingConfigurationBlock; +import net.sourceforge.phpdt.internal.ui.preferences.PreferencesMessages; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; @@ -44,16 +49,12 @@ import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; 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.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -70,9 +71,11 @@ import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.help.WorkbenchHelp; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AnnotationPreference; -import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants; +import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; /** * The page for setting the editor options. @@ -166,7 +169,7 @@ public class JavaEditorPreferencePage extends PreferencePage { PreferencesMessages .getString("JavaEditorPreferencePage.lineNumberForegroundColor"), - ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$ { PreferencesMessages @@ -176,12 +179,12 @@ public class JavaEditorPreferencePage extends PreferencePage { PreferencesMessages .getString("JavaEditorPreferencePage.currentLineHighlighColor"), - ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$ { PreferencesMessages .getString("JavaEditorPreferencePage.printMarginColor2"), - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$ { PreferencesMessages @@ -191,7 +194,7 @@ public class JavaEditorPreferencePage extends PreferencePage {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR}, //$NON-NLS-1$ }; - private final String[][] fAnnotationColorListModel; +// private final String[][] fAnnotationColorListModel; private final String[][] fContentAssistColorListModel = new String[][]{ { PreferencesMessages @@ -223,35 +226,37 @@ public class JavaEditorPreferencePage extends PreferencePage .getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND} //$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[][] 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() { @@ -321,7 +326,7 @@ 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) { @@ -423,19 +428,19 @@ public class JavaEditorPreferencePage extends PreferencePage PreferenceConstants.EDITOR_MATCHING_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, - ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, - ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.INT, - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); // overlayKeys.add(new // OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, // PreferenceConstants.EDITOR_MARK_OCCURRENCES)); @@ -455,13 +460,13 @@ public class JavaEditorPreferencePage extends PreferencePage PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, - ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.STRING, - ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, - ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey( OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS)); @@ -630,56 +635,56 @@ public class JavaEditorPreferencePage extends PreferencePage 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()); @@ -806,8 +811,11 @@ public class JavaEditorPreferencePage extends PreferencePage private Control createPreviewer(Composite parent) { Preferences coreStore = createTemporaryCorePreferenceStore(); fJavaTextTools = new JavaTextTools(fOverlayStore, coreStore, false); - fPreviewViewer = new JavaSourceViewer(parent, null, null, false, - SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); + 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); @@ -818,7 +826,7 @@ public class JavaEditorPreferencePage extends PreferencePage fPreviewViewer.setEditable(false); String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document = new Document(content); - fJavaTextTools.setupJavaDocumentPartitioner(document, ".php"); //IJavaPartitions.JAVA_PARTITIONING); + fJavaTextTools.setupJavaDocumentPartitioner(document, ".php", null); //IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); } @@ -839,16 +847,16 @@ public class JavaEditorPreferencePage extends PreferencePage label = PreferencesMessages .getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$ addTextField(appearanceComposite, label, - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true); label = PreferencesMessages .getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, @@ -856,11 +864,11 @@ public class JavaEditorPreferencePage extends PreferencePage label = PreferencesMessages .getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, - ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); label = PreferencesMessages .getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$ // Button master= addCheckBox(appearanceComposite, label, @@ -934,185 +942,185 @@ 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(); @@ -1556,6 +1564,7 @@ public class JavaEditorPreferencePage extends PreferencePage */ protected Control createContents(Composite parent) { initializeDefaultColors(); + fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore); fOverlayStore.load(); fOverlayStore.start(); TabFolder folder = new TabFolder(parent, SWT.NONE); @@ -1573,10 +1582,10 @@ public class JavaEditorPreferencePage extends PreferencePage 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.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$ @@ -1592,7 +1601,10 @@ public class JavaEditorPreferencePage extends PreferencePage 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; @@ -1619,16 +1631,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() { @@ -1640,6 +1652,7 @@ public class JavaEditorPreferencePage extends PreferencePage // } // } // }); + fFoldingConfigurationBlock.initialize(); } private void initializeFields() { Iterator e = fColorButtons.keySet().iterator(); @@ -1723,6 +1736,7 @@ public class JavaEditorPreferencePage extends PreferencePage */ public boolean performOk() { // fJavaEditorHoverConfigurationBlock.performOk(); + fFoldingConfigurationBlock.performOk(); // fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, // computeStateMask(fBrowserLikeLinksKeyModifierText.getText())); fOverlayStore.propagate(); @@ -1737,9 +1751,10 @@ public class JavaEditorPreferencePage extends PreferencePage initializeFields(); handleSyntaxColorListSelection(); handleAppearanceColorListSelection(); - handleAnnotationListSelection(); +// handleAnnotationListSelection(); // handleContentAssistColorListSelection(); // fJavaEditorHoverConfigurationBlock.performDefaults(); + fFoldingConfigurationBlock.performDefaults(); super.performDefaults(); fPreviewViewer.invalidateTextPresentation(); } @@ -1747,6 +1762,8 @@ public class JavaEditorPreferencePage extends PreferencePage * @see DialogPage#dispose() */ public void dispose() { + fFoldingConfigurationBlock.dispose(); + if (fJavaTextTools != null) { fJavaTextTools.dispose(); fJavaTextTools = null;