|
From: <caw...@us...> - 2006-12-15 15:32:51
|
Revision: 1706
http://svn.sourceforge.net/rubyeclipse/?rev=1706&view=rev
Author: cawilliams
Date: 2006-12-15 07:32:50 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
all sorts of plumbing for new test case wizard, new SourceFolder in IRubyElement hierarchy
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/.project
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CodeFormatterUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
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/preferences/PropertyAndPreferencePage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/AbstractOpenWizardAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/dialogfields/ListDialogField.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyTypeSelectionDialog.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_obj.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProjectSelectionDialog.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/TypedElementSelectionValidator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/TypedViewerFilter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyModuleSelectionDialog.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties
Property Changed:
----------------
trunk/org.rubypeople.rdt.ui/icons/full/obj16/
Modified: trunk/org.rubypeople.rdt.ui/.project
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16
___________________________________________________________________
Name: svn:ignore
- Thumbs.db
+ Thumbs.db
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/fldr_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2006-12-15 15:32:50 UTC (rev 1706)
@@ -31,7 +31,7 @@
viewCategoryName=Ruby
appearancePrefName=Appearance
-problemSeveritiesPrefName=Errors/Warnings
+problemSeveritiesPageName=Errors/Warnings
preferenceKeywords.general=Ruby resources call type hierarchy refactoring search
preferenceKeywords.appearance=Ruby appearance resources browsing
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2006-12-15 15:32:50 UTC (rev 1706)
@@ -285,19 +285,9 @@
</enabledWhen>
</page>
<page
- name="%PropertyPageRubyProject.name"
- class="org.rubypeople.rdt.internal.ui.RubyProjectPropertyPage"
- id="org.rubypeople.rdt.ui.PropertyPageRubyProject">
- <enabledWhen>
- <adapt type="org.eclipse.core.resources.IProject">
- <test property="org.eclipse.core.resources.projectNature" value="org.rubypeople.rdt.core.rubynature"/>
- </adapt>
- </enabledWhen>
- </page>
- <page
name="%problemSeveritiesPageName"
class="org.rubypeople.rdt.internal.ui.preferences.ProblemSeveritiesPreferencePage"
- category="org.rubypeople.rdt.ui.propertyPages.CompliancePreferencePage"
+ category="org.rubypeople.rdt.ui.PropertyPageRubyProject"
id="org.rubypeople.rdt.ui.propertyPages.ProblemSeveritiesPreferencePage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -0,0 +1,48 @@
+package org.rubypeople.rdt.internal.corext.codemanipulation;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.rubypeople.rdt.core.IRubyProject;
+
+public class StubUtility {
+
+ /**
+ * Returns the line delimiter which is used in the specified project.
+ *
+ * @param project the ruby project, or <code>null</code>
+ * @return the used line delimiter
+ */
+ public static String getLineDelimiterUsed(IRubyProject project) {
+ return getProjectLineDelimiter(project);
+ }
+
+ private static String getProjectLineDelimiter(IRubyProject javaProject) {
+ IProject project= null;
+ if (javaProject != null)
+ project= javaProject.getProject();
+
+ String lineDelimiter= getLineDelimiterPreference(project);
+ if (lineDelimiter != null)
+ return lineDelimiter;
+
+ return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static String getLineDelimiterPreference(IProject project) {
+ IScopeContext[] scopeContext;
+ if (project != null) {
+ // project preference
+ scopeContext= new IScopeContext[] { new ProjectScope(project) };
+ String lineDelimiter= Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
+ if (lineDelimiter != null)
+ return lineDelimiter;
+ }
+ // workspace preference
+ scopeContext= new IScopeContext[] { new InstanceScope() };
+ String platformDefault= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
+ }
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CodeFormatterUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CodeFormatterUtil.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/CodeFormatterUtil.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -2,168 +2,274 @@
import java.util.Map;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.Position;
import org.eclipse.text.edits.TextEdit;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.ToolFactory;
import org.rubypeople.rdt.core.formatter.DefaultCodeFormatterConstants;
import org.rubypeople.rdt.internal.corext.Assert;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
public class CodeFormatterUtil {
- /**
- * Creates edits that describe how to format the given string. Returns
- * <code>null</code> if the code could not be formatted for the given
- * kind.
- *
- * @throws IllegalArgumentException
- * If the offset and length are not inside the string, a
- * IllegalArgumentException is thrown.
- */
- public static TextEdit format2(int kind, String string, int offset, int length,
- int indentationLevel, String lineSeparator, Map options) {
- if (offset < 0 || length < 0 || offset + length > string.length()) { throw new IllegalArgumentException(
- "offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
- return ToolFactory.createCodeFormatter(options).format(kind, string, offset, length,
- indentationLevel, lineSeparator);
- }
+ /**
+ * Creates edits that describe how to format the given string. Returns
+ * <code>null</code> if the code could not be formatted for the given
+ * kind.
+ *
+ * @throws IllegalArgumentException
+ * If the offset and length are not inside the string, a
+ * IllegalArgumentException is thrown.
+ */
+ public static TextEdit format2(int kind, String string, int offset,
+ int length, int indentationLevel, String lineSeparator, Map options) {
+ if (offset < 0 || length < 0 || offset + length > string.length()) {
+ throw new IllegalArgumentException(
+ "offset or length outside of string. offset: " + offset + ", length: " + length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ return ToolFactory.createCodeFormatter(options).format(kind, string,
+ offset, length, indentationLevel, lineSeparator);
+ }
- /**
- * Returns the current indent width.
- *
- * @param project
- * the project where the source is used or <code>null</code> if
- * the project is unknown and the workspace default should be
- * used
- * @return the indent width
- * @since 0.8.0
- */
- public static int getIndentWidth(IRubyProject project) {
- String key;
- if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project,
- DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
- key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
- else
- key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+ /**
+ * Returns the current indent width.
+ *
+ * @param project
+ * the project where the source is used or <code>null</code> if
+ * the project is unknown and the workspace default should be
+ * used
+ * @return the indent width
+ * @since 0.8.0
+ */
+ public static int getIndentWidth(IRubyProject project) {
+ String key;
+ if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+ key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+ else
+ key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
- return getCoreOption(project, key, 4);
- }
+ return getCoreOption(project, key, 4);
+ }
- /**
- * Gets the current tab width.
- *
- * @param project
- * The project where the source is used, used for project
- * specific options or <code>null</code> if the project is
- * unknown and the workspace default should be used
- * @return The tab width
- */
- public static int getTabWidth(IRubyProject project) {
- /*
- * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used by
- * the core formatter. We piggy back the visual tab length setting in
- * that preference in that case.
- */
- String key;
- if (RubyCore.SPACE.equals(getCoreOption(project,
- DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
- key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
- else
- key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+ /**
+ * Gets the current tab width.
+ *
+ * @param project
+ * The project where the source is used, used for project
+ * specific options or <code>null</code> if the project is
+ * unknown and the workspace default should be used
+ * @return The tab width
+ */
+ public static int getTabWidth(IRubyProject project) {
+ /*
+ * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used by
+ * the core formatter. We piggy back the visual tab length setting in
+ * that preference in that case.
+ */
+ String key;
+ if (RubyCore.SPACE.equals(getCoreOption(project,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+ key = DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+ else
+ key = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
- return getCoreOption(project, key, 4);
- }
+ return getCoreOption(project, key, 4);
+ }
- /**
- * Returns the possibly <code>project</code>-specific core preference
- * defined under <code>key</code>.
- *
- * @param project
- * the project to get the preference from, or <code>null</code>
- * to get the global preference
- * @param key
- * the key of the preference
- * @return the value of the preference
- * @since 0.8.0
- */
- private static String getCoreOption(IRubyProject project, String key) {
- if (project == null) return RubyCore.getOption(key);
- return project.getOption(key, true);
- }
+ /**
+ * Returns the possibly <code>project</code>-specific core preference
+ * defined under <code>key</code>.
+ *
+ * @param project
+ * the project to get the preference from, or <code>null</code>
+ * to get the global preference
+ * @param key
+ * the key of the preference
+ * @return the value of the preference
+ * @since 0.8.0
+ */
+ private static String getCoreOption(IRubyProject project, String key) {
+ if (project == null)
+ return RubyCore.getOption(key);
+ return project.getOption(key, true);
+ }
- /**
- * Returns the possibly <code>project</code>-specific core preference
- * defined under <code>key</code>, or <code>def</code> if the value is
- * not a integer.
- *
- * @param project
- * the project to get the preference from, or <code>null</code>
- * to get the global preference
- * @param key
- * the key of the preference
- * @param def
- * the default value
- * @return the value of the preference
- * @since 0.8.0
- */
- private static int getCoreOption(IRubyProject project, String key, int def) {
- try {
- return Integer.parseInt(getCoreOption(project, key));
- } catch (NumberFormatException e) {
- return def;
- }
- }
+ /**
+ * Returns the possibly <code>project</code>-specific core preference
+ * defined under <code>key</code>, or <code>def</code> if the value is
+ * not a integer.
+ *
+ * @param project
+ * the project to get the preference from, or <code>null</code>
+ * to get the global preference
+ * @param key
+ * the key of the preference
+ * @param def
+ * the default value
+ * @return the value of the preference
+ * @since 0.8.0
+ */
+ private static int getCoreOption(IRubyProject project, String key, int def) {
+ try {
+ return Integer.parseInt(getCoreOption(project, key));
+ } catch (NumberFormatException e) {
+ return def;
+ }
+ }
- /**
- * Creates a string that represents the given number of indentation units.
- * The returned string can contain tabs and/or spaces depending on the core
- * formatter preferences.
- *
- * @param indentationUnits
- * the number of indentation units to generate
- * @param project
- * the project from which to get the formatter settings,
- * <code>null</code> if the workspace default should be used
- * @return the indent string
- */
- public static String createIndentString(int indentationUnits, IRubyProject project) {
- final String tabChar = getCoreOption(project,
- DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
- final int tabs, spaces;
- if (RubyCore.SPACE.equals(tabChar)) {
- tabs = 0;
- spaces = indentationUnits * getIndentWidth(project);
- } else if (RubyCore.TAB.equals(tabChar)) {
- // indentWidth == tabWidth
- tabs = indentationUnits;
- spaces = 0;
- } else if (DefaultCodeFormatterConstants.MIXED.equals(tabChar)) {
- int tabWidth = getTabWidth(project);
- int spaceEquivalents = indentationUnits * getIndentWidth(project);
- if (tabWidth > 0) {
- tabs = spaceEquivalents / tabWidth;
- spaces = spaceEquivalents % tabWidth;
- } else {
- tabs = 0;
- spaces = spaceEquivalents;
- }
- } else {
- // new indent type not yet handled
- Assert.isTrue(false);
- return null;
- }
+ /**
+ * Creates a string that represents the given number of indentation units.
+ * The returned string can contain tabs and/or spaces depending on the core
+ * formatter preferences.
+ *
+ * @param indentationUnits
+ * the number of indentation units to generate
+ * @param project
+ * the project from which to get the formatter settings,
+ * <code>null</code> if the workspace default should be used
+ * @return the indent string
+ */
+ public static String createIndentString(int indentationUnits,
+ IRubyProject project) {
+ final String tabChar = getCoreOption(project,
+ DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+ final int tabs, spaces;
+ if (RubyCore.SPACE.equals(tabChar)) {
+ tabs = 0;
+ spaces = indentationUnits * getIndentWidth(project);
+ } else if (RubyCore.TAB.equals(tabChar)) {
+ // indentWidth == tabWidth
+ tabs = indentationUnits;
+ spaces = 0;
+ } else if (DefaultCodeFormatterConstants.MIXED.equals(tabChar)) {
+ int tabWidth = getTabWidth(project);
+ int spaceEquivalents = indentationUnits * getIndentWidth(project);
+ if (tabWidth > 0) {
+ tabs = spaceEquivalents / tabWidth;
+ spaces = spaceEquivalents % tabWidth;
+ } else {
+ tabs = 0;
+ spaces = spaceEquivalents;
+ }
+ } else {
+ // new indent type not yet handled
+ Assert.isTrue(false);
+ return null;
+ }
- StringBuffer buffer = new StringBuffer(tabs + spaces);
- for (int i = 0; i < tabs; i++)
- buffer.append('\t');
- for (int i = 0; i < spaces; i++)
- buffer.append(' ');
- return buffer.toString();
- }
+ StringBuffer buffer = new StringBuffer(tabs + spaces);
+ for (int i = 0; i < tabs; i++)
+ buffer.append('\t');
+ for (int i = 0; i < spaces; i++)
+ buffer.append(' ');
+ return buffer.toString();
+ }
- public static TextEdit format2(int kind, String string, int indentationLevel,
- String lineSeparator, Map options) {
- return format2(kind, string, 0, string.length(), indentationLevel, lineSeparator, options);
- }
+ public static TextEdit format2(int kind, String string,
+ int indentationLevel, String lineSeparator, Map options) {
+ return format2(kind, string, 0, string.length(), indentationLevel,
+ lineSeparator, options);
+ }
+
+ /**
+ * Old API. Consider to use format2 (TextEdit)
+ */
+ public static String format(int kind, String string, int offset,
+ int length, int indentationLevel, int[] positions,
+ String lineSeparator, Map options) {
+ TextEdit edit = format2(kind, string, offset, length, indentationLevel,
+ lineSeparator, options);
+ if (edit == null) {
+ // JavaPlugin.logErrorMessage("formatter failed to format (no edit
+ // returned). Will use unformatted text instead. kind: " + kind + ",
+ // string: " + string); //$NON-NLS-1$ //$NON-NLS-2$
+ return string.substring(offset, offset + length);
+ }
+ String formatted = getOldAPICompatibleResult(string, edit,
+ indentationLevel, positions, lineSeparator, options);
+ return formatted.substring(offset, formatted.length()
+ - (string.length() - (offset + length)));
+ }
+
+ private static String getOldAPICompatibleResult(String string, TextEdit edit, int indentationLevel, int[] positions, String lineSeparator, Map options) {
+ Position[] p= null;
+
+ if (positions != null) {
+ p= new Position[positions.length];
+ for (int i= 0; i < positions.length; i++) {
+ p[i]= new Position(positions[i], 0);
+ }
+ }
+ String res= evaluateFormatterEdit(string, edit, p);
+
+ if (positions != null) {
+ for (int i= 0; i < positions.length; i++) {
+ Position curr= p[i];
+ positions[i]= curr.getOffset();
+ }
+ }
+ return res;
+ }
+ /**
+ * Evaluates the edit on the given string.
+ * @throws IllegalArgumentException If the positions are not inside the string, a
+ * IllegalArgumentException is thrown.
+ */
+ public static String evaluateFormatterEdit(String string, TextEdit edit, Position[] positions) {
+ try {
+ Document doc= createDocument(string, positions);
+ edit.apply(doc, 0);
+ if (positions != null) {
+ for (int i= 0; i < positions.length; i++) {
+ Assert.isTrue(!positions[i].isDeleted, "Position got deleted"); //$NON-NLS-1$
+ }
+ }
+ return doc.get();
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e); // bug in the formatter
+ Assert.isTrue(false, "Formatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ private static Document createDocument(String string, Position[] positions) throws IllegalArgumentException {
+ Document doc= new Document(string);
+ try {
+ if (positions != null) {
+ final String POS_CATEGORY= "myCategory"; //$NON-NLS-1$
+
+ doc.addPositionCategory(POS_CATEGORY);
+ doc.addPositionUpdater(new DefaultPositionUpdater(POS_CATEGORY) {
+ protected boolean notDeleted() {
+ if (fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) {
+ fPosition.offset= fOffset + fLength; // deleted positions: set to end of remove
+ return false;
+ }
+ return true;
+ }
+ });
+ for (int i= 0; i < positions.length; i++) {
+ try {
+ doc.addPosition(POS_CATEGORY, positions[i]);
+ } catch (BadLocationException e) {
+ throw new IllegalArgumentException("Position outside of string. offset: " + positions[i].offset + ", length: " + positions[i].length + ", string size: " + string.length()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ }
+ }
+ } catch (BadPositionCategoryException cannotHappen) {
+ // can not happen: category is correctly set up
+ }
+ return doc;
+ }
+
+ public static String format(int kind, String string, int indentationLevel, int[] positions, String lineSeparator, IRubyProject project) {
+ Map options= project != null ? project.getOptions(true) : null;
+ return format(kind, string, 0, string.length(), indentationLevel, positions, lineSeparator, options);
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -14,6 +14,7 @@
*/
public final class RubyModelUtil {
+ public static final String DEFAULT_SCRIPT_SUFFIX = ".rb";
private static boolean PRIMARY_ONLY = false;
/**
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -48,9 +48,10 @@
private static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_INNER_CLASS= NAME_PREFIX + "innerclass_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_CLASSALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
- private static final String IMG_OBJS_MODULE = NAME_PREFIX + "module_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_MODULE = NAME_PREFIX + "module_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_MODULEALT= NAME_PREFIX + "modulefo_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_RUBY_MODEL= NAME_PREFIX + "ruby_model_obj.gif"; //$NON-NLS-1$
+ private static final String IMG_OBJS_SOURCE_FOLDER= NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_SCRIPT= NAME_PREFIX + "rscript_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_RUBY_RESOURCE= NAME_PREFIX + "rscript_resource_obj.gif"; //$NON-NLS-1$
private static final String IMG_OBJS_UNKNOWN= NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
@@ -107,7 +108,7 @@
public static final ImageDescriptor DESC_OBJS_IMPCONT= createManaged(T_OBJ, IMG_CTOOLS_RUBY_IMPORT_CONTAINER);
public static final ImageDescriptor DESC_OBJS_RUBY_MODEL= createManaged(T_OBJ, IMG_OBJS_RUBY_MODEL);
-
+ public static final ImageDescriptor DESC_OBJS_SOURCE_FOLDER= createManaged(T_OBJ, IMG_OBJS_SOURCE_FOLDER);
public static final ImageDescriptor DESC_OBJS_LOCAL_VAR = createManaged(T_OBJ, IMG_CTOOLS_RUBY_LOCAL_VAR);
public static final ImageDescriptor DESC_OBJS_GLOBAL = createManaged(T_OBJ, IMG_CTOOLS_RUBY_GLOBAL);
public static final ImageDescriptor DESC_OBJS_MODULE = createManaged(T_OBJ, IMG_OBJS_MODULE);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -25,6 +25,10 @@
public static String CoreUtility_buildproject_taskname;
public static String CoreUtility_buildall_taskname;
public static String CoreUtility_job_title;
+ public static String MultiTypeSelectionDialog_errorTitle;
+ public static String MultiTypeSelectionDialog_errorMessage;
+ public static String TypeSelectionDialog_errorTitle;
+ public static String TypeSelectionDialog_dialogMessage;
private RubyUIMessages() {
}
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 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -150,6 +150,13 @@
public static String MarkOccurrencesConfigurationBlock_markMethodExitPoints;
public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
public static String MarkOccurrencesConfigurationBlock_title;
+
+ public static String PropertyAndPreferencePage_useprojectsettings_label;
+ public static String PropertyAndPreferencePage_useworkspacesettings_change;
+ public static String PropertyAndPreferencePage_showprojectspecificsettings_label;
+ public static String ProjectSelectionDialog_title;
+ public static String ProjectSelectionDialog_desciption;
+ public static String ProjectSelectionDialog_filter;
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 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2006-12-15 15:32:50 UTC (rev 1706)
@@ -171,3 +171,11 @@
DebuggerPreferencePage_description_label=Debugger preferences
DebuggerPreferencePage_useRubyDebug_label=Use ruby-debug library
DebuggerPreferencePage_useRubyDebug_comment=ruby-debug requires a ruby version >= 1.8.4. At the time being a patched ruby-debug version must be used. It is packaged with RDT and can be found at {0}plugins/org.rubypeople.rdt.launching. It can be installed with the command 'gem install'. Please be aware that the package contains native code and therefore a c-compiler for your platform must be available.
+
+PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings
+PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings...
+PropertyAndPreferencePage_showprojectspecificsettings_label=Configure Project Specific Settings...
+
+ProjectSelectionDialog_title=Project Specific Configuration
+ProjectSelectionDialog_desciption=&Select the project to configure:
+ProjectSelectionDialog_filter=&Filter projects with no project specific settings
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProjectSelectionDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProjectSelectionDialog.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/ProjectSelectionDialog.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * 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.Set;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+import org.rubypeople.rdt.core.IRubyModel;
+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.ui.RubyElementLabelProvider;
+import org.rubypeople.rdt.ui.RubyElementSorter;
+import org.rubypeople.rdt.ui.StandardRubyElementContentProvider;
+
+
+public class ProjectSelectionDialog extends SelectionStatusDialog {
+
+ // the visual selection widget group
+ private TableViewer fTableViewer;
+ private Set fProjectsWithSpecifics;
+
+ // sizing constants
+ private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
+ private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
+
+ private final static String DIALOG_SETTINGS_SHOW_ALL= "ProjectSelectionDialog.show_all"; //$NON-NLS-1$
+
+ private ViewerFilter fFilter;
+
+ public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) {
+ super(parentShell);
+ setTitle(PreferencesMessages.ProjectSelectionDialog_title);
+ setMessage(PreferencesMessages.ProjectSelectionDialog_desciption);
+ fProjectsWithSpecifics= projectsWithSpecifics;
+
+ int shellStyle = getShellStyle();
+ setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
+
+ fFilter= new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return fProjectsWithSpecifics.contains(element);
+ }
+ };
+
+ }
+
+ /* (non-Rubydoc)
+ * Method declared on Dialog.
+ */
+ protected Control createDialogArea(Composite parent) {
+ // page group
+ Composite composite= (Composite) super.createDialogArea(parent);
+
+ Font font= parent.getFont();
+ composite.setFont(font);
+
+ createMessageArea(composite);
+
+ fTableViewer= new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
+ }
+ });
+ fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+ GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
+ data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
+ fTableViewer.getTable().setLayoutData(data);
+
+ fTableViewer.setLabelProvider(new RubyElementLabelProvider());
+ fTableViewer.setContentProvider(new StandardRubyElementContentProvider());
+ fTableViewer.setSorter(new RubyElementSorter());
+ fTableViewer.getControl().setFont(font);
+
+ Button checkbox= new Button(composite, SWT.CHECK);
+ checkbox.setText(PreferencesMessages.ProjectSelectionDialog_filter);
+ checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
+ checkbox.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ updateFilter(((Button) e.widget).getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateFilter(((Button) e.widget).getSelection());
+ }
+ });
+ IDialogSettings dialogSettings= RubyPlugin.getDefault().getDialogSettings();
+ boolean doFilter= !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty();
+ checkbox.setSelection(doFilter);
+ updateFilter(doFilter);
+
+ IRubyModel input= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ fTableViewer.setInput(input);
+
+ doSelectionChanged(new Object[0]);
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
+
+ protected void updateFilter(boolean selected) {
+ if (selected) {
+ fTableViewer.addFilter(fFilter);
+ } else {
+ fTableViewer.removeFilter(fFilter);
+ }
+ RubyPlugin.getDefault().getDialogSettings().put(DIALOG_SETTINGS_SHOW_ALL, !selected);
+ }
+
+ private void doSelectionChanged(Object[] objects) {
+ if (objects.length != 1) {
+ updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
+ setSelectionResult(null);
+ } else {
+ updateStatus(new StatusInfo());
+ setSelectionResult(objects);
+ }
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
+ */
+ protected void computeResult() {
+ }
+}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PropertyAndPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PropertyAndPreferencePage.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PropertyAndPreferencePage.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -1,213 +1,340 @@
/*******************************************************************************
- * 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
+ * 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/cpl-v10.html
- *
+ * 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.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
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.swt.widgets.Link;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
import org.rubypeople.rdt.internal.ui.dialogs.StatusUtil;
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.LayoutUtil;
import org.rubypeople.rdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+
/**
* Base for project property and preference pages
*/
-public abstract class PropertyAndPreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+
+ private Control fConfigurationBlockControl;
+ private ControlEnableState fBlockEnableState;
+ private Link fChangeWorkspaceSettings;
+ private SelectionButtonDialogField fUseProjectSettings;
+ private IStatus fBlockStatus;
+ private Composite fParentComposite;
+
+ private IProject fProject; // project or null
+ private Map fData; // page data
+
+ public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
+
+ public PropertyAndPreferencePage() {
+ fBlockStatus= new StatusInfo();
+ fBlockEnableState= null;
+ fProject= null;
+ fData= null;
+ }
- private Control fConfigurationBlockControl;
- private ControlEnableState fBlockEnableState;
- private Hyperlink fChangeWorkspaceSettings;
- private SelectionButtonDialogField fUseProjectSettings;
- private IStatus fBlockStatus;
+ protected abstract Control createPreferenceContent(Composite composite);
+ protected abstract boolean hasProjectSpecificOptions(IProject project);
+
+ protected abstract String getPreferencePageID();
+ protected abstract String getPropertyPageID();
+
+ protected boolean supportsProjectSpecificOptions() {
+ return getPropertyPageID() != null;
+ }
+
+ protected boolean offerLink() {
+ return fData == null || !Boolean.TRUE.equals(fData.get(DATA_NO_LINK));
+ }
+
+ protected Label createDescriptionLabel(Composite parent) {
+ fParentComposite= parent;
+ if (isProjectPreferencePage()) {
+ Composite composite= new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ layout.numColumns= 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ IDialogFieldListener listener= new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
+ }
+ };
+
+ fUseProjectSettings= new SelectionButtonDialogField(SWT.CHECK);
+ fUseProjectSettings.setDialogFieldListener(listener);
+ fUseProjectSettings.setLabelText(PreferencesMessages.PropertyAndPreferencePage_useprojectsettings_label);
+ fUseProjectSettings.doFillIntoGrid(composite, 1);
+ LayoutUtil.setHorizontalGrabbing(fUseProjectSettings.getSelectionButton(null));
+
+ if (offerLink()) {
+ fChangeWorkspaceSettings= createLink(composite, PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
+ fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+ } else {
+ LayoutUtil.setHorizontalSpan(fUseProjectSettings.getSelectionButton(null), 2);
+ }
+
+ Label horizontalLine= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+ horizontalLine.setFont(composite.getFont());
+ } else if (supportsProjectSpecificOptions() && offerLink()) {
+ fChangeWorkspaceSettings= createLink(parent, PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
+ fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
+ }
- private IProject fProject; // project or null
-
- public PropertyAndPreferencePage() {
- fBlockStatus = new StatusInfo();
- fBlockEnableState = null;
- fProject = null;
+ return super.createDescriptionLabel(parent);
}
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+ Composite composite= new Composite(parent, SWT.NONE);
+ GridLayout layout= new GridLayout();
+ layout.marginHeight= 0;
+ layout.marginWidth= 0;
+ composite.setLayout(layout);
+ composite.setFont(parent.getFont());
+
+ GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
+
+ fConfigurationBlockControl= createPreferenceContent(composite);
+ fConfigurationBlockControl.setLayoutData(data);
+ if (isProjectPreferencePage()) {
+ boolean useProjectSettings= hasProjectSpecificOptions(getProject());
+ enableProjectSpecificSettings(useProjectSettings);
+ }
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setFont(parent.getFont());
-
- GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
-
- fConfigurationBlockControl= createPreferenceContent(composite);
- fConfigurationBlockControl.setLayoutData(data);
+ Dialog.applyDialogFont(composite);
+ return composite;
+ }
- if (isProjectPreferencePage()) {
- boolean useProjectSettings= hasProjectSpecificOptions(getProject());
- enableProjectSpecificSettings(useProjectSettings);
- }
+ private Link createLink(Composite composite, String text) {
+ Link link= new Link(composite, SWT.NONE);
+ link.setFont(composite.getFont());
+ link.setText("<A>" + text + "</A>"); //$NON-NLS-1$//$NON-NLS-2$
+ link.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ doLinkActivated((Link) e.widget);
+ }
- Dialog.applyDialogFont(composite);
- return composite;
- }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ doLinkActivated((Link) e.widget);
+ }
+ });
+ return link;
+ }
+
+ protected boolean useProjectSettings() {
+ return isProjectPreferencePage() && fUseProjectSettings != null && fUseProjectSettings.isSelected();
+ }
+
+ protected boolean isProjectPreferencePage() {
+ return fProject != null;
+ }
+
+ protected IProject getProject() {
+ return fProject;
+ }
+
+ final void doLinkActivated(Link link) {
+ Map data= new HashMap();
+ data.put(DATA_NO_LINK, Boolean.TRUE);
+
+ if (isProjectPreferencePage()) {
+ openWorkspacePreferences(data);
+ } else {
+ HashSet projectsWithSpecifics= new HashSet();
+ try {
+ IRubyProject[] projects= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot()).getRubyProjects();
+ for (int i= 0; i < projects.length; i++) {
+ IRubyProject curr= projects[i];
+ if (hasProjectSpecificOptions(curr.getProject())) {
+ projectsWithSpecifics.add(curr);
+ }
+ }
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ ProjectSelectionDialog dialog= new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
+ if (dialog.open() == Window.OK) {
+ IRubyProject res= (IRubyProject) dialog.getFirstResult();
+ openProjectProperties(res.getProject(), data);
+ }
+ }
+ }
+
+ protected final void openWorkspacePreferences(Object data) {
+ String id= getPreferencePageID();
+ PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
+ }
+
+ protected final void openProjectProperties(IProject project, Object data) {
+ String id= getPropertyPageID();
+ if (id != null) {
+ PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
+ }
+ }
+
+
+ protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+ fUseProjectSettings.setSelection(useProjectSpecificSettings);
+ enablePreferenceContent(useProjectSpecificSettings);
+ updateLinkVisibility();
+ doStatusChanged();
+ }
+
+ private void updateLinkVisibility() {
+ if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
+ return;
+ }
+
+ if (isProjectPreferencePage()) {
+ fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
+ }
+ }
+
- protected abstract Control createPreferenceContent(Composite composite);
- protected abstract boolean hasProjectSpecificOptions(IProject project);
- protected abstract String getPreferencePageID();
- protected abstract String getPropertyPageID();
-
- protected final void openWorkspacePreferences(Object data) {
- String id= getPreferencePageID();
- PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
- }
-
- protected boolean useProjectSettings() {
- return isProjectPreferencePage() && fUseProjectSettings != null
- && fUseProjectSettings.isSelected();
- }
+ protected void setPreferenceContentStatus(IStatus status) {
+ fBlockStatus= status;
+ doStatusChanged();
+ }
+
+ /**
+ * Returns a new status change listener that calls {@link #setPreferenceContentStatus(IStatus)}
+ * when the status has changed
+ * @return The new listener
+ */
+ protected IStatusChangeListener getNewStatusChangedListener() {
+ return new IStatusChangeListener() {
+ public void statusChanged(IStatus status) {
+ setPreferenceContentStatus(status);
+ }
+ };
+ }
+
+ protected IStatus getPreferenceContentStatus() {
+ return fBlockStatus;
+ }
- protected boolean isProjectPreferencePage() {
- return fProject != null;
- }
+ protected void doStatusChanged() {
+ if (!isProjectPreferencePage() || useProjectSettings()) {
+ updateStatus(fBlockStatus);
+ } else {
+ updateStatus(new StatusInfo());
+ }
+ }
+
+ protected void enablePreferenceContent(boolean enable) {
+ if (enable) {
+ if (fBlockEnableState != null) {
+ fBlockEnableState.restore();
+ fBlockEnableState= null;
+ }
+ } else {
+ if (fBlockEnableState == null) {
+ fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
+ }
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ if (useProjectSettings()) {
+ enableProjectSpecificSettings(false);
+ }
+ super.performDefaults();
+ }
- protected IProject getProject() {
- return fProject;
- }
+ private void updateStatus(IStatus status) {
+ setValid(!status.matches(IStatus.ERROR));
+ StatusUtil.applyToStatusLine(this, status);
+ }
- private void doProjectWorkspaceStateChanged() {
- enablePreferenceContent(useProjectSettings());
- fChangeWorkspaceSettings.setVisible(!useProjectSettings());
- doStatusChanged();
- }
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
- protected void setPreferenceContentStatus(IStatus status) {
- fBlockStatus = status;
- doStatusChanged();
- }
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return fProject;
+ }
- /**
- * Returns a new status change listener that calls
- * {@link #setPreferenceContentStatus(IStatus)} when the status has changed
- *
- * @return The new listener
- */
- protected IStatusChangeListener getNewStatusChangedListener() {
- return new IStatusChangeListener() {
-
- public void statusChanged(IStatus status) {
- setPreferenceContentStatus(status);
- }
- };
- }
-
- protected IStatus getPreferenceContentStatus() {
- return fBlockStatus;
- }
-
- protected void doStatusChanged() {
- if (!isProjectPreferencePage() || useProjectSettings()) {
- updateStatus(fBlockStatus);
- } else {
- updateStatus(new StatusInfo());
- }
- }
-
- protected void enablePreferenceContent(boolean enable) {
- if (enable) {
- if (fBlockEnableState != null) {
- fBlockEnableState.restore();
- fBlockEnableState = null;
- }
- } else {
- if (fBlockEnableState == null) {
- fBlockEnableState = ControlEnableState.disable(fConfigurationBlockControl);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- if (useProjectSettings()) {
- fUseProjectSettings.setSelection(false);
- // fUseWorkspaceSettings.setSelection(true);
- }
- super.performDefaults();
- }
-
- private void updateStatus(IStatus status) {
- setValid(!status.matches(IStatus.ERROR));
- StatusUtil.applyToStatusLine(this, status);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
- */
- public IAdaptable getElement() {
- return fProject;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
- */
- public void setElement(IAdaptable element) {
- fProject = (IProject) element.getAdapter(IResource.class);
- }
-
- protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
- fUseProjectSettings.setSelection(useProjectSpecificSettings);
- enablePreferenceContent(useProjectSpecificSettings);
- updateLinkVisibility();
- doStatusChanged();
- }
-
- private void updateLinkVisibility() {
- if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
- return;
- }
-
- if (isProjectPreferencePage()) {
- fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
- }
- }
+ /* (non-Rubydoc)
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ fProject= (IProject) element.getAdapter(IResource.class);
+ }
+
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
+ */
+ public void applyData(Object data) {
+ if (data instanceof Map) {
+ fData= (Map) data;
+ }
+ if (fChangeWorkspaceSettings != null) {
+ if (!offerLink()) {
+ fChangeWorkspaceSettings.dispose();
+ fParentComposite.layout(true, true);
+ }
+ }
+ }
+
+ protected Map getData() {
+ return fData;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -206,6 +206,9 @@
case IRubyElement.SCRIPT:
return RubyPluginImages.DESC_OBJS_SCRIPT;
+
+ case IRubyElement.SOURCE_FOLDER:
+ return RubyPluginImages.DESC_OBJS_SOURCE_FOLDER;
case IRubyElement.RUBY_PROJECT:
IRubyProject jp = (IRubyProject) element;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/AbstractOpenWizardAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/AbstractOpenWizardAction.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/AbstractOpenWizardAction.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -148,8 +148,8 @@
notifyResult(res == Window.OK);
} catch (CoreException e) {
- String title = NewWizardMessages.getString("AbstractOpenWizardAction.createerror.title"); //$NON-NLS-1$
- String message = NewWizardMessages.getString("AbstractOpenWizardAction.createerror.message"); //$NON-NLS-1$
+ String title = NewWizardMessages.AbstractOpenWizardAction_createerror_title;
+ String message = NewWizardMessages.AbstractOpenWizardAction_createerror_message;
ExceptionHandler.handle(e, shell, title, message);
}
}
@@ -191,8 +191,8 @@
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace.getRoot().getProjects().length == 0) {
Shell shell = RubyPlugin.getActiveWorkbenchShell();
- String title = NewWizardMessages.getString("AbstractOpenWizardAction.noproject.title"); //$NON-NLS-1$
- String message = NewWizardMessages.getString("AbstractOpenWizardAction.noproject.message"); //$NON-NLS-1$
+ String title = NewWizardMessages.AbstractOpenWizardAction_noproject_title;
+ String message = NewWizardMessages.AbstractOpenWizardAction_noproject_message;
if (MessageDialog.openQuestion(shell, title, message)) {
IWorkbenchWindow window = RubyPlugin.getActiveWorkbenchWindow();
(new NewProjectAction(window)).run();
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.java 2006-12-15 15:31:22 UTC (rev 1705)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.java 2006-12-15 15:32:50 UTC (rev 1706)
@@ -10,40 +10,50 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.ui.wizards;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import org.eclipse.osgi.util.NLS;
-public class NewWizardMessages {
+public class NewWizardMessages extends NLS {
- private static final String RESOURCE_BUNDLE= NewWizardMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
+ private static final String BUNDLE_NAME= "org.rubypeople.rdt.internal.ui.wizards.NewWizardMessages";//$NON-NLS-1$
+
private NewWizardMessages() {
+ // Do not instantiate
}
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
+ public static String NewContainerWizardPage_container_label;
+ public static String NewContainerWizardPage_container_button;
+ public static String NewContainerWizardPage_ChooseSourceContainerDialog_title;
+ public static String NewContainerWizardPage_ChooseSourceContainerDialog_description;
+ public static String NewContainerWizardPage_error_EnterContainerName;
+ public static String NewContainerWizardPage_error_ProjectClosed;
+ public static String NewContainerWizardPage_warning_NotARubyProject;
+ public static String NewContainerWizardPage_warning_NotInARubyProject;
+ public static String NewContainerWizardPage_error_NotAFolder;
+ public static String NewContainerWizardPage_error_ContainerDoesNotExist;
+ public static String AbstractOpenWizardAction_createerror_message;
+ public static String AbstractOpenWizardAction_createerror_title;
+ public static String AbstractOpenWizardAction_noproject_title;
+ public static String AbstractOpenWizardAction_noproject_message;
+
+ public static String N...
[truncated message content] |