|
From: <caw...@us...> - 2007-08-01 15:27:27
|
Revision: 2911
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2911&view=rev
Author: cawilliams
Date: 2007-08-01 08:27:22 -0700 (Wed, 01 Aug 2007)
Log Message:
-----------
fix #4229 - Allow users to specify tokens to be highlighted like keywords
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordInputDialog.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordPreferencePage.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-08-01 14:38:26 UTC (rev 2910)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-08-01 15:27:22 UTC (rev 2911)
@@ -96,6 +96,11 @@
class="org.rubypeople.rdt.internal.ui.preferences.DebuggerPreferencePage"
id="org.rubypeople.rdt.ui.preferences.debugger"
name="%PreferencePage.rdtDebuggerPreferences"/>
+ <page
+ category="org.rubypeople.rdt.ui.preferences.RubyEditorColoringPreferencePage"
+ class="org.rubypeople.rdt.internal.ui.preferences.KeywordPreferencePage"
+ id="org.rubypeople.rdt.ui.preferences.PreferencePageKeyword"
+ name="Keywords"/>
</extension>
<!-- =========================================================================== -->
<!-- Ruby Perspective -->
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordConfigurationBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordConfigurationBlock.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * 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.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.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.ui.PreferenceConstants;
+
+/**
+ */
+public class KeywordConfigurationBlock extends OptionsConfigurationBlock {
+
+ private static final Key PREF_COMPILER_TASK_TAGS= getRDTUIKey(PreferenceConstants.EDITOR_USER_KEYWORDS);
+
+ private static final String ENABLED= RubyCore.ENABLED;
+ private static final String DISABLED= RubyCore.DISABLED;
+
+ public static class Keyword {
+ public String name;
+ }
+
+ private class KeywordLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
+
+ public KeywordLabelProvider() {
+ }
+
+ /* (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) {
+ Keyword task= (Keyword) element;
+ if (columnIndex == 0) {
+ return task.name;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+ */
+ public Font getFont(Object element) {
+ return null;
+ }
+ }
+
+ private static class TodoTaskSorter extends ViewerSorter {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return collator.compare(((Keyword) e1).name, ((Keyword) e2).name);
+ }
+ }
+
+ private static final int IDX_ADD= 0;
+ private static final int IDX_EDIT= 1;
+ private static final int IDX_REMOVE= 2;
+
+ private IStatus fTaskTagsStatus;
+ private ListDialogField fTodoTasksList;
+
+
+ public KeywordConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
+ super(context, project, getKeys(), container);
+
+ KeywordAdapter adapter= new KeywordAdapter();
+ String[] buttons= new String[] {
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button,
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button
+ };
+ fTodoTasksList= new ListDialogField(adapter, buttons, new KeywordLabelProvider());
+ fTodoTasksList.setDialogFieldListener(adapter);
+ fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
+
+ String[] columnsHeaders= new String[] {
+ PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column
+ };
+
+ fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
+ fTodoTasksList.setViewerSorter(new TodoTaskSorter());
+
+ unpackTodoTasks();
+ if (fTodoTasksList.getSize() > 0) {
+ fTodoTasksList.selectFirstElement();
+ } else {
+ fTodoTasksList.enableButton(IDX_EDIT, false);
+ }
+
+ fTaskTagsStatus= new StatusInfo();
+ }
+
+ public void setEnabled(boolean isEnabled) {
+ fTodoTasksList.setEnabled(isEnabled);
+ }
+
+ private static Key[] getKeys() {
+ return new Key[] {
+ PREF_COMPILER_TASK_TAGS
+ };
+ }
+
+ public class KeywordAdapter implements IListAdapter, IDialogFieldListener {
+
+ private boolean canEdit(List selectedElements) {
+ return selectedElements.size() == 1;
+ }
+
+ public void customButtonPressed(ListDialogField field, int index) {
+ doTodoButtonPressed(index);
+ }
+
+ public void selectionChanged(ListDialogField field) {
+ List selectedElements= field.getSelectedElements();
+ field.enableButton(IDX_EDIT, canEdit(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));
+
+ 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();
+ List list= fTodoTasksList.getElements();
+ for (int i= 0; i < list.size(); i++) {
+ if (i > 0) {
+ tags.append(',');
+ }
+ Keyword elem= (Keyword) list.get(i);
+ tags.append(elem.name);
+ }
+ setValue(PREF_COMPILER_TASK_TAGS, tags.toString());
+ validateSettings(PREF_COMPILER_TASK_TAGS, null, null);
+ }
+ }
+
+ protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+ return null;
+ }
+
+ /* (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[] tags= getTokens(currTags, ","); //$NON-NLS-1$
+ ArrayList elements= new ArrayList(tags.length);
+ for (int i= 0; i < tags.length; i++) {
+ Keyword task= new Keyword();
+ task.name= tags[i].trim();
+ elements.add(task);
+ }
+ fTodoTasksList.setElements(elements);
+
+ }
+
+ private void doTodoButtonPressed(int index) {
+ Keyword edited= null;
+ if (index != IDX_ADD) {
+ edited= (Keyword) fTodoTasksList.getSelectedElements().get(0);
+ }
+ if (index == IDX_ADD || index == IDX_EDIT) {
+ KeywordInputDialog dialog= new KeywordInputDialog(getShell(), edited, fTodoTasksList.getElements());
+ if (dialog.open() == Window.OK) {
+ if (edited != null) {
+ fTodoTasksList.replaceElement(edited, dialog.getResult());
+ } else {
+ fTodoTasksList.addElement(dialog.getResult());
+ }
+ }
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordConfigurationBlock.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordInputDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordInputDialog.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordInputDialog.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * 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.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusDialog;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
+import org.rubypeople.rdt.internal.ui.preferences.KeywordConfigurationBlock.Keyword;
+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.LayoutUtil;
+import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringDialogField;
+
+/**
+ * Dialog to enter a new keyword
+ */
+public class KeywordInputDialog extends StatusDialog {
+
+ private class KeywordInputAdapter implements IDialogFieldListener {
+ public void dialogFieldChanged(DialogField field) {
+ doValidation();
+ }
+ }
+
+ private StringDialogField fNameDialogField;
+
+ private List fExistingNames;
+
+ public KeywordInputDialog(Shell parent, Keyword task, List existingEntries) {
+ super(parent);
+
+ fExistingNames= new ArrayList(existingEntries.size());
+ for (int i= 0; i < existingEntries.size(); i++) {
+ Keyword curr= (Keyword) existingEntries.get(i);
+ if (!curr.equals(task)) {
+ fExistingNames.add(curr.name);
+ }
+ }
+
+ if (task == null) {
+ setTitle(PreferencesMessages.KeywordInputDialog_new_title);
+ } else {
+ setTitle(PreferencesMessages.KeywordInputDialog_edit_title);
+ }
+
+ KeywordInputAdapter adapter= new KeywordInputAdapter();
+
+ fNameDialogField= new StringDialogField();
+ fNameDialogField.setLabelText(PreferencesMessages.KeywordInputDialog_name_label);
+ fNameDialogField.setDialogFieldListener(adapter);
+
+ fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
+ }
+
+ public Keyword getResult() {
+ Keyword task= new Keyword();
+ task.name= fNameDialogField.getText().trim();
+ return task;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite= (Composite) super.createDialogArea(parent);
+
+ Composite inner= new Composite(composite, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ inner.setLayout(layout);
+
+ fNameDialogField.doFillIntoGrid(inner, 2);
+
+ LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
+ LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
+
+ fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
+
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ private void doValidation() {
+ StatusInfo status= new StatusInfo();
+ String newText= fNameDialogField.getText();
+ if (newText.length() == 0) {
+ status.setError(PreferencesMessages.KeywordInputDialog_error_enterName);
+ } else {
+ if (newText.indexOf(',') != -1) {
+ status.setError(PreferencesMessages.KeywordInputDialog_error_comma);
+ } else if (fExistingNames.contains(newText)) {
+ status.setError(PreferencesMessages.KeywordInputDialog_error_entryExists);
+ } else if (Character.isWhitespace(newText.charAt(0)) || Character.isWhitespace(newText.charAt(newText.length() - 1))) {
+ status.setError(PreferencesMessages.KeywordInputDialog_error_noSpace);
+ }
+ }
+ updateStatus(status);
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ // FIXME Uncomment for help context!
+ //WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.TODO_TASK_INPUT_DIALOG);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordInputDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordPreferencePage.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordPreferencePage.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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.preferences.IWorkbenchPreferenceContainer;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+/*
+ * The page to configure the task tags
+ */
+public class KeywordPreferencePage extends PropertyAndPreferencePage {
+
+ public static final String PREF_ID= "org.rubypeople.rdt.ui.preferences.KeywordPreferencePage"; //$NON-NLS-1$
+ public static final String PROP_ID= "org.rubypeople.rdt.ui.propertyPages.KeywordPreferencePage"; //$NON-NLS-1$
+
+ private KeywordConfigurationBlock fConfigurationBlock;
+
+ public KeywordPreferencePage() {
+ setPreferenceStore(RubyPlugin.getDefault().getPreferenceStore());
+ setDescription(PreferencesMessages.KeywordPreferencePage_description);
+
+ // only used when page is shown programatically
+ setTitle(PreferencesMessages.KeywordPreferencePage_title);
+ }
+
+ /*
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
+ fConfigurationBlock= new KeywordConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
+
+ super.createControl(parent);
+
+// if (isProjectPreferencePage()) {
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.KEYWORD_PROPERTY_PAGE);
+// } else {
+// PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRubyHelpContextIds.KEYWORD_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
+ }
+
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/KeywordPreferencePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-08-01 14:38:26 UTC (rev 2910)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -182,6 +182,15 @@
public static String NewRubyProjectPreferencePage_folders_error_invalidcp;
public static String NewRubyProjectPreferencePage_folders_error_invalidsrcname;
public static String NewRubyProjectPreferencePage_folders_error_namesempty;
+ public static String KeywordPreferencePage_description;
+ public static String KeywordPreferencePage_title;
+ public static String KeywordInputDialog_new_title;
+ public static String KeywordInputDialog_edit_title;
+ public static String KeywordInputDialog_name_label;
+ public static String KeywordInputDialog_error_enterName;
+ public static String KeywordInputDialog_error_comma;
+ public static String KeywordInputDialog_error_entryExists;
+ public static String KeywordInputDialog_error_noSpace;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-08-01 14:38:26 UTC (rev 2910)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-08-01 15:27:22 UTC (rev 2911)
@@ -32,7 +32,7 @@
TodoTaskConfigurationBlock_needsbuild_title=Task Tags Settings Changed
TodoTaskConfigurationBlock_tasks_default={0} (default)
-TodoTaskConfigurationBlock_needsfullbuild_message=The task tags settings have changed. A full rebuild is required to for changes to take effect. Do the full build now?
+TodoTaskConfigurationBlock_needsfullbuild_message=The task tags settings have changed. A full rebuild is required for changes to take effect. Do the full build now?
TodoTaskConfigurationBlock_needsprojectbuild_message=The task tags settings have changed. A rebuild of the project is required for changes to take effect. Build the project now?
TodoTaskInputDialog_new_title=New Task Tag
@@ -47,6 +47,17 @@
TodoTaskInputDialog_error_entryExists=An entry with the same name already exists.
TodoTaskInputDialog_error_noSpace=Name cannot begin or end with a whitespace.
+KeywordPreferencePage_title=Keywords
+KeywordPreferencePage_description=&Strings indicating user defined keywords for syntax coloring purposes.
+
+KeywordInputDialog_new_title=New Keyword
+KeywordInputDialog_edit_title=Edit Keyword
+KeywordInputDialog_name_label=Keyword:
+KeywordInputDialog_error_enterName=Enter keyword.
+KeywordInputDialog_error_comma=Keyword cannot contain a comma.
+KeywordInputDialog_error_entryExists=An entry with the same keyword already exists.
+KeywordInputDialog_error_noSpace=Keyword cannot begin or end with a space.
+
MembersOrderPreferencePage_category_button_up=&Up
MembersOrderPreferencePage_category_button_down=D&own
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-08-01 14:38:26 UTC (rev 2910)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.StringReader;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -19,6 +20,7 @@
import org.jruby.parser.Tokens;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
+import org.rubypeople.rdt.ui.PreferenceConstants;
import org.rubypeople.rdt.ui.text.IColorManager;
public class RubyTokenScanner extends AbstractRubyTokenScanner {
@@ -227,7 +229,22 @@
}
private boolean isKeyword(int i) {
- return (i >= MIN_KEYWORD && i <= MAX_KEYWORD);
+ if (i >= MIN_KEYWORD && i <= MAX_KEYWORD) return true;
+ if (i != Tokens.tIDENTIFIER) return false;
+ String src = fContents.substring((fOffset - origOffset), (fOffset - origOffset) + fTokenLength);
+ Preferences prefs = RubyPlugin.getDefault().getPluginPreferences();
+ String rawKeywords = prefs.getString(PreferenceConstants.EDITOR_USER_KEYWORDS);
+ if (rawKeywords == null || rawKeywords.length() == 0) {
+ return false;
+ }
+ String[] keywords = rawKeywords.split(",");
+ if (keywords == null || keywords.length == 0) {
+ return false;
+ }
+ for (int j = 0; j < keywords.length; j++) {
+ if (keywords[j].equals(src.trim())) return true;
+ }
+ return false;
}
public void setRange(IDocument document, int offset, int length) {
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-08-01 14:38:26 UTC (rev 2910)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-08-01 15:27:22 UTC (rev 2911)
@@ -680,6 +680,16 @@
* @since 0.9.0
*/
public static final String EDITOR_MARK_METHOD_EXIT_POINTS = "markMethodExitPoints"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds user defined "keywords".
+ * <p>
+ * Value is of type <code>String</code>.
+ * </p>
+ *
+ * @since 1.0
+ */
+ public static final String EDITOR_USER_KEYWORDS = "userDefinedKeywords"; //$NON-NLS-1$
/**
@@ -807,6 +817,7 @@
store.setDefault(LOADPATH_RUBYVMLIBRARY_INDEX, 0);
store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false);
+ store.setDefault(PreferenceConstants.EDITOR_USER_KEYWORDS, "");
// FIXME We can't enabling using code formatter yet, because it breaks
// on formatting templates (when inserting via content assist)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|