|
From: Christopher W. <caw...@us...> - 2006-04-21 21:13:35
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28089/src/org/rubypeople/rdt/internal/ui/preferences Modified Files: PreferencesMessages.java PreferencesMessages.properties Added Files: SmartTypingPreferencePage.java RubyEditorPreferencePage.java SmartTypingConfigurationBlock.java RubyEditorAppearanceConfigurationBlock.java Log Message: make over the ruby editor preference page. Add options for smart typing features (like auto-closing brackets/strings) Index: PreferencesMessages.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PreferencesMessages.java 13 Apr 2006 23:00:38 -0000 1.6 --- PreferencesMessages.java 21 Apr 2006 21:13:28 -0000 1.7 *************** *** 72,76 **** public static String AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives; public static String AppearancePreferencePage_methodtypeparams_label; - public static String AppearancePreferencePage_showMembersInPackagesView; public static String AppearancePreferencePage_stackViewsVerticallyInTheRubyBrowsingPerspective; public static String AppearancePreferencePage_description; --- 72,75 ---- *************** *** 102,105 **** --- 101,122 ---- public static String RubyEditorPreferencePage_invalid_input; public static String RubyEditorPreferencePage_folding_title; + public static String RubyEditorPreferencePage_matchingBracketsHighlightColor2; + public static String RubyEditorPreferencePage_backgroundForCompletionProposals; + public static String RubyEditorPreferencePage_foregroundForCompletionProposals; + public static String RubyEditorPreferencePage_backgroundForMethodParameters; + public static String RubyEditorPreferencePage_foregroundForMethodParameters; + public static String RubyEditorPreferencePage_backgroundForCompletionReplacement; + public static String RubyEditorPreferencePage_foregroundForCompletionReplacement; + public static String RubyEditorPreferencePage_analyseAnnotationsWhileTyping; + public static String SmartTypingConfigurationBlock_annotationReporting_link; + public static String RubyEditorPreferencePage_highlightMatchingBrackets; + public static String RubyEditorPreferencePage_appearanceOptions; + public static String RubyEditorPreferencePage_systemDefault; + public static String RubyEditorPreferencePage_general; + public static String RubyEditorPreferencePage_typing_tabTitle; + public static String SmartTypingConfigurationBlock_autoclose_title; + public static String RubyEditorPreferencePage_closeStrings; + public static String RubyEditorPreferencePage_closeBrackets; + public static String RubyEditorPreferencePage_closeBraces; static { --- NEW FILE: RubyEditorPreferencePage.java --- /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.rubypeople.rdt.internal.ui.preferences; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; import org.rubypeople.rdt.internal.ui.RubyPlugin; /** * The page for setting the editor options. */ public final class RubyEditorPreferencePage extends AbstractConfigurationBlockPreferencePage { /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() */ protected String getHelpId() { return IRubyHelpContextIds.RUBY_EDITOR_PREFERENCE_PAGE; } /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() */ protected void setDescription() { String description= PreferencesMessages.RubyEditorPreferencePage_general; setDescription(description); } /* * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() */ protected void setPreferenceStore() { setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore()); } protected Label createDescriptionLabel(Composite parent) { return null; // no description for new look. } /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) */ protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { return new RubyEditorAppearanceConfigurationBlock(this, overlayPreferenceStore); } } --- NEW FILE: SmartTypingConfigurationBlock.java --- /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.rubypeople.rdt.internal.ui.preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.rubypeople.rdt.ui.PreferenceConstants; /** * Configures Ruby Editor typing preferences. * * @since 3.1 */ class SmartTypingConfigurationBlock extends AbstractConfigurationBlock { public SmartTypingConfigurationBlock(OverlayPreferenceStore store) { super(store); store.addKeys(createOverlayStoreKeys()); } private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { return new OverlayPreferenceStore.OverlayKey[] { new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS), new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES) }; } /** * Creates page for mark occurrences preferences. * * @param parent the parent composite * @return the control for the preference page */ public Control createControl(Composite parent) { ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL); scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); Composite control= new Composite(scrolled, SWT.NONE); GridLayout layout= new GridLayout(); control.setLayout(layout); Composite composite; composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title); addAutoclosingSection(composite); scrolled.setContent(control); final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT); scrolled.setMinSize(size.x, size.y); return scrolled; } private void addAutoclosingSection(Composite composite) { GridLayout layout= new GridLayout(); layout.numColumns= 1; composite.setLayout(layout); String label; label= PreferencesMessages.RubyEditorPreferencePage_closeStrings; addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 0); label= PreferencesMessages.RubyEditorPreferencePage_closeBrackets; addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 0); label= PreferencesMessages.RubyEditorPreferencePage_closeBraces; addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0); } } Index: PreferencesMessages.properties =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PreferencesMessages.properties 13 Apr 2006 23:00:38 -0000 1.9 --- PreferencesMessages.properties 21 Apr 2006 21:13:28 -0000 1.10 *************** *** 109,111 **** RubyEditorPreferencePage_regular_expressions= Regular Expressions RubyEditorPreferencePage_symbols= Symbols ! RubyEditorPreferencePage_variables= Variables \ No newline at end of file --- 109,133 ---- RubyEditorPreferencePage_regular_expressions= Regular Expressions RubyEditorPreferencePage_symbols= Symbols ! RubyEditorPreferencePage_variables= Variables ! ! RubyEditorPreferencePage_matchingBracketsHighlightColor2=Matching brackets highlight ! RubyEditorPreferencePage_backgroundForCompletionProposals= Completion proposal background ! RubyEditorPreferencePage_foregroundForCompletionProposals= Completion proposal foreground ! RubyEditorPreferencePage_backgroundForMethodParameters= Parameter hints background ! RubyEditorPreferencePage_foregroundForMethodParameters= Parameter hints foreground ! RubyEditorPreferencePage_backgroundForCompletionReplacement= Completion overwrite background ! RubyEditorPreferencePage_foregroundForCompletionReplacement= Completion overwrite foreground ! RubyEditorPreferencePage_analyseAnnotationsWhileTyping= Report &problems as you type ! RubyEditorPreferencePage_highlightMatchingBrackets=Highlight &matching brackets ! RubyEditorPreferencePage_appearanceOptions=Appearance co&lor options: ! RubyEditorPreferencePage_systemDefault=&System Default ! RubyEditorPreferencePage_general=Appeara&nce ! ! RubyEditorPreferencePage_typing_tabTitle=T&yping ! RubyEditorPreferencePage_closeStrings= "&Strings" ! RubyEditorPreferencePage_closeBrackets= (Parentheses), [square] and <angle> brac&kets ! RubyEditorPreferencePage_closeBraces= {B&races} ! ! SmartTypingConfigurationBlock_autoclose_title=Automatically close ! SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org.eclipse.ui.editors.preferencePages.Spelling">spell checking</a> preferences. ! --- NEW FILE: SmartTypingPreferencePage.java --- /******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.rubypeople.rdt.internal.ui.preferences; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; import org.rubypeople.rdt.internal.ui.RubyPlugin; /** * The page for setting the editor options. */ public final class SmartTypingPreferencePage extends AbstractConfigurationBlockPreferencePage { /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId() */ protected String getHelpId() { return IRubyHelpContextIds.RUBY_EDITOR_PREFERENCE_PAGE; } /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription() */ protected void setDescription() { String description= PreferencesMessages.RubyEditorPreferencePage_typing_tabTitle; setDescription(description); } /* * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore() */ protected void setPreferenceStore() { setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore()); } protected Label createDescriptionLabel(Composite parent) { return null; // no description for new look. } /* * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore) */ protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) { return new SmartTypingConfigurationBlock(overlayPreferenceStore); } } --- NEW FILE: RubyEditorAppearanceConfigurationBlock.java --- /******************************************************************************* * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.rubypeople.rdt.internal.ui.preferences; import java.util.ArrayList; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.ColorSelector; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; 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.Link; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.PreferencesUtil; import org.rubypeople.rdt.internal.ui.util.PixelConverter; import org.rubypeople.rdt.ui.PreferenceConstants; /** * Configures Ruby Editor hover preferences. * * @since 2.1 */ class RubyEditorAppearanceConfigurationBlock extends AbstractConfigurationBlock { private final String[][] fAppearanceColorListModel= new String[][] { {PreferencesMessages.RubyEditorPreferencePage_matchingBracketsHighlightColor2, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, null}, {PreferencesMessages.RubyEditorPreferencePage_backgroundForCompletionProposals, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, null }, {PreferencesMessages.RubyEditorPreferencePage_foregroundForCompletionProposals, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, null }, {PreferencesMessages.RubyEditorPreferencePage_backgroundForMethodParameters, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, null }, {PreferencesMessages.RubyEditorPreferencePage_foregroundForMethodParameters, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, null }, {PreferencesMessages.RubyEditorPreferencePage_backgroundForCompletionReplacement, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND, null }, {PreferencesMessages.RubyEditorPreferencePage_foregroundForCompletionReplacement, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND, null }, }; private List fAppearanceColorList; private ColorSelector fAppearanceColorEditor; private Button fAppearanceColorDefault; private FontMetrics fFontMetrics; public RubyEditorAppearanceConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) { super(store, mainPreferencePage); getPreferenceStore().addKeys(createOverlayStoreKeys()); } private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { ArrayList overlayKeys= new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS)); 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)); OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return keys; } /** * Creates page for appearance preferences. * * @param parent the parent composite * @return the control for the preference page */ public Control createControl(Composite parent) { initializeDialogUnits(parent); Composite composite= new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); createHeader(composite); createAppearancePage(composite); return composite; } private void createHeader(Composite contents) { final Shell shell= contents.getShell(); String text= PreferencesMessages.RubyEditorPreferencePage_link; Link link= new Link(contents, SWT.NONE); link.setText(text); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.ui.preferencePages.GeneralTextEditor", null, null); //$NON-NLS-1$ } }); // TODO replace by link-specific tooltips when // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed link.setToolTipText(PreferencesMessages.RubyEditorPreferencePage_link_tooltip); GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint= 150; // only expand further if anyone else requires it link.setLayoutData(gridData); addFiller(contents); } private void addFiller(Composite composite) { PixelConverter pixelConverter= new PixelConverter(composite); Label filler= new Label(composite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); } /** * Returns the number of pixels corresponding to the width of the given * number of characters. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param chars * the number of characters * @return the number of pixels */ protected int convertWidthInCharsToPixels(int chars) { // test for failure to initialize for backward compatibility if (fFontMetrics == null) return 0; return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); } /** * Returns the number of pixels corresponding to the height of the given * number of characters. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param chars * the number of characters * @return the number of pixels */ protected int convertHeightInCharsToPixels(int chars) { // test for failure to initialize for backward compatibility if (fFontMetrics == null) return 0; return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); } private Control createAppearancePage(Composite parent) { Composite appearanceComposite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; appearanceComposite.setLayout(layout); String label; label= PreferencesMessages.RubyEditorPreferencePage_analyseAnnotationsWhileTyping; addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); String text= PreferencesMessages.SmartTypingConfigurationBlock_annotationReporting_link; addLink(appearanceComposite, text, INDENT); Label spacer= new Label(appearanceComposite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; spacer.setLayoutData(gd); label= PreferencesMessages.RubyEditorPreferencePage_highlightMatchingBrackets; addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0); Label l= new Label(appearanceComposite, SWT.LEFT ); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; l.setLayoutData(gd); l= new Label(appearanceComposite, SWT.LEFT); l.setText(PreferencesMessages.RubyEditorPreferencePage_appearanceOptions); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(appearanceComposite, 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); fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(12); fAppearanceColorList.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.RubyEditorPreferencePage_color); gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; l.setLayoutData(gd); fAppearanceColorEditor= new ColorSelector(stylesComposite); Button foregroundColorButton= fAppearanceColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); SelectionListener colorDefaultSelectionListener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean systemDefault= fAppearanceColorDefault.getSelection(); fAppearanceColorEditor.getButton().setEnabled(!systemDefault); int i= fAppearanceColorList.getSelectionIndex(); if (i == -1) return; String key= fAppearanceColorListModel[i][2]; if (key != null) getPreferenceStore().setValue(key, systemDefault); } public void widgetDefaultSelected(SelectionEvent e) {} }; fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK); fAppearanceColorDefault.setText(PreferencesMessages.RubyEditorPreferencePage_systemDefault); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fAppearanceColorDefault.setLayoutData(gd); fAppearanceColorDefault.setVisible(false); fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener); fAppearanceColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleAppearanceColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAppearanceColorList.getSelectionIndex(); if (i == -1) return; String key= fAppearanceColorListModel[i][1]; PreferenceConverter.setValue(getPreferenceStore(), key, fAppearanceColorEditor.getColorValue()); } }); return appearanceComposite; } private void addLink(Composite composite, String text, int indent) { GridData gd; final Link link= new Link(composite, SWT.NONE); link.setText(text); gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false); gd.widthHint= 300; // don't get wider initially gd.horizontalSpan= 2; gd.horizontalIndent= indent; link.setLayoutData(gd); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(link.getShell(), e.text, null, null); } }); } private void handleAppearanceColorListSelection() { int i= fAppearanceColorList.getSelectionIndex(); if (i == -1) return; String key= fAppearanceColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), key); fAppearanceColorEditor.setColorValue(rgb); updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]); } private void updateAppearanceColorWidgets(String systemDefaultKey) { if (systemDefaultKey == null) { fAppearanceColorDefault.setSelection(false); fAppearanceColorDefault.setVisible(false); fAppearanceColorEditor.getButton().setEnabled(true); } else { boolean systemDefault= getPreferenceStore().getBoolean(systemDefaultKey); fAppearanceColorDefault.setSelection(systemDefault); fAppearanceColorDefault.setVisible(true); fAppearanceColorEditor.getButton().setEnabled(!systemDefault); } } /* * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize() */ public void initialize() { super.initialize(); for (int i= 0; i < fAppearanceColorListModel.length; i++) fAppearanceColorList.add(fAppearanceColorListModel[i][0]); fAppearanceColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) { fAppearanceColorList.select(0); handleAppearanceColorListSelection(); } } }); } /* * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults() */ public void performDefaults() { super.performDefaults(); handleAppearanceColorListSelection(); } /** * Initializes the computation of horizontal and vertical dialog units based * on the size of current font. * <p> * This method must be called before any of the dialog unit based conversion * methods are called. * </p> * * @param testControl * a control from which to obtain the current font */ protected void initializeDialogUnits(Control testControl) { // Compute and store a font metric GC gc = new GC(testControl); gc.setFont(JFaceResources.getDialogFont()); fFontMetrics = gc.getFontMetrics(); gc.dispose(); } } |