mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
More documentation, some minor refactorings
This commit is contained in:
+17
-5
@@ -14,30 +14,42 @@ import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Processing Editor Messages object handles localization stuff
|
||||
* using the ProcessingEditorMessages.preferences file. This class
|
||||
* is never instantiated, and all of its variables and methods are
|
||||
* Handles localization stuff using the ProcessingEditorMessages.preferences
|
||||
* file. This is never instantiated, and all of its variables and methods are
|
||||
* static.
|
||||
*
|
||||
* @author lonnen
|
||||
*/
|
||||
public class ProcessingEditorMessages {
|
||||
|
||||
/** location of the resource bundle */
|
||||
private static final String RESOURCE_BUNDLE= "org.processing.editor.ProcessingEditorMessages";//$NON-NLS-1$
|
||||
|
||||
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
/** the resource bundle object itself*/
|
||||
static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
|
||||
private ProcessingEditorMessages() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string for the given key from this resource bundle or one of its parents.
|
||||
* Calling this method is equivalent to calling <code> (String) getObject(key) </code>
|
||||
*
|
||||
* @param key the key for the desired string
|
||||
* @return the string for the given key
|
||||
*/
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||
return "!" + key + "!";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposes the resource bundle for direct access
|
||||
* @return this resource bundle
|
||||
*/
|
||||
public static ResourceBundle getResourceBundle() {
|
||||
return fgResourceBundle;
|
||||
}
|
||||
|
||||
+13
-13
@@ -33,7 +33,7 @@ import org.osgi.framework.BundleContext;
|
||||
public class ProcessingEditorPlugin extends AbstractUIPlugin {
|
||||
|
||||
public static final String PLUGIN_ID = "org.processing.ProcessingEditor";
|
||||
public static final String PROCESSING_PARTITIONING= "__processing_partitioning"; //$NON-NLS-1$
|
||||
public static final String PROCESSING_PARTITIONING= "__processing_partitioning";
|
||||
|
||||
// The shared instance
|
||||
private static ProcessingEditorPlugin fgInstance;
|
||||
@@ -143,18 +143,18 @@ public class ProcessingEditorPlugin extends AbstractUIPlugin {
|
||||
* @param filename the file to be loaded
|
||||
* @return BufferedInputStream to read the file with
|
||||
*/
|
||||
public BufferedInputStream getFileInputStream(String filename) {
|
||||
Bundle bundle = getDefault().getBundle();
|
||||
URL fileLocation;
|
||||
try {
|
||||
fileLocation = FileLocator.toFileURL(bundle.getEntry(filename));
|
||||
BufferedInputStream file = new BufferedInputStream(fileLocation.openStream());
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null; // this should be more explicit than a null pointer from a caught exception, right? [lonnen] June 15, 2010
|
||||
}
|
||||
public BufferedInputStream getFileInputStream(String filename) {
|
||||
//TODO consider replacing this with find (IPath path) and openStream (IPath file)
|
||||
Bundle bundle = getDefault().getBundle(); // the plugin's root directory, regardless of install directory
|
||||
try {
|
||||
URL fileLocation = FileLocator.toFileURL(bundle.getEntry(filename));
|
||||
BufferedInputStream file = new BufferedInputStream(fileLocation.openStream());
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null; // this should be more explicit than a null pointer from a caught exception, right? [lonnen] June 15, 2010
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+19
-2
@@ -13,20 +13,37 @@ package org.processing.editor.language;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Handles localization stuff using the ProcessingEditorMessages.preferences
|
||||
* file. This is never instantiated, and all of its variables and methods are
|
||||
* static.
|
||||
*
|
||||
* @author lonnen
|
||||
*/
|
||||
public class ProcessingEditorMessages {
|
||||
|
||||
/** location of the resource bundle */
|
||||
private static final String RESOURCE_BUNDLE= "org.processing.editor.ProcessingEditorMessages";//$NON-NLS-1$
|
||||
|
||||
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
/** the resource bundle object itself*/
|
||||
static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
|
||||
private ProcessingEditorMessages() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string for the given key from this resource bundle or one of its parents.
|
||||
* Calling this method is equivalent to calling <code> (String) getObject(key) </code>
|
||||
*
|
||||
* @param key the key for the desired string
|
||||
* @return the string for the given key
|
||||
*/
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||
return "!" + key + "!";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user