|
From: Christopher W. <caw...@us...> - 2006-05-17 02:43:40
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv25483/src/org/rubypeople/rdt/internal/ui/preferences Modified Files: PreferencesMessages.java TodoTaskConfigurationBlock.java TodoTaskPreferencePage.java PreferencesMessages.properties OptionsConfigurationBlock.java Added Files: ProblemSeveritiesPreferencePage.java ProblemSeveritiesConfigurationBlock.java Log Message: expose a new preference page for the Ruby "Lint" like warnings. This is a first cut at it, a lot of the warnings from the pref page aren't hooked up in the analyzer (so they have no effect) Index: PreferencesMessages.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PreferencesMessages.java 5 May 2006 21:44:59 -0000 1.8 --- PreferencesMessages.java 17 May 2006 02:43:37 -0000 1.9 *************** *** 119,122 **** --- 119,141 ---- public static String RubyEditorPreferencePage_closeBrackets; public static String RubyEditorPreferencePage_closeBraces; + public static String ProblemSeveritiesPreferencePage_title; + public static String ProblemSeveritiesConfigurationBlock_needsbuild_title; + public static String ProblemSeveritiesConfigurationBlock_needsfullbuild_message; + public static String ProblemSeveritiesConfigurationBlock_needsprojectbuild_message; + public static String ProblemSeveritiesConfigurationBlock_error; + public static String ProblemSeveritiesConfigurationBlock_warning; + public static String ProblemSeveritiesConfigurationBlock_ignore; + public static String ProblemSeveritiesConfigurationBlock_common_description; + public static String ProblemSeveritiesConfigurationBlock_section_unnecessary_code; + public static String ProblemSeveritiesConfigurationBlock_section_potential_programming_problems; + public static String ProblemSeveritiesConfigurationBlock_pb_ensure_block_not_completing_label; + public static String ProblemSeveritiesConfigurationBlock_pb_empty_statement_label; + public static String ProblemSeveritiesConfigurationBlock_pb_hidden_rescueblock_label; + public static String ProblemSeveritiesConfigurationBlock_pb_fall_through_case; + public static String ProblemSeveritiesConfigurationBlock_pb_null_reference; + public static String ProblemSeveritiesConfigurationBlock_pb_unused_local_label; + public static String ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label; + public static String ProblemSeveritiesConfigurationBlock_pb_unused_private_label; + public static String ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label; public static String RubyEditorPreferencePage_background_color; Index: PreferencesMessages.properties =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PreferencesMessages.properties 5 May 2006 21:44:59 -0000 1.12 --- PreferencesMessages.properties 17 May 2006 02:43:37 -0000 1.13 *************** *** 133,134 **** --- 133,159 ---- SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org.eclipse.ui.editors.preferencePages.Spelling">spell checking</a> preferences. + + ProblemSeveritiesPreferencePage_title=Problem Severities + + ProblemSeveritiesConfigurationBlock_needsbuild_title=Error/Warning Settings Changed + ProblemSeveritiesConfigurationBlock_needsfullbuild_message=The Error/Warning settings have changed. A full rebuild is required for changes to take effect. Do the full build now? + ProblemSeveritiesConfigurationBlock_needsprojectbuild_message=The Error/Warning settings have changed. A rebuild of the project is required for changes to take effect. Build the project now? + + ProblemSeveritiesConfigurationBlock_error=Error + ProblemSeveritiesConfigurationBlock_warning=Warning + ProblemSeveritiesConfigurationBlock_ignore=Ignore + + ProblemSeveritiesConfigurationBlock_common_description=Select the severity level for the following Ruby compiler problems: + + ProblemSeveritiesConfigurationBlock_section_potential_programming_problems=&Potential programming problems + ProblemSeveritiesConfigurationBlock_section_unnecessary_code=&Unnecessary code + + ProblemSeveritiesConfigurationBlock_pb_ensure_block_not_completing_label='&ensure' does not complete normally: + ProblemSeveritiesConfigurationBlock_pb_empty_statement_label=Empty statement: + ProblemSeveritiesConfigurationBlock_pb_hidden_rescueblock_label=Hidden rescue bloc&k: + ProblemSeveritiesConfigurationBlock_pb_fall_through_case='case' fall-through: + ProblemSeveritiesConfigurationBlock_pb_null_reference=Null reference: + ProblemSeveritiesConfigurationBlock_pb_unused_local_label=&Local variable is never read: + ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label=Parameter is never read: + ProblemSeveritiesConfigurationBlock_pb_unused_private_label=Unused local or private member: + ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label=Unnecessary else statement: Index: TodoTaskPreferencePage.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskPreferencePage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TodoTaskPreferencePage.java 10 Feb 2006 19:52:26 -0000 1.3 --- TodoTaskPreferencePage.java 17 May 2006 02:43:37 -0000 1.4 *************** *** 1,150 **** ! /******************************************************************************* ! * 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 org.rubypeople.rdt.internal.ui.preferences; ! ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.runtime.IAdaptable; ! import org.eclipse.swt.widgets.Composite; ! import org.eclipse.swt.widgets.Control; ! import org.eclipse.ui.help.WorkbenchHelp; ! import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; ! import org.rubypeople.rdt.internal.ui.RubyPlugin; ! ! /* ! * The page to configure the task tags ! */ ! public class TodoTaskPreferencePage extends PropertyAndPreferencePage { ! ! public static final String PREF_ID = "org.rubypeople.rdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$ ! public static final String PROP_ID = "org.rubypeople.rdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$ ! ! private TodoTaskConfigurationBlock fConfigurationBlock; ! ! public TodoTaskPreferencePage() { ! setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore()); ! setDescription(PreferencesMessages.TodoTaskPreferencePage_description); ! ! // only used when page is shown programatically ! setTitle(PreferencesMessages.TodoTaskPreferencePage_title); ! } ! ! /* ! * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! fConfigurationBlock = new TodoTaskConfigurationBlock(getNewStatusChangedListener(), ! getProject()); ! ! super.createControl(parent); ! if (isProjectPreferencePage()) { ! WorkbenchHelp.setHelp(getControl(), IRubyHelpContextIds.TODOTASK_PROPERTY_PAGE); ! } else { ! WorkbenchHelp.setHelp(getControl(), IRubyHelpContextIds.TODOTASK_PREFERENCE_PAGE); ! } ! } ! ! /* ! * (non-Rubydoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID() ! */ ! protected String getPreferencePageID() { ! return PREF_ID; ! } ! ! /* ! * (non-Rubydoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID() ! */ ! protected String getPropertyPageID() { ! return PROP_ID; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite) ! */ ! protected Control createPreferenceContent(Composite composite) { ! return fConfigurationBlock.createContents(composite); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions() ! */ ! protected boolean hasProjectSpecificOptions(IProject project) { ! return fConfigurationBlock.hasProjectSpecificOptions(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#openWorkspacePreferences() ! */ ! protected void openWorkspacePreferences() { ! TodoTaskPreferencePage page = new TodoTaskPreferencePage(); ! PreferencePageSupport.showPreferencePage(getShell(), PREF_ID, page); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean) ! */ ! protected void enablePreferenceContent(boolean enable) { ! fConfigurationBlock.setEnabled(enable); // override default behaviour ! } ! ! /* ! * @see org.eclipse.jface.preference.IPreferencePage#performDefaults() ! */ ! protected void performDefaults() { ! super.performDefaults(); ! if (fConfigurationBlock != null) { ! fConfigurationBlock.performDefaults(); ! } ! } ! ! /* ! * @see org.eclipse.jface.preference.IPreferencePage#performOk() ! */ ! public boolean performOk() { ! boolean enabled = !isProjectPreferencePage() || useProjectSettings(); ! if (fConfigurationBlock != null && !fConfigurationBlock.performOk(enabled)) { return false; } ! return super.performOk(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.dialogs.DialogPage#dispose() ! */ ! public void dispose() { ! if (fConfigurationBlock != null) { ! fConfigurationBlock.dispose(); ! } ! super.dispose(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable) ! */ ! public void setElement(IAdaptable element) { ! super.setElement(element); ! setDescription(null); // no description for property page ! } ! ! } --- 1,143 ---- ! /******************************************************************************* ! * 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.core.resources.IProject; ! import org.eclipse.core.runtime.IAdaptable; ! import org.eclipse.swt.widgets.Composite; ! import org.eclipse.swt.widgets.Control; ! import org.eclipse.ui.PlatformUI; ! import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; ! import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; ! import org.rubypeople.rdt.internal.ui.RubyPlugin; ! ! /* ! * The page to configure the task tags ! */ ! public class TodoTaskPreferencePage extends PropertyAndPreferencePage { ! ! public static final String PREF_ID= "org.rubypeople.rdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$ ! public static final String PROP_ID= "org.rubypeople.rdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$ ! ! private TodoTaskConfigurationBlock fConfigurationBlock; ! ! public TodoTaskPreferencePage() { ! setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore()); ! setDescription(PreferencesMessages.TodoTaskPreferencePage_description); ! ! // only used when page is shown programatically ! setTitle(PreferencesMessages.TodoTaskPreferencePage_title); ! } ! ! /* ! * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); ! fConfigurationBlock= new TodoTaskConfigurationBlock(getNewStatusChangedListener(), getProject(), container); ! ! super.createControl(parent); ! ! if (isProjectPreferencePage()) { ! PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.TODOTASK_PROPERTY_PAGE); ! } else { ! PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.TODOTASK_PREFERENCE_PAGE); ! } ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite) ! */ ! protected Control createPreferenceContent(Composite composite) { ! return fConfigurationBlock.createContents(composite); ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject) ! */ ! protected boolean hasProjectSpecificOptions(IProject project) { ! return fConfigurationBlock.hasProjectSpecificOptions(project); ! } ! ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID() ! */ ! protected String getPreferencePageID() { ! return PREF_ID; ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID() ! */ ! protected String getPropertyPageID() { ! return PROP_ID; ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean) ! */ ! protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { ! super.enableProjectSpecificSettings(useProjectSpecificSettings); ! if (fConfigurationBlock != null) { ! fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings); ! } ! } ! ! /* ! * @see org.eclipse.jface.preference.IPreferencePage#performDefaults() ! */ ! protected void performDefaults() { ! super.performDefaults(); ! if (fConfigurationBlock != null) { ! fConfigurationBlock.performDefaults(); ! } ! } ! ! /* ! * @see org.eclipse.jface.preference.IPreferencePage#performOk() ! */ ! public boolean performOk() { ! if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { ! return false; ! } ! return super.performOk(); ! } ! ! /* ! * @see org.eclipse.jface.preference.IPreferencePage#performApply() ! */ ! public void performApply() { ! if (fConfigurationBlock != null) { ! fConfigurationBlock.performApply(); ! } ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jface.dialogs.DialogPage#dispose() ! */ ! public void dispose() { ! if (fConfigurationBlock != null) { ! fConfigurationBlock.dispose(); ! } ! super.dispose(); ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable) ! */ ! public void setElement(IAdaptable element) { ! super.setElement(element); ! setDescription(null); // no description for property page ! } ! ! ! } --- NEW FILE: ProblemSeveritiesConfigurationBlock.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 org.eclipse.core.resources.IProject; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.ui.RubyPlugin; import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo; import org.rubypeople.rdt.internal.ui.util.PixelConverter; import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener; /** */ public class ProblemSeveritiesConfigurationBlock extends OptionsConfigurationBlock { private static final String SETTINGS_SECTION_NAME= null; //"ProblemSeveritiesConfigurationBlock"; // Preference store keys, see RubyCore.getOptions private static final Key PREF_PB_ENSURE_BLOCK_NOT_COMPLETING = getJDTCoreKey(RubyCore.COMPILER_PB_ENSURE_BLOCK_NOT_COMPLETING); private static final Key PREF_PB_EMPTY_STATEMENT = getJDTCoreKey(RubyCore.COMPILER_PB_EMPTY_STATEMENT); private static final Key PREF_PB_HIDDEN_RESCUE_BLOCK = getJDTCoreKey(RubyCore.COMPILER_PB_HIDDEN_RESCUE_BLOCK); private static final Key PREF_PB_FALLTHROUGH_CASE = getJDTCoreKey(RubyCore.COMPILER_PB_FALLTHROUGH_CASE); private static final Key PREF_PB_NULL_REFERENCE = getJDTCoreKey(RubyCore.COMPILER_PB_NULL_REFERENCE); private static final Key PREF_PB_UNUSED_LOCAL = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_LOCAL); private static final Key PREF_PB_UNUSED_PARAMETER = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PARAMETER); private static final Key PREF_PB_UNUSED_PRIVATE = getJDTCoreKey(RubyCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER); private static final Key PREF_PB_UNNECESSARY_ELSE = getJDTCoreKey(RubyCore.COMPILER_PB_UNNECESSARY_ELSE); // values private static final String ERROR= RubyCore.ERROR; private static final String WARNING= RubyCore.WARNING; private static final String IGNORE= RubyCore.IGNORE; private static final String ENABLED= RubyCore.ENABLED; private static final String DISABLED= RubyCore.DISABLED; private PixelConverter fPixelConverter; public ProblemSeveritiesConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { super(context, project, getKeys(), container); } private static Key[] getKeys() { return new Key[] { PREF_PB_ENSURE_BLOCK_NOT_COMPLETING, PREF_PB_EMPTY_STATEMENT, PREF_PB_HIDDEN_RESCUE_BLOCK, PREF_PB_FALLTHROUGH_CASE, PREF_PB_NULL_REFERENCE, PREF_PB_UNUSED_LOCAL, PREF_PB_UNUSED_PARAMETER, PREF_PB_UNUSED_PRIVATE, PREF_PB_UNNECESSARY_ELSE }; } /* * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { fPixelConverter= new PixelConverter(parent); setShell(parent.getShell()); Composite mainComp= new Composite(parent, SWT.NONE); mainComp.setFont(parent.getFont()); GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; mainComp.setLayout(layout); Composite commonComposite= createStyleTabContent(mainComp); GridData gridData= new GridData(GridData.FILL, GridData.FILL, true, true); gridData.heightHint= fPixelConverter.convertHeightInCharsToPixels(20); commonComposite.setLayoutData(gridData); validateSettings(null, null, null); return mainComp; } private Composite createStyleTabContent(Composite folder) { String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE }; String[] errorWarningIgnoreLabels= new String[] { PreferencesMessages.ProblemSeveritiesConfigurationBlock_error, PreferencesMessages.ProblemSeveritiesConfigurationBlock_warning, PreferencesMessages.ProblemSeveritiesConfigurationBlock_ignore }; String[] enabledDisabled= new String[] { ENABLED, DISABLED }; int nColumns= 3; final ScrolledPageContent sc1 = new ScrolledPageContent(folder); Composite composite= sc1.getBody(); GridLayout layout= new GridLayout(nColumns, false); layout.marginHeight= 0; layout.marginWidth= 0; composite.setLayout(layout); Label description= new Label(composite, SWT.LEFT | SWT.WRAP); description.setFont(description.getFont()); description.setText(PreferencesMessages.ProblemSeveritiesConfigurationBlock_common_description); description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false, nColumns - 1, 1)); int indentStep= fPixelConverter.convertWidthInCharsToPixels(1); int defaultIndent= indentStep * 0; int extraIndent= indentStep * 2; String label; ExpandableComposite excomposite; Composite inner; // --- potential_programming_problems label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_potential_programming_problems; excomposite= createStyleSection(composite, label, nColumns); inner= new Composite(excomposite, SWT.NONE); inner.setFont(composite.getFont()); inner.setLayout(new GridLayout(nColumns, false)); excomposite.setClient(inner); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_ensure_block_not_completing_label; addComboBox(inner, label, PREF_PB_ENSURE_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_empty_statement_label; addComboBox(inner, label, PREF_PB_EMPTY_STATEMENT, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_hidden_rescueblock_label; addComboBox(inner, label, PREF_PB_HIDDEN_RESCUE_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_fall_through_case; addComboBox(inner, label, PREF_PB_FALLTHROUGH_CASE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_null_reference; addComboBox(inner, label, PREF_PB_NULL_REFERENCE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); // --- unnecessary_code label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_section_unnecessary_code; excomposite= createStyleSection(composite, label, nColumns); inner= new Composite(excomposite, SWT.NONE); inner.setFont(composite.getFont()); inner.setLayout(new GridLayout(nColumns, false)); excomposite.setClient(inner); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_local_label; addComboBox(inner, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_parameter_label; addComboBox(inner, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unused_private_label; addComboBox(inner, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); label= PreferencesMessages.ProblemSeveritiesConfigurationBlock_pb_unnecessary_else_label; addComboBox(inner, label, PREF_PB_UNNECESSARY_ELSE, errorWarningIgnore, errorWarningIgnoreLabels, defaultIndent); IDialogSettings section= RubyPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION_NAME); restoreSectionExpansionStates(section); return sc1; } /* (non-javadoc) * Update fields and validate. * @param changedKey Key that changed, or null, if all changed. */ protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return; } if (changedKey != null) { return; } else { updateEnableStates(); } fContext.statusChanged(new StatusInfo()); } private void updateEnableStates() { // TODO Handle enabling/disabling checkboxes as prefs change } protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { String title= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsbuild_title; String message; if (workspaceSettings) { message= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsfullbuild_message; } else { message= PreferencesMessages.ProblemSeveritiesConfigurationBlock_needsprojectbuild_message; } return new String[] { title, message }; } /* (non-Rubydoc) * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#dispose() */ public void dispose() { IDialogSettings section= RubyPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION_NAME); storeSectionExpansionStates(section); super.dispose(); } } Index: TodoTaskConfigurationBlock.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/TodoTaskConfigurationBlock.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TodoTaskConfigurationBlock.java 13 Apr 2006 23:00:38 -0000 1.4 --- TodoTaskConfigurationBlock.java 17 May 2006 02:43:37 -0000 1.5 *************** *** 1,363 **** ! /******************************************************************************* ! * 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 org.rubypeople.rdt.internal.ui.preferences; ! ! import java.util.ArrayList; ! import java.util.List; ! ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.runtime.IStatus; ! import org.eclipse.jface.resource.JFaceResources; ! import org.eclipse.jface.viewers.IFontProvider; ! import org.eclipse.jface.viewers.ITableLabelProvider; ! import org.eclipse.jface.viewers.LabelProvider; ! import org.eclipse.jface.viewers.Viewer; ! import org.eclipse.jface.viewers.ViewerSorter; ! import org.eclipse.jface.window.Window; ! import org.eclipse.swt.SWT; ! import org.eclipse.swt.graphics.Font; ! import org.eclipse.swt.graphics.Image; ! import org.eclipse.swt.layout.GridData; ! import org.eclipse.swt.layout.GridLayout; ! import org.eclipse.swt.widgets.Composite; ! import org.eclipse.swt.widgets.Control; ! import org.rubypeople.rdt.core.RubyCore; ! import org.rubypeople.rdt.internal.corext.util.Messages; ! import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo; ! import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.DialogField; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IDialogFieldListener; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IListAdapter; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.ListDialogField; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; ! ! /** ! */ ! public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { ! ! private static final Key PREF_COMPILER_TASK_TAGS= getJDTCoreKey(RubyCore.COMPILER_TASK_TAGS); ! private static final Key PREF_COMPILER_TASK_PRIORITIES= getJDTCoreKey(RubyCore.COMPILER_TASK_PRIORITIES); ! ! private static final Key PREF_COMPILER_TASK_CASE_SENSITIVE= getJDTCoreKey(RubyCore.COMPILER_TASK_CASE_SENSITIVE); ! ! private static final String PRIORITY_HIGH= RubyCore.COMPILER_TASK_PRIORITY_HIGH; ! private static final String PRIORITY_NORMAL= RubyCore.COMPILER_TASK_PRIORITY_NORMAL; ! private static final String PRIORITY_LOW= RubyCore.COMPILER_TASK_PRIORITY_LOW; ! ! private static final String ENABLED= RubyCore.ENABLED; ! private static final String DISABLED= RubyCore.DISABLED; ! ! public static class TodoTask { ! public String name; ! public String priority; ! } ! ! private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider { ! ! public TodoTaskLabelProvider() { ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) ! */ ! public Image getImage(Object element) { ! return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO); ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) ! */ ! public String getText(Object element) { ! return getColumnText(element, 0); ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) ! */ ! public Image getColumnImage(Object element, int columnIndex) { ! return null; ! } ! /* (non-Javadoc) ! * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) ! */ ! public String getColumnText(Object element, int columnIndex) { ! TodoTask task= (TodoTask) element; ! if (columnIndex == 0) { ! String name= task.name; ! if (isDefaultTask(task)) { ! name=Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name); ! } ! return name; ! } ! if (PRIORITY_HIGH.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; ! } else if (PRIORITY_NORMAL.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; ! } else if (PRIORITY_LOW.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; ! } ! return ""; //$NON-NLS-1$ ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) ! */ ! public Font getFont(Object element) { ! if (isDefaultTask((TodoTask) element)) { ! return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); ! } ! return null; ! } ! } ! ! private static class TodoTaskSorter extends ViewerSorter { ! public int compare(Viewer viewer, Object e1, Object e2) { ! return collator.compare(((TodoTask) e1).name, ((TodoTask) e2).name); ! } ! } ! ! private static final int IDX_ADD= 0; ! private static final int IDX_EDIT= 1; ! private static final int IDX_REMOVE= 2; ! private static final int IDX_DEFAULT= 4; ! ! private IStatus fTaskTagsStatus; ! private ListDialogField fTodoTasksList; ! private SelectionButtonDialogField fCaseSensitiveCheckBox; ! ! ! public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project) { ! super(context, project, getKeys()); ! ! TaskTagAdapter adapter= new TaskTagAdapter(); ! String[] buttons= new String[] { ! /* 0 */ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button, ! /* 1 */ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button, ! /* 2 */ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button, ! null, ! /* 4 */ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button ! }; ! fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); ! fTodoTasksList.setDialogFieldListener(adapter); ! fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE); ! ! String[] columnsHeaders= new String[] { ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column, ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column ! }; ! ! fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true)); ! fTodoTasksList.setViewerSorter(new TodoTaskSorter()); ! ! ! fCaseSensitiveCheckBox= new SelectionButtonDialogField(SWT.CHECK); ! fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label); ! ! unpackTodoTasks(); ! if (fTodoTasksList.getSize() > 0) { ! fTodoTasksList.selectFirstElement(); ! } else { ! fTodoTasksList.enableButton(IDX_EDIT, false); ! fTodoTasksList.enableButton(IDX_DEFAULT, false); ! } ! ! fTaskTagsStatus= new StatusInfo(); ! } ! ! public void setEnabled(boolean isEnabled) { ! fTodoTasksList.setEnabled(isEnabled); ! fCaseSensitiveCheckBox.setEnabled(isEnabled); ! } ! ! final boolean isDefaultTask(TodoTask task) { ! return fTodoTasksList.getIndexOfElement(task) == 0; ! } ! ! private void setToDefaultTask(TodoTask task) { ! List elements= fTodoTasksList.getElements(); ! elements.remove(task); ! elements.add(0, task); ! fTodoTasksList.setElements(elements); ! fTodoTasksList.enableButton(IDX_DEFAULT, false); ! } ! ! private static Key[] getKeys() { ! return new Key[] { ! PREF_COMPILER_TASK_TAGS, PREF_COMPILER_TASK_PRIORITIES, PREF_COMPILER_TASK_CASE_SENSITIVE ! }; ! } ! ! public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { ! ! private boolean canEdit(List selectedElements) { ! return selectedElements.size() == 1; ! } ! ! private boolean canSetToDefault(List selectedElements) { ! return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0)); ! } ! ! public void customButtonPressed(ListDialogField field, int index) { ! doTodoButtonPressed(index); ! } ! ! public void selectionChanged(ListDialogField field) { ! List selectedElements= field.getSelectedElements(); ! field.enableButton(IDX_EDIT, canEdit(selectedElements)); ! field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements)); ! } ! ! public void doubleClicked(ListDialogField field) { ! if (canEdit(field.getSelectedElements())) { ! doTodoButtonPressed(IDX_EDIT); ! } ! } ! ! public void dialogFieldChanged(DialogField field) { ! validateSettings(PREF_COMPILER_TASK_TAGS, null, null); ! } ! ! } ! ! protected Control createContents(Composite parent) { ! setShell(parent.getShell()); ! ! Composite markersComposite= createMarkersTabContent(parent); ! ! validateSettings(null, null, null); ! ! return markersComposite; ! } ! ! private Composite createMarkersTabContent(Composite folder) { ! GridLayout layout= new GridLayout(); ! layout.marginHeight= 0; ! layout.marginWidth= 0; ! layout.numColumns= 2; ! ! Composite markersComposite= new Composite(folder, SWT.NULL); ! markersComposite.setLayout(layout); ! ! Control listControl= fTodoTasksList.getListControl(markersComposite); ! listControl.setLayoutData(new GridData(GridData.FILL_BOTH)); ! ! Control buttonsControl= fTodoTasksList.getButtonBox(markersComposite); ! buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); ! ! fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2); ! ! return markersComposite; ! } ! ! protected void validateSettings(Key changedKey, String oldValue, String newValue) { ! if (changedKey != null) { ! if (PREF_COMPILER_TASK_TAGS.equals(changedKey)) { ! fTaskTagsStatus= validateTaskTags(); ! } else { ! return; ! } ! } else { ! fTaskTagsStatus= validateTaskTags(); ! } ! IStatus status= fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus }); ! fContext.statusChanged(status); ! } ! ! private IStatus validateTaskTags() { ! return new StatusInfo(); ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performOk(boolean) ! */ ! public boolean performOk(boolean enabled) { ! packTodoTasks(); ! return super.performOk(enabled); ! } ! ! ! protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { ! String title= PreferencesMessages.TodoTaskConfigurationBlock_needsbuild_title; ! String message; ! if (fProject == null) { ! message= PreferencesMessages.TodoTaskConfigurationBlock_needsfullbuild_message; ! } else { ! message= PreferencesMessages.TodoTaskConfigurationBlock_needsprojectbuild_message; ! } ! return new String[] { title, message }; ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls() ! */ ! protected void updateControls() { ! unpackTodoTasks(); ! } ! ! private void unpackTodoTasks() { ! String currTags= getValue(PREF_COMPILER_TASK_TAGS); ! String currPrios= getValue(PREF_COMPILER_TASK_PRIORITIES); ! String[] tags= getTokens(currTags, ","); //$NON-NLS-1$ ! String[] prios= getTokens(currPrios, ","); //$NON-NLS-1$ ! ArrayList elements= new ArrayList(tags.length); ! for (int i= 0; i < tags.length; i++) { ! TodoTask task= new TodoTask(); ! task.name= tags[i].trim(); ! task.priority= (i < prios.length) ? prios[i] : PRIORITY_NORMAL; ! elements.add(task); ! } ! fTodoTasksList.setElements(elements); ! ! boolean isCaseSensitive= checkValue(PREF_COMPILER_TASK_CASE_SENSITIVE, ENABLED); ! fCaseSensitiveCheckBox.setSelection(isCaseSensitive); ! } ! ! private void packTodoTasks() { ! StringBuffer tags= new StringBuffer(); ! StringBuffer prios= new StringBuffer(); ! List list= fTodoTasksList.getElements(); ! for (int i= 0; i < list.size(); i++) { ! if (i > 0) { ! tags.append(','); ! prios.append(','); ! } ! TodoTask elem= (TodoTask) list.get(i); ! tags.append(elem.name); ! prios.append(elem.priority); ! } ! setValue(PREF_COMPILER_TASK_TAGS, tags.toString()); ! setValue(PREF_COMPILER_TASK_PRIORITIES, prios.toString()); ! ! String state= fCaseSensitiveCheckBox.isSelected() ? ENABLED : DISABLED; ! setValue(PREF_COMPILER_TASK_CASE_SENSITIVE, state); ! ! } ! ! private void doTodoButtonPressed(int index) { ! TodoTask edited= null; ! if (index != IDX_ADD) { ! edited= (TodoTask) fTodoTasksList.getSelectedElements().get(0); ! } ! if (index == IDX_ADD || index == IDX_EDIT) { ! TodoTaskInputDialog dialog= new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements()); ! if (dialog.open() == Window.OK) { ! if (edited != null) { ! fTodoTasksList.replaceElement(edited, dialog.getResult()); ! } else { ! fTodoTasksList.addElement(dialog.getResult()); ! } ! } ! } else if (index == IDX_DEFAULT) { ! setToDefaultTask(edited); ! } ! } ! ! } --- 1,369 ---- ! /******************************************************************************* ! * 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 java.util.ArrayList; ! import java.util.List; ! ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.runtime.IStatus; ! import org.eclipse.jface.resource.JFaceResources; ! import org.eclipse.jface.viewers.IFontProvider; ! import org.eclipse.jface.viewers.ITableLabelProvider; ! import org.eclipse.jface.viewers.LabelProvider; ! import org.eclipse.jface.viewers.Viewer; ! import org.eclipse.jface.viewers.ViewerSorter; ! import org.eclipse.jface.window.Window; ! import org.eclipse.swt.SWT; ! import org.eclipse.swt.graphics.Font; ! import org.eclipse.swt.graphics.Image; ! import org.eclipse.swt.layout.GridData; ! import org.eclipse.swt.layout.GridLayout; ! import org.eclipse.swt.widgets.Composite; ! import org.eclipse.swt.widgets.Control; ! import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; ! import org.rubypeople.rdt.core.RubyCore; ! import org.rubypeople.rdt.internal.corext.util.Messages; ! import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo; ! import org.rubypeople.rdt.internal.ui.util.PixelConverter; ! import org.rubypeople.rdt.internal.ui.wizards.IStatusChangeListener; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.DialogField; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IDialogFieldListener; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IListAdapter; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.ListDialogField; ! import org.rubypeople.rdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; ! ! /** ! */ ! public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { ! ! private static final Key PREF_COMPILER_TASK_TAGS= getJDTCoreKey(RubyCore.COMPILER_TASK_TAGS); ! private static final Key PREF_COMPILER_TASK_PRIORITIES= getJDTCoreKey(RubyCore.COMPILER_TASK_PRIORITIES); ! ! private static final Key PREF_COMPILER_TASK_CASE_SENSITIVE= getJDTCoreKey(RubyCore.COMPILER_TASK_CASE_SENSITIVE); ! ! private static final String PRIORITY_HIGH= RubyCore.COMPILER_TASK_PRIORITY_HIGH; ! private static final String PRIORITY_NORMAL= RubyCore.COMPILER_TASK_PRIORITY_NORMAL; ! private static final String PRIORITY_LOW= RubyCore.COMPILER_TASK_PRIORITY_LOW; ! ! private static final String ENABLED= RubyCore.ENABLED; ! private static final String DISABLED= RubyCore.DISABLED; ! ! public static class TodoTask { ! public String name; ! public String priority; ! } ! ! private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider { ! ! public TodoTaskLabelProvider() { ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) ! */ ! public Image getImage(Object element) { ! return null; // RubyPluginImages.get(RubyPluginImages.IMG_OBJS_REFACTORING_INFO); ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) ! */ ! public String getText(Object element) { ! return getColumnText(element, 0); ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) ! */ ! public Image getColumnImage(Object element, int columnIndex) { ! return null; ! } ! /* (non-Rubydoc) ! * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) ! */ ! public String getColumnText(Object element, int columnIndex) { ! TodoTask task= (TodoTask) element; ! if (columnIndex == 0) { ! String name= task.name; ! if (isDefaultTask(task)) { ! name=Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name); ! } ! return name; ! } else { ! if (PRIORITY_HIGH.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; ! } else if (PRIORITY_NORMAL.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; ! } else if (PRIORITY_LOW.equals(task.priority)) { ! return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; ! } ! return ""; //$NON-NLS-1$ ! } ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object) ! */ ! public Font getFont(Object element) { ! if (isDefaultTask((TodoTask) element)) { ! return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); ! } ! return null; ! } ! } ! ! private static class TodoTaskSorter extends ViewerSorter { ! public int compare(Viewer viewer, Object e1, Object e2) { ! return collator.compare(((TodoTask) e1).name, ((TodoTask) e2).name); ! } ! } ! ! private static final int IDX_ADD= 0; ! private static final int IDX_EDIT= 1; ! private static final int IDX_REMOVE= 2; ! private static final int IDX_DEFAULT= 4; ! ! private IStatus fTaskTagsStatus; ! private ListDialogField fTodoTasksList; ! private SelectionButtonDialogField fCaseSensitiveCheckBox; ! ! ! public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) { ! super(context, project, getKeys(), container); ! ! TaskTagAdapter adapter= new TaskTagAdapter(); ! String[] buttons= new String[] { ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button, ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button, ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button, ! null, ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button, ! }; ! fTodoTasksList= new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); ! fTodoTasksList.setDialogFieldListener(adapter); ! fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE); ! ! String[] columnsHeaders= new String[] { ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column, ! PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column, ! }; ! ! fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true)); ! fTodoTasksList.setViewerSorter(new TodoTaskSorter()); ! ! ! fCaseSensitiveCheckBox= new SelectionButtonDialogField(SWT.CHECK); ! fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label); ! fCaseSensitiveCheckBox.setDialogFieldListener(adapter); ! ! unpackTodoTasks(); ! if (fTodoTasksList.getSize() > 0) { ! fTodoTasksList.selectFirstElement(); ! } else { ! fTodoTasksList.enableButton(IDX_EDIT, false); ! fTodoTasksList.enableButton(IDX_DEFAULT, false); ! } ! ! fTaskTagsStatus= new StatusInfo(); ! } ! ! public void setEnabled(boolean isEnabled) { ! fTodoTasksList.setEnabled(isEnabled); ! fCaseSensitiveCheckBox.setEnabled(isEnabled); ! } ! ! final boolean isDefaultTask(TodoTask task) { ! return fTodoTasksList.getIndexOfElement(task) == 0; ! } ! ! private void setToDefaultTask(TodoTask task) { ! List elements= fTodoTasksList.getElements(); ! elements.remove(task); ! elements.add(0, task); ! fTodoTasksList.setElements(elements); ! fTodoTasksList.enableButton(IDX_DEFAULT, false); ! } ! ! private static Key[] getKeys() { ! return new Key[] { ! PREF_COMPILER_TASK_TAGS, PREF_COMPILER_TASK_PRIORITIES, PREF_COMPILER_TASK_CASE_SENSITIVE ! }; ! } ! ! public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { ! ! private boolean canEdit(List selectedElements) { ! return selectedElements.size() == 1; ! } ! ! private boolean canSetToDefault(List selectedElements) { ! return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0)); ! } ! ! public void customButtonPressed(ListDialogField field, int index) { ! doTodoButtonPressed(index); ! } ! ! public void selectionChanged(ListDialogField field) { ! List selectedElements= field.getSelectedElements(); ! field.enableButton(IDX_EDIT, canEdit(selectedElements)); ! field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements)); ! } ! ! public void doubleClicked(ListDialogField field) { ! if (canEdit(field.getSelectedElements())) { ! doTodoButtonPressed(IDX_EDIT); ! } ! } ! ! public void dialogFieldChanged(DialogField field) { ! updateModel(field); ! } ! ! } ! ! protected Control createContents(Composite parent) { ! setShell(parent.getShell()); ! ! Composite markersComposite= createMarkersTabContent(parent); ! ! validateSettings(null, null, null); ! ! return markersComposite; ! } ! ! private Composite createMarkersTabContent(Composite folder) { ! GridLayout layout= new GridLayout(); ! layout.marginHeight= 0; ! layout.marginWidth= 0; ! layout.numColumns= 2; ! ! PixelConverter conv= new PixelConverter(folder); ! ! Composite markersComposite= new Composite(folder, SWT.NULL); ! markersComposite.setLayout(layout); ! markersComposite.setFont(folder.getFont()); ! ! GridData data= new GridData(GridData.FILL_BOTH); ! data.widthHint= conv.convertWidthInCharsToPixels(50); ! Control listControl= fTodoTasksList.getListControl(markersComposite); ! listControl.setLayoutData(data); ! ! Control buttonsControl= fTodoTasksList.getButtonBox(markersComposite); ! buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING)); ! ! fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2); ! ! return markersComposite; ! } ! ! protected void validateSettings(Key changedKey, String oldValue, String newValue) { ! if (!areSettingsEnabled()) { ! return; ! } ! ! if (changedKey != null) { ! if (PREF_COMPILER_TASK_TAGS.equals(changedKey)) { ! fTaskTagsStatus= validateTaskTags(); ! } else { ! return; ! } ! } else { ! fTaskTagsStatus= validateTaskTags(); ! } ! IStatus status= fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus }); ! fContext.statusChanged(status); ! } ! ! private IStatus validateTaskTags() { ! return new StatusInfo(); ! } ! ! protected final void updateModel(DialogField field) { ! if (field == fTodoTasksList) { ! StringBuffer tags= new StringBuffer(); ! StringBuffer prios= new StringBuffer(); ! List list= fTodoTasksList.getElements(); ! for (int i= 0; i < list.size(); i++) { ! if (i > 0) { ! tags.append(','); ! prios.append(','); ! } ! TodoTask elem= (TodoTask) list.get(i); ! tags.append(elem.name); ! prios.append(elem.priority); ! } ! setValue(PREF_COMPILER_TASK_TAGS, tags.toString()); ! setValue(PREF_COMPILER_TASK_PRIORITIES, prios.toString()); ! validateSettings(PREF_COMPILER_TASK_TAGS, null, null); ! } else if (field == fCaseSensitiveCheckBox) { ! String state= fCaseSensitiveCheckBox.isSelected() ? ENABLED : DISABLED; ! setValue(PREF_COMPILER_TASK_CASE_SENSITIVE, state); ! } ! } ! ! protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { ! String title= PreferencesMessages.TodoTaskConfigurationBlock_needsbuild_title; ! String message; ! if (fProject == null) { ! message= PreferencesMessages.TodoTaskConfigurationBlock_needsfullbuild_message; ! } else { ! message= PreferencesMessages.TodoTaskConfigurationBlock_needsprojectbuild_message; ! } ! return new String[] { title, message }; ! } ! ! /* (non-Rubydoc) ! * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls() ! */ ! protected void updateControls() { ! unpackTodoTasks(); ! } ! ! private void unpackTodoTasks() { ! String currTags= getValue(PREF_COMPILER_TASK_TAGS); ! String currPrios= getValue(PREF_COMPILER_TASK_PRIORITIES); ! String[] tags= getTokens(currTags, ","); //$NON-NLS-1$ ! String[] prios= getTokens(currPrios, ","); //$NON-NLS-1$ ! ArrayList elements= new ArrayList(tags.length); ! for (int i= 0; i < tags.length; i++) { ! TodoTask task= new TodoTask(); ! task.name= tags[i].trim(); ! task.priority= (i < prios.length) ? prios[i] : PRIORITY_NORMAL; ! elements.add(task); ! } ! fTodoTasksList.setElements(elements); ! ! boolean isCaseSensitive= checkValue(PREF_COMPILER_TASK_CASE_SENSITIVE, ENABLED); ! fCaseSensitiveCheckBox.setSelection(isCaseSensitive); ! } ! ! private void doTodoButtonPressed(int index) { ! TodoTask edited= null; ! if (index != IDX_ADD) { ! edited= (TodoTask) fTodoTasksList.getSelectedElements().get(0); ! } ! if (index == IDX_ADD || index == IDX_EDIT) { ! TodoTaskInputDialog dialog= new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements()); ! if (dialog.open() == Window.OK) { ! if (edited != null) { ! fTodoTasksList.replaceElement(edited, dialog.getResult()); ! } else { ! fTodoTasksList.addElement(dialog.getResult()); ! } ! } ! } else if (index == IDX_DEFAULT) { ! setToDefaultTask(edited); ! } ! } ! ! } --- NEW FILE: ProblemSeveritiesPreferencePage.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 java.util.Map; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; import org.rubypeople.rdt.internal.ui.RubyPlugin; /** * Page used to configure both workspace and project specific compiler settings */ public class ProblemSeveritiesPreferencePage extends PropertyAndPreferencePage { public static final String PREF_ID= "org.rubypeople.rdt.ui.preferences.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$ public static final String PROP_ID= "org.rubypeople.rdt.ui.propertyPages.ProblemSeveritiesPreferencePage"; //$NON-NLS-1$ public static final String DATA_SELECT_OPTION_KEY= "select_option_key"; //$NON-NLS-1$ public static final String DATA_SELECT_OPTION_QUALIFIER= "select_option_qualifier"; //$NON-NLS-1$ private ProblemSeveritiesConfigurationBlock fConfigurationBlock; public ProblemSeveritiesPreferencePage() { setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore()); //setDescription(PreferencesMessages.getString("ProblemSeveritiesPreferencePage.description")); //$NON-NLS-1$ // only used when page is shown programatically setTitle(PreferencesMessages.ProblemSeveritiesPreferencePage_title); } /* * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer(); fConfigurationBlock= new ProblemSeveritiesConfigurationBlock(getNewStatusChangedListener(), getProject(), container); super.createControl(parent); if (isProjectPreferencePage()) { PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.COMPILER_PROPERTY_PAGE); } else { PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.COMPILER_PREFERENCE_PAGE); } } protected Control createPreferenceContent(Composite composite) { return fConfigurationBlock.createContents(composite); } protected boolean hasProjectSpecificOptions(IProject project) { return fConfigurationBlock.hasProjectSpecificOptions(project); } /* (non-Rubydoc) * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID() */ protected String getPreferencePageID() { return PREF_ID; } /* (non-Rubydoc) * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID() */ protected String getPropertyPageID() { return PROP_ID; } /* (non-Rubydoc) * @see org.eclipse.jface.dialogs.DialogPage#dispose() */ public void dispose() { if (fConfigurationBlock != null) { fConfigurationBlock.dispose(); } super.dispose(); } /* (non-Rubydoc) * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean) */ protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { super.enableProjectSpecificSettings(useProjectSpecificSettings); if (fConfigurationBlock != null) { fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings); } } /* * @see org.eclipse.jface.preference.IPreferencePage#performDefaults() */ protected void performDefaults() { super.performDefaults(); if (fConfigurationBlock != null) { fConfigurationBlock.performDefaults(); } } /* * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { return false; } return super.performOk(); } /* * @see org.eclipse.jface.preference.IPreferencePage#performApply() */ public void performApply() { if (fConfigurationBlock != null) { fConfigurationBlock.performApply(); } } /* (non-Rubydoc) * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object) */ public void applyData(Object data) { super.applyData(data); if (data instanceof Map && fConfigurationBlock != null) { Map map= (Map) data; Object key= map.get(DATA_SELECT_OPTION_KEY); Object qualifier= map.get(DATA_SELECT_OPTION_QUALIFIER); if (key instanceof String && qualifier instanceof String) { fConfigurationBlock.selectOption((String) key, (String) qualifier); } } } /* (non-Rubydoc) * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable) */ public void setElement(IAdaptable element) { super.setElement(element); setDescription(null); // no description for property page } } Index: OptionsConfigurationBlock.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/OptionsConfigurationBlock.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OptionsConfigurationBlock.java 5 Mar 2005 16:02:19 -0000 1.3 --- OptionsConfigurationBlock.java 17 May 2006 02:43:37 -0000 1.4 *************** *** 1,695 **** ! /******************************************************************************* ! * 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 ! *******************************************************************************/ [...1547 lines suppressed...] ! return comboBox; ! } ! Button checkBox= getCheckBox(key); ! if (checkBox != null) { ! return checkBox; ! } ! Text text= getTextControl(key); ! if (text != null) { ! return text; ! } ! return null; ! } ! ! protected void setComboEnabled(Key key, boolean enabled) { ! Combo combo= getComboBox(key); ! Label label= (Label) fLabels.get(combo); ! combo.setEnabled(enabled); ! label.setEnabled(enabled); ! } ! } |