|
From: <caw...@us...> - 2007-01-24 14:39:49
|
Revision: 1870
http://svn.sourceforge.net/rubyeclipse/?rev=1870&view=rev
Author: cawilliams
Date: 2007-01-24 06:39:46 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
more moving to NLS based localization
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelStatus.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-01-24 14:11:53 UTC (rev 1869)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-01-24 14:39:46 UTC (rev 1870)
@@ -9,7 +9,6 @@
import org.eclipse.core.runtime.Status;
import org.rubypeople.rdt.internal.core.RubyModelStatus;
import org.rubypeople.rdt.internal.core.util.Messages;
-import org.rubypeople.rdt.internal.core.util.Util;
/**
* @author Chris
@@ -37,13 +36,13 @@
* indicating what is wrong with the name
*/
public static IStatus validateRubyScriptName(String name) {
- if (name == null) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"), null); //$NON-NLS-1$
+ if (name == null) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Messages.bind(Messages.convention_unit_nullName), null);
}
- if (!org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(name)) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ if (!org.rubypeople.rdt.internal.core.util.Util.isRubyLikeFileName(name)) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Messages.bind(Messages.convention_unit_notJavaName), null);
}
int index;
index = name.lastIndexOf('.');
- if (index == -1) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ if (index == -1) { return new Status(IStatus.ERROR, RubyCore.PLUGIN_ID, -1, Messages.bind(Messages.convention_unit_notJavaName), null);
}
IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
if (!status.isOK()) { return status; }
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java 2007-01-24 14:11:53 UTC (rev 1869)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ReconcileWorkingCopyOperation.java 2007-01-24 14:39:46 UTC (rev 1870)
@@ -17,6 +17,7 @@
import org.rubypeople.rdt.core.IRubyModelStatusConstants;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.util.Messages;
/**
* Reconcile a working copy and signal the changes through a delta.
@@ -44,8 +45,7 @@
protected void executeOperation() throws RubyModelException {
if (this.progressMonitor != null) {
if (this.progressMonitor.isCanceled()) throw new OperationCanceledException();
- this.progressMonitor.beginTask(org.rubypeople.rdt.internal.core.util.Util
- .bind("element.reconciling"), 2); //$NON-NLS-1$
+ this.progressMonitor.beginTask(Messages.bind(Messages.element_reconciling), 2);
}
RubyScript workingCopy = getWorkingCopy();
boolean wasConsistent = workingCopy.isConsistent();
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-01-24 14:11:53 UTC (rev 1869)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java 2007-01-24 14:39:46 UTC (rev 1870)
@@ -24,6 +24,7 @@
import org.rubypeople.rdt.core.IRubyModel;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.util.Messages;
/**
* @author Chris
@@ -173,7 +174,7 @@
case IResource.PROJECT:
return new RubyProject((IProject) resource, this);
default:
- throw new IllegalArgumentException(org.rubypeople.rdt.internal.core.util.Util.bind("element.invalidResourceForProject")); //$NON-NLS-1$
+ throw new IllegalArgumentException(Messages.bind(Messages.element_invalidResourceForProject));
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelStatus.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelStatus.java 2007-01-24 14:11:53 UTC (rev 1869)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelStatus.java 2007-01-24 14:39:46 UTC (rev 1870)
@@ -20,7 +20,7 @@
import org.rubypeople.rdt.core.IRubyModelStatusConstants;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.util.Util;
+import org.rubypeople.rdt.internal.core.util.Messages;
/**
* @see IRubyModelStatus
@@ -52,7 +52,7 @@
/**
* Singleton OK object
*/
- public static final IRubyModelStatus VERIFIED_OK = new RubyModelStatus(OK, OK, Util.bind("status.OK")); //$NON-NLS-1$
+ public static final IRubyModelStatus VERIFIED_OK = new RubyModelStatus(OK, OK, Messages.bind(Messages.status_OK));
/**
* Constructs an Ruby model status with no corresponding elements.
@@ -172,40 +172,40 @@
if (exception == null) {
switch (getCode()) {
case CORE_EXCEPTION :
- return Util.bind("status.coreException"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_coreException);
case BUILDER_INITIALIZATION_ERROR:
- return Util.bind("build.initializationError"); //$NON-NLS-1$
+ return Messages.bind(Messages.build_initializationError);
case BUILDER_SERIALIZATION_ERROR:
- return Util.bind("build.serializationError"); //$NON-NLS-1$
+ return Messages.bind(Messages.build_serializationError);
case DEVICE_PATH:
- return Util.bind("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
+ return Messages.bind(Messages.status_cannotUseDeviceOnPath, getPath().toString());
case DOM_EXCEPTION:
- return Util.bind("status.JDOMError"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_JDOMError);
case ELEMENT_DOES_NOT_EXIST:
- return Util.bind("element.doesNotExist",((RubyElement)elements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ return Messages.bind(Messages.element_doesNotExist,((RubyElement)elements[0]).toStringWithAncestors());
case ELEMENT_NOT_ON_CLASSPATH:
- return Util.bind("element.notOnClasspath",((RubyElement)elements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ return Messages.bind(Messages.element_notOnClasspath,((RubyElement)elements[0]).toStringWithAncestors());
case EVALUATION_ERROR:
- return Util.bind("status.evaluationError", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_evaluationError, string);
case INDEX_OUT_OF_BOUNDS:
- return Util.bind("status.indexOutOfBounds"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_indexOutOfBounds);
case INVALID_CONTENTS:
- return Util.bind("status.invalidContents"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidContents);
case INVALID_DESTINATION:
- return Util.bind("status.invalidDestination", ((RubyElement)elements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidDestination, ((RubyElement)elements[0]).toStringWithAncestors());
case INVALID_ELEMENT_TYPES:
- StringBuffer buff= new StringBuffer(Util.bind("operation.notSupported")); //$NON-NLS-1$
+ StringBuffer buff= new StringBuffer(Messages.bind(Messages.operation_notSupported));
for (int i= 0; i < elements.length; i++) {
if (i > 0) {
buff.append(", "); //$NON-NLS-1$
@@ -215,81 +215,81 @@
return buff.toString();
case INVALID_NAME:
- return Util.bind("status.invalidName", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidName, string);
case INVALID_PACKAGE:
- return Util.bind("status.invalidPackage", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidPackage, string);
case INVALID_PATH:
if (string != null) {
return string;
}
- return Util.bind("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ return Messages.bind(Messages.status_invalidPath, getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$
case INVALID_PROJECT:
- return Util.bind("status.invalidProject", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidProject, string);
case INVALID_RESOURCE:
- return Util.bind("status.invalidResource", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidResource, string);
case INVALID_RESOURCE_TYPE:
- return Util.bind("status.invalidResourceType", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidResourceType, string);
case INVALID_SIBLING:
if (string != null) {
- return Util.bind("status.invalidSibling", string); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidSibling, string);
}
- return Util.bind("status.invalidSibling", ((RubyElement)elements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ return Messages.bind(Messages.status_invalidSibling, ((RubyElement)elements[0]).toStringWithAncestors());
case IO_EXCEPTION:
- return Util.bind("status.IOException"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_IOException);
case NAME_COLLISION:
if (string != null) {
return string;
}
- return Util.bind("status.nameCollision", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ return Messages.bind(Messages.status_nameCollision, ""); //$NON-NLS-1$
case NO_ELEMENTS_TO_PROCESS:
- return Util.bind("operation.needElements"); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_needElements);
case NULL_NAME:
- return Util.bind("operation.needName"); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_needName);
case NULL_PATH:
- return Util.bind("operation.needPath"); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_needPath);
case NULL_STRING:
- return Util.bind("operation.needString"); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_needString);
case PATH_OUTSIDE_PROJECT:
- return Util.bind("operation.pathOutsideProject", string, ((RubyElement)elements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_pathOutsideProject, string, ((RubyElement)elements[0]).toStringWithAncestors());
case READ_ONLY:
IRubyElement element = elements[0];
String name = element.getElementName();
- return Util.bind("status.readOnly", name); //$NON-NLS-1$
+ return Messages.bind(Messages.status_readOnly, name);
case RELATIVE_PATH:
- return Util.bind("operation.needAbsolutePath", getPath().toString()); //$NON-NLS-1$
+ return Messages.bind(Messages.operation_needAbsolutePath, getPath().toString());
case TARGET_EXCEPTION:
- return Util.bind("status.targetException"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_targetException);
case UPDATE_CONFLICT:
- return Util.bind("status.updateConflict"); //$NON-NLS-1$
+ return Messages.bind(Messages.status_updateConflict);
case NO_LOCAL_CONTENTS :
- return Util.bind("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
+ return Messages.bind(Messages.status_noLocalContents, getPath().toString());
case CP_VARIABLE_PATH_UNBOUND:
IRubyProject javaProject = (IRubyProject)elements[0];
- return Util.bind("classpath.unboundVariablePath", path.makeRelative().toString(), javaProject.getElementName()); //$NON-NLS-1$
+ return Messages.bind(Messages.classpath_unboundVariablePath, path.makeRelative().toString(), javaProject.getElementName());
case CLASSPATH_CYCLE:
javaProject = (IRubyProject)elements[0];
- return Util.bind("classpath.cycle", javaProject.getElementName()); //$NON-NLS-1$
+ return Messages.bind(Messages.classpath_cycle, javaProject.getElementName());
case DISABLED_CP_EXCLUSION_PATTERNS:
javaProject = (IRubyProject)elements[0];
@@ -298,7 +298,7 @@
if (path.segment(0).toString().equals(projectName)) {
newPath = path.removeFirstSegments(1);
}
- return Util.bind("classpath.disabledInclusionExclusionPatterns", newPath.makeRelative().toString(), projectName); //$NON-NLS-1$
+ return Messages.bind(Messages.classpath_disabledInclusionExclusionPatterns, newPath.makeRelative().toString(), projectName);
case DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS:
javaProject = (IRubyProject)elements[0];
@@ -307,7 +307,7 @@
if (path.segment(0).toString().equals(projectName)) {
newPath = path.removeFirstSegments(1);
}
- return Util.bind("classpath.disabledMultipleOutputLocations", newPath.makeRelative().toString(), projectName); //$NON-NLS-1$
+ return Messages.bind(Messages.classpath_disabledMultipleOutputLocations, newPath.makeRelative().toString(), projectName);
}
if (string != null) {
return string;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-01-24 14:11:53 UTC (rev 1869)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java 2007-01-24 14:39:46 UTC (rev 1870)
@@ -11,9 +11,6 @@
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URI;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
@@ -42,20 +39,10 @@
*/
public class Util {
- /* Bundle containing messages */
- protected static ResourceBundle bundle;
private static boolean ENABLE_RUBY_LIKE_EXTENSIONS = true;
private static char[][] RUBY_LIKE_EXTENSIONS;
private static char[][] RUBY_LIKE_FILENAMES;
- private final static String bundleName = "org.rubypeople.rdt.internal.core.util.messages"; //$NON-NLS-1$
- private final static char[] DOUBLE_QUOTES = "''".toCharArray(); //$NON-NLS-1$
- private final static char[] SINGLE_QUOTE = "'".toCharArray(); //$NON-NLS-1$
-
- static {
- relocalize();
- }
-
private Util() {
// cannot be instantiated
}
@@ -107,123 +94,6 @@
}
}
- /**
- * Creates a NLS catalog for the given locale.
- */
- public static void relocalize() {
- try {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
- } catch (MissingResourceException e) {
- System.out
- .println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
- throw e;
- }
- }
-
- /**
- * Lookup the message with the given ID in this catalog
- */
- public static String bind(String id) {
- return bind(id, (String[]) null);
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
- public static String bind(String id, String[] arguments) {
- if (id == null) return "No message available"; //$NON-NLS-1$
- String message = null;
- try {
- message = bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully
- // by just returning
- // the id we were looking for. In most cases this is
- // semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
- }
- // for compatibility with MessageFormat which eliminates double quotes
- // in original message
- char[] messageWithNoDoubleQuotes = CharOperation.replace(message.toCharArray(),
- DOUBLE_QUOTES, SINGLE_QUOTE);
-
- if (arguments == null) return new String(messageWithNoDoubleQuotes);
-
- int length = messageWithNoDoubleQuotes.length;
- int start = 0;
- int end = length;
- StringBuffer output = null;
- while (true) {
- if ((end = CharOperation.indexOf('{', messageWithNoDoubleQuotes, start)) > -1) {
- if (output == null) output = new StringBuffer(length + arguments.length * 20);
- output.append(messageWithNoDoubleQuotes, start, end - start);
- if ((start = CharOperation.indexOf('}', messageWithNoDoubleQuotes, end + 1)) > -1) {
- int index = -1;
- String argId = new String(messageWithNoDoubleQuotes, end + 1, start - end - 1);
- try {
- index = Integer.parseInt(argId);
- if (arguments[index] == null) {
- output.append('{').append(argId).append('}'); // leave
- // parameter
- // in
- // since
- // no
- // better
- // arg
- // '{0}'
- } else {
- output.append(arguments[index]);
- }
- } catch (NumberFormatException nfe) { // could be nested
- // message ID
- // {compiler.name}
- boolean done = false;
- if (!id.equals(argId)) {
- String argMessage = null;
- try {
- argMessage = bundle.getString(argId);
- output.append(argMessage);
- done = true;
- } catch (MissingResourceException e) {
- // unable to bind argument, ignore (will leave
- // argument in)
- }
- }
- if (!done) output.append(messageWithNoDoubleQuotes, end + 1, start - end);
- } catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
- }
- start++;
- } else {
- output.append(messageWithNoDoubleQuotes, end, length);
- break;
- }
- } else {
- if (output == null) return new String(messageWithNoDoubleQuotes);
- output.append(messageWithNoDoubleQuotes, start, length - start);
- break;
- }
- }
- return output.toString();
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
- public static String bind(String id, String binding) {
- return bind(id, new String[] { binding});
- }
-
- /**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
- public static String bind(String id, String binding1, String binding2) {
- return bind(id, new String[] { binding1, binding2});
- }
-
/*
* Returns whether the given resource path matches one of the
* inclusion/exclusion patterns. NOTE: should not be asked directly using
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|