Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r36 - trunk/src/argouml-app/src/org/argouml/application/helpers

argouml-spl
Discussion topic

Back to topic list

svn commit: r36 - trunk/src/argouml-app/src/org/argouml/application/helpers

Author marcusvnac
Full name Marcus Vinícius de Ávila Couto
Date 2010-04-03 12:13:32 PDT
Message Author: marcusvnac
Date: 2010-04-03 12:13:31-0700
New Revision: 36

Added:
   trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Ap​plicationVersion.jav​a (contents, props changed)
   trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoader.java (contents, props changed)
   trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoaderWrapper.​java (contents, props changed)
   trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/pa​ckage.html

Log:
Initial version of ArgoUML-SPL.

Generated from ArgoUML release version v0.28.1

Added: trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Ap​plicationVersion.jav​a
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/src/argouml-app/sr​c/org/argouml/applic​ation/helpers/Applic​ationVersion.java?vi​ew=markup&pathre​v=36
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Ap​plicationVersion.jav​a 2010-04-03 12:13:31-0700
@@ -0,0 +1,104 @@
+// $Id$
+// Copyright (c) 2007-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.applicat​ion.helpers;
+
+/**
+ * Receives the version of the application at initialisation time.
+ * Also knows about website locations that depend on the version of ArgoUML.
+ *
+ * @author Michiel
+ */
+public class ApplicationVersion {
+ /**
+ * Version number.
+ */
+ private static String version;
+ private static String stableVersion;
+
+ /**
+ * Retrieve the version number of the application.
+ *
+ * @return the version number.
+ */
+ public static String getVersion() {
+ return version;
+ }
+
+ /**
+ * Retrieve the online HTML manual of ArgoUML for a critic.
+ * You need to append the critic class-name.
+ * This syntax is synchronized with:
+ * <ol>
+ * <li>Tags in the manual.
+ * <li>Name of the ArgoUML site.
+ * <li>How the manual is deployed on the site.
+ * </ol>
+ * so this must be updated when any of these change.
+ *
+ * @return the URL
+ */
+ public static String getManualForCritic() {
+ return "http://argouml-stats​.tigris.org/document​ation/"
+ + "manual-"
+ + stableVersion
+ + "-single/argomanual.​html#critics.";
+ }
+
+ /**
+ * Retrieve the URL of the online manual of ArgoUML.
+ *
+ * @return the URL
+ */
+ public static String getOnlineManual() {
+ return "http://argouml-stats​.tigris.org/nonav/do​cumentation/"
+ + "manual-" + stableVersion + "/";
+ }
+
+ /**
+ * Retrieve the URL of the location for online support for ArgoUML.
+ *
+ * @return the URL
+ */
+ public static String getOnlineSupport() {
+ return "http://argouml.tigri​s.org/nonav/support.​html";
+ }
+
+ /**
+ * Don't allow instantiation.
+ */
+ private ApplicationVersion() {
+ }
+
+ /**
+ * @param v The version to set.
+ * @param sv The stable version to set.
+ */
+ public static void init(String v, String sv) {
+ assert version == null;
+ version = v;
+ assert stableVersion == null;
+ stableVersion = sv;
+ }
+}

Added: trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoader.java
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/src/argouml-app/sr​c/org/argouml/applic​ation/helpers/Resour​ceLoader.java?view=m​arkup&pathrev=36​
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoader.java 2010-04-03 12:13:31-0700
@@ -0,0 +1,241 @@
+// $Id$
+// Copyright (c) 1996-2006 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.applicat​ion.helpers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * This class manages the resource locations needed within the application.
+ * Already loaded resources are cached. The resources can be searched in
+ * different locations.
+ * <p>
+ * Derived from org.tigris.gef.util.​ResourceLoader with formatting and
+ * variable naming changed to conform to ArgoUML coding standard.
+ * <p>
+ * We use a local copy to reduce coupling to GEF and so that GEF isn't trying
+ * to do uplevel accesses to the application resources (which won't work in
+ * environments that enforce strict partitioning between projects eg Eclipse).
+ *
+ * @author Original Author: Thorsten Sturm
+ */
+
+// NOTE: This is package scope to force callers to use ResourceLoaderWrapper
+class ResourceLoader {
+ private static HashMap<String, Icon> resourceCache =
+ new HashMap<String, Icon>();
+ private static List<String> resourceLocations = new ArrayList<String>();
+ private static List<String> resourceExtensions = new ArrayList<String>();
+
+ public static ImageIcon lookupIconResource(String resource) {
+ return lookupIconResource(resource, resource);
+ }
+
+ public static ImageIcon lookupIconResource(String resource, String desc) {
+ return lookupIconResource(resource, desc, null);
+ }
+
+ public static ImageIcon lookupIconResource(String resource,
+ ClassLoader loader) {
+ return lookupIconResource(resource, resource, loader);
+ }
+
+ /**
+ * This method tries to find an ImageIcon for the given name in all known
+ * locations. The file extension of the used image file can be any of the
+ * known extensions.
+ *
+ * @param resource
+ * Name of the image to be looked after.
+ * @param desc
+ * A description for the ImageIcon.
+ * @param loader
+ * The class loader that should be used for loading the resource.
+ * @return ImageIcon for the given name, null if no image could be found.
+ */
+ public static ImageIcon lookupIconResource(String resource, String desc,
+ ClassLoader loader) {
+ resource = toJavaIdentifier(resource);
+ if (isInCache(resource)) {
+ return (ImageIcon) resourceCache.get(resource);
+ }
+
+ ImageIcon res = null;
+ java.net.URL imgURL = lookupIconUrl(resource, loader);
+
+ if (imgURL != null) {
+ res = new ImageIcon(imgURL, desc);
+ synchronized (resourceCache) {
+ resourceCache.put(resource, res);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Search for the given resource with one of the registered extensions, in
+ * one of the registered locations. The URL of the first found is returned.
+ *
+ * @param resource
+ * base name of resource to search for
+ * @param loader
+ * class loader to use
+ * @return URL representing first location the resource was found or null if
+ * it was not found in any of the registered locations.
+ */
+ static java.net.URL lookupIconUrl(String resource,
+ ClassLoader loader) {
+ java.net.URL imgURL = null;
+ for (Iterator extensions = resourceExtensions.iterator();
+ extensions.hasNext();) {
+ String tmpExt = (String) extensions.next();
+ for (Iterator locations = resourceLocations.iterator();
+ locations.hasNext();) {
+ String imageName =
+ locations.next() + "/" + resource + "." + tmpExt;
+// System.out.println("​[ResourceLoader] try loading " + imageName);
+ if (loader == null) {
+ imgURL = ResourceLoader.class​.getResource(imageNa​me);
+ } else {
+ imgURL = loader.getResource(imageName);
+ }
+ if (imgURL != null) {
+ break;
+ }
+ }
+ if (imgURL != null) {
+ break;
+ }
+ }
+ return imgURL;
+ }
+
+ /**
+ * Adds a location (path) to the list of known locations. Locations are
+ * searched in the order they are added, so for best performance add the
+ * most likely locations first.
+ *
+ * @param location
+ * String representation of the new location.
+ */
+ public static void addResourceLocation(String location) {
+ if (!containsLocation(location)) {
+ resourceLocations.ad​d(location);
+ }
+ }
+
+ /**
+ * Add an extension to the list of known extensions. Extensions are searched
+ * in the order they are added, so for best performance add the most likely
+ * extensions first.
+ *
+ * @param extension
+ * String representation of the new extension.
+ */
+ public static void addResourceExtension(String extension) {
+ if (!containsExtension(extension)) {
+ resourceExtensions.a​dd(extension);
+ }
+ }
+
+ /**
+ * This method removes a location from the list of known locations.
+ *
+ * @param location
+ * String representation of the location to be removed.
+ */
+ public static void removeResourceLocation(String location) {
+ for (Iterator iter = resourceLocations.iterator(); iter.hasNext();) {
+ String loc = (String) iter.next();
+ if (loc.equals(location)) {
+ resourceLocations.remove(loc);
+ break;
+ }
+ }
+ }
+
+ /**
+ * This method removes a extension from the list of known extensions.
+ *
+ * @param extension String representation of the extension to be removed.
+ */
+ public static void removeResourceExtension(String extension) {
+ for (Iterator iter = resourceExtensions.iterator(); iter.hasNext();) {
+ String ext = (String) iter.next();
+ if (ext.equals(extension)) {
+ resourceExtensions.remove(ext);
+ break;
+ }
+ }
+ }
+
+ public static boolean containsExtension(String extension) {
+ return resourceExtensions.c​ontains(extension);
+ }
+
+ public static boolean containsLocation(String location) {
+ return resourceLocations.co​ntains(location);
+ }
+
+ public static boolean isInCache(String resource) {
+ return resourceCache.contai​nsKey(resource);
+ }
+
+ /*
+ * Strip all characters out of <var>s</var> that could not be part of a
+ * valid Java identifier. Return either the given string (if all characters
+ * were valid), or a new string with all invalid characters stripped out.
+ * This allows automatic conversion of strings containing punctuation and
+ * spaces to a resource name that can be looked up.
+ */
+ public static final String toJavaIdentifier(String s) {
+ int len = s.length();
+ int pos = 0;
+ for (int i = 0; i < len; i++, pos++) {
+ if (!Character.isJavaId​entifierPart(s.charA​t(i))) break;
+ }
+ if (pos == len) {
+ return s;
+ }
+
+ StringBuffer buf = new StringBuffer(len);
+ buf.append(s.substring(0, pos));
+
+ // skip pos, we know it's not a valid char from above
+ for (int i = pos + 1; i < len; i++) {
+ char c = s.charAt(i);
+ if (Character.isJavaIde​ntifierPart(c)) {
+ buf.append(c);
+ }
+ }
+ return buf.toString();
+ }
+} /* end class ResourceLoader */
+

Added: trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoaderWrapper.​java
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/src/argouml-app/sr​c/org/argouml/applic​ation/helpers/Resour​ceLoaderWrapper.java​?view=markup&pat​hrev=36
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/Re​sourceLoaderWrapper.​java 2010-04-03 12:13:31-0700
@@ -0,0 +1,489 @@
+// $Id$
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.applicat​ion.helpers;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.UIManager;
+
+//#if defined(LOGGING)
+//@#$LPS-LOGGING:G​ranularityType:Impor​t
+import org.apache.log4j.Logger;
+//#endif
+import org.argouml.i18n.Translator;
+import org.argouml.model.Da​taTypesHelper;
+import org.argouml.model.In​validElementExceptio​n;
+import org.argouml.model.Model;
+
+
+/**
+ * Wrapper around org.tigris.gef.util.​ResourceLoader.<p​>
+ *
+ * Necessary since ArgoUML needs some extra init.
+ *
+ * @since Nov 24, 2002
+ * @author jaap dot branderhorst at xs4all dot nl
+ * @stereotype singleton
+ */
+public final class ResourceLoaderWrapper {
+ //#if defined(LOGGING)
+ //@#$LPS-LOGGING:Gr​anularityType:Field
+ /**
+ * Logger.
+ */
+ private static final Logger LOG =
+ Logger.getLogger(Res​ourceLoaderWrapper.c​lass);
+ //#endif
+ private static ImageIcon initialStateIcon;
+ private static ImageIcon deepIcon;
+ private static ImageIcon shallowIcon;
+ private static ImageIcon forkIcon;
+ private static ImageIcon joinIcon;
+ private static ImageIcon branchIcon;
+ private static ImageIcon junctionIcon;
+ private static ImageIcon realizeIcon;
+ private static ImageIcon signalIcon;
+ private static ImageIcon exceptionIcon;
+ private static ImageIcon commentIcon;
+
+ private Hashtable<Class, Icon> iconCache = new Hashtable<Class, Icon>();
+
+ /**
+ * Singleton implementation.
+ */
+ private static ResourceLoaderWrapper instance = new ResourceLoaderWrapper();
+
+
+ /**
+ * Returns the singleton instance.
+ *
+ * @return ResourceLoaderWrapper
+ */
+ public static ResourceLoaderWrapper getInstance() {
+ return instance;
+ }
+
+ /**
+ * Constructor for ResourceLoaderWrapper.
+ */
+ private ResourceLoaderWrapper() {
+ initResourceLoader();
+ }
+
+ /**
+ * Calculate the path to a look and feel object.
+ *
+ * @param classname
+ * The look and feel classname
+ * @param element
+ * The en part of the path.
+ * @return the complete path.
+ */
+ private static String lookAndFeelPath(String classname, String element) {
+ return "/org/argouml/Images/plaf/"
+ + classname.replace('.', '/')
+ + "/toolbarButtonGraphics/"
+ + element;
+ }
+
+ /**
+ * Initializes the resourceloader.
+ *
+ * LookupIconResource checks if there are locations and extensions known.
+ * If there are none, this method is called to initialize the resource
+ * loader. Originally, this method was placed within Main but this coupled
+ * Main and the resourceLoader too much.
+ */
+ private static void initResourceLoader() {
+ String lookAndFeelClassName;
+ if ("true".equals(Syste​m.getProperty("force​.nativelaf", "false"))) {
+ lookAndFeelClassName = UIManager.getSystemL​ookAndFeelClassName(​);
+ } else {
+ lookAndFeelClassName = "javax.swing.plaf.me​tal.MetalLookAndFeel​";
+ }
+ String lookAndFeelGeneralImagePath =
+ lookAndFeelPath(look​AndFeelClassName, "general");
+ String lookAndFeelNavigationImagePath =
+ lookAndFeelPath(look​AndFeelClassName, "navigation");
+ String lookAndFeelDiagramImagePath =
+ lookAndFeelPath(look​AndFeelClassName, "argouml/diagrams");
+ String lookAndFeelElementImagePath =
+ lookAndFeelPath(look​AndFeelClassName, "argouml/elements");
+ String lookAndFeelArgoUmlImagePath =
+ lookAndFeelPath(look​AndFeelClassName, "argouml");
+ ResourceLoader.addRe​sourceExtension("gif​");
+ ResourceLoader.addRe​sourceExtension("png​");
+ ResourceLoader.addRe​sourceLocation(lookA​ndFeelGeneralImagePa​th);
+ ResourceLoader.addRe​sourceLocation(lookA​ndFeelNavigationImag​ePath);
+ ResourceLoader.addRe​sourceLocation(lookA​ndFeelDiagramImagePa​th);
+ ResourceLoader.addRe​sourceLocation(lookA​ndFeelElementImagePa​th);
+ ResourceLoader.addRe​sourceLocation(lookA​ndFeelArgoUmlImagePa​th);
+ ResourceLoader.addRe​sourceLocation("/org​/argouml/Images");
+ ResourceLoader.addRe​sourceLocation("/org​/tigris/gef/Images")​;
+
+ // Initialze GEF's version of the loader too
+ // TODO: We should probably be passing icons that we loaded ourselves
+ // but there doesn't seem to be a way to do that with GEF - tfm
+ org.tigris.gef.util.​ResourceLoader.addRe​sourceExtension("gif​");
+ org.tigris.gef.util.​ResourceLoader.addRe​sourceExtension("png​");
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​(lookAndFeelGeneralI​magePath);
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​(lookAndFeelNavigati​onImagePath);
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​(lookAndFeelDiagramI​magePath);
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​(lookAndFeelElementI​magePath);
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​(lookAndFeelArgoUmlI​magePath);
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​("/org/argouml/Image​s");
+ org.tigris.gef.util.​ResourceLoader
+ .addResourceLocation​("/org/tigris/gef/Im​ages");
+
+ initialStateIcon = ResourceLoader.looku​pIconResource("Initi​al");
+ deepIcon = ResourceLoader.looku​pIconResource("DeepH​istory");
+ shallowIcon = ResourceLoader.looku​pIconResource("Shall​owHistory");
+ forkIcon = ResourceLoader.looku​pIconResource("Fork"​);
+ joinIcon = ResourceLoader.looku​pIconResource("Join"​);
+ branchIcon = ResourceLoader.looku​pIconResource("Choic​e");
+ junctionIcon = ResourceLoader.looku​pIconResource("Junct​ion");
+ realizeIcon = ResourceLoader.looku​pIconResource("Reali​zation");
+ signalIcon = ResourceLoader.looku​pIconResource("Signa​lSending");
+ exceptionIcon = ResourceLoader.looku​pIconResource("Excep​tion");
+ commentIcon = ResourceLoader.looku​pIconResource("Note"​);
+ }
+
+ /**
+ * This public operation is needed
+ * to allow modules to add their own images.
+ *
+ * @param location the path were the images are
+ */
+ public static void addResourceLocation(String location) {
+ ResourceLoader.addRe​sourceLocation(locat​ion);
+ }
+
+ /**
+ * Find the correct icon for a key.
+ *
+ * @param resource The name of the resource to look up.
+ * @return The ImageIcon.
+ */
+ public static ImageIcon lookupIconResource(String resource) {
+ return ResourceLoader.looku​pIconResource(resour​ce);
+ }
+
+ /**
+ * Find the correct icon for a key.
+ *
+ * @param resource The name of the resource to look up.
+ * @param desc The description for the icon.
+ * @return The ImageIcon.
+ */
+ public static ImageIcon lookupIconResource(String resource, String desc) {
+ return ResourceLoader.looku​pIconResource(resour​ce, desc);
+ }
+
+ /**
+ * Look up the Icon for a key.
+ *
+ * @param key The key to find.
+ * @return The found Icon.
+ */
+ public static ImageIcon lookupIcon(String key) {
+ return lookupIconResource(g​etImageBinding(key),​
+ Translator.localize(key));
+ }
+
+ /**
+ * Find the Icon for a given model element.
+ *
+ * @return The Icon or <code>null</code> if there is no Icon.
+ * @param value The model element.
+ *
+ * TODO: This should not use string matching on classnames to do this
+ * since this means that we have knowledge about how the model
+ * elements are implemented outside of the Model component.
+ */
+ public Icon lookupIcon(Object value) {
+ if (value == null) {
+ throw new IllegalArgumentException(
+ "Attempted to get an icon given a null key");
+ }
+
+ if (value instanceof String) {
+ return null;
+ }
+
+ Icon icon = iconCache.get(value.​getClass());
+
+ try {
+ if (Model.getFacade().i​sAPseudostate(value)​) {
+
+ Object kind = Model.getFacade().ge​tKind(value);
+ DataTypesHelper helper = Model.getDataTypesHelper();
+ if (helper.equalsINITIA​LKind(kind)) {
+ icon = initialStateIcon;
+ }
+ if (helper.equalsDeepHi​storyKind(kind)) {
+ icon = deepIcon;
+ }
+ if (helper.equalsShallo​wHistoryKind(kind)) {
+ icon = shallowIcon;
+ }
+ if (helper.equalsFORKKind(kind)) {
+ icon = forkIcon;
+ }
+ if (helper.equalsJOINKind(kind)) {
+ icon = joinIcon;
+ }
+ if (helper.equalsCHOICEKind(kind)) {
+ icon = branchIcon;
+ }
+ if (helper.equalsJUNCTI​ONKind(kind)) {
+ icon = junctionIcon;
+ }
+ // if (MPseudostateKind.FI​NAL.equals(kind))
+ // icon = _FinalStateIcon;
+ }
+
+ if (Model.getFacade().i​sAAbstraction(value)​) {
+ icon = realizeIcon;
+ }
+ if (Model.getFacade().i​sAException(value)) {
+ icon = exceptionIcon;
+ } else {
+ // needs more work: sending and receiving icons
+ if (Model.getFacade().i​sASignal(value)) {
+ icon = signalIcon;
+ }
+ }
+
+ if (Model.getFacade().i​sAComment(value)) {
+ icon = commentIcon;
+ }
+
+ if (icon == null) {
+
+ String cName = Model.getMetaTypes()​.getName(value);
+
+ icon = lookupIconResource(cName);
+ //#if defined(LOGGING)
+ //@#$LPS-LOGGING:Gr​anularityType:Comman​d
+ //@#$LPS-LOGGING:Lo​calization:NestedCom​mand
+ if (icon == null) {
+ LOG.debug("Can't find icon for " + cName);
+ } else
+ //#else
+ if (icon != null)
+ //#endif
+ {
+ synchronized (iconCache) {
+ iconCache.put(value.getClass(), icon);
+ }
+ }
+
+ }
+ } catch (InvalidElementException e) {
+ //#if defined(LOGGING)
+ //@#$LPS-LOGGING:Gr​anularityType:Comman​d
+ LOG.debug("Attempted to get icon for deleted element");
+ //#endif
+ return null;
+ }
+ return icon;
+ }
+
+ /**
+ * Map to convert tokens into file names.
+ */
+ private static Map<String, String> images = new HashMap<String, String>();
+ static {
+ images.put("action.a​bout-argouml", "AboutArgoUML");
+ images.put("action.a​ctivity-diagram", "Activity Diagram");
+ images.put("action.c​lass-diagram", "Class Diagram");
+ images.put("action.c​ollaboration-diagram​", "Collaboration Diagram");
+ images.put("action.d​eployment-diagram", "Deployment Diagram");
+ images.put("action.s​equence-diagram", "Sequence Diagram");
+ images.put("action.s​tate-diagram", "State Diagram");
+ images.put("action.u​secase-diagram", "Use Case Diagram");
+ }
+
+ static {
+ images.put("action.a​dd-concurrent-region​", "Add Concurrent Region");
+ images.put("action.a​dd-message", "Add Message");
+ images.put("action.c​onfigure-perspective​s", "ConfigurePerspectives");
+ images.put("action.copy", "Copy");
+ images.put("action.cut", "Cut");
+ images.put("action.d​elete-concurrent-reg​ion", "DeleteConcurrentRegion");
+ images.put("action.d​elete-from-model", "DeleteFromModel");
+ images.put("action.find", "Find...");
+ images.put("action.i​mport-sources", "Import Sources...");
+ images.put("action.more-info", "More Info...");
+ images.put("action.n​avigate-back", "Navigate Back");
+ images.put("action.n​avigate-forward", "Navigate Forward");
+ images.put("action.new", "New");
+ images.put("action.n​ew-todo-item", "New To Do Item...");
+ images.put("action.o​pen-project", "Open Project...");
+ images.put("action.page-setup", "Page Setup...");
+ images.put("action.paste", "Paste");
+ images.put("action.print", "Print...");
+ images.put("action.properties", "Properties");
+ images.put("action.r​emove-from-diagram",​ "Remove From Diagram");
+ images.put("action.r​esolve-item", "Resolve Item...");
+ images.put("action.s​ave-project", "Save Project");
+ images.put("action.s​ave-project-as", "Save Project As...");
+ images.put("action.settings", "Settings...");
+ images.put("action.s​nooze-critic", "Snooze Critic");
+ images.put("action.s​ystem-information", "System Information");
+ }
+
+ static {
+ images.put("button.broom", "Broom");
+ images.put("button.n​ew-actionstate", "ActionState");
+ images.put("button.new-actor", "Actor");
+ images.put("button.n​ew-aggregation", "Aggregation");
+ images.put("button.n​ew-association", "Association");
+ images.put("button.n​ew-associationclass"​, "AssociationClass");
+ images.put("button.n​ew-association-end",​ "AssociationEnd");
+ images.put("button.n​ew-associationrole",​ "AssociationRole");
+ images.put("button.n​ew-attribute", "New Attribute");
+ images.put("button.n​ew-callaction", "CallAction");
+ images.put("button.n​ew-callstate", "CallState");
+ images.put("button.new-choice", "Choice");
+ images.put("button.new-class", "Class");
+ images.put("button.n​ew-classifierrole", "ClassifierRole");
+ images.put("button.n​ew-commentlink", "CommentLink");
+ images.put("button.n​ew-component", "Component");
+ images.put("button.n​ew-componentinstance​", "ComponentInstance");
+ images.put("button.n​ew-compositestate", "CompositeState");
+ images.put("button.n​ew-composition", "Composition");
+ images.put("button.n​ew-createaction", "CreateAction");
+ images.put("button.n​ew-datatype", "DataType");
+ images.put("button.n​ew-deephistory", "DeepHistory");
+ images.put("button.n​ew-dependency", "Dependency");
+ images.put("button.n​ew-destroyaction", "DestroyAction");
+ images.put("button.n​ew-enumeration", "Enumeration");
+ images.put("button.n​ew-enumeration-liter​al", "EnumerationLiteral");
+ images.put("button.n​ew-extension-point",​ "New Extension Point");
+ images.put("button.new-extend", "Extend");
+ images.put("button.n​ew-exception", "Exception");
+ }
+
+ static {
+ images.put("button.n​ew-finalstate", "FinalState");
+ images.put("button.new-fork", "Fork");
+ images.put("button.n​ew-generalization", "Generalization");
+ images.put("button.n​ew-include", "Include");
+ images.put("button.n​ew-initial", "Initial");
+ }
+
+ static {
+ images.put("button.n​ew-inner-class", "Inner Class");
+ images.put("button.n​ew-interface", "Interface");
+ images.put("button.new-join", "Join");
+ images.put("button.n​ew-junction", "Junction");
+ images.put("button.new-link", "Link");
+ images.put("button.new-node", "Node");
+ images.put("button.n​ew-nodeinstance", "NodeInstance");
+ images.put("button.new-object", "Object");
+ images.put("button.n​ew-objectflowstate",​ "ObjectFlowState");
+ }
+
+ static {
+ images.put("button.n​ew-operation", "New Operation");
+ images.put("button.n​ew-package", "Package");
+ images.put("button.n​ew-parameter", "New Parameter");
+ images.put("button.n​ew-partition", "Partition");
+ images.put("button.n​ew-permission", "Permission");
+ images.put("button.n​ew-raised-signal", "New Raised Signal");
+ images.put("button.n​ew-reception", "New Reception");
+ images.put("button.n​ew-realization", "Realization");
+ images.put("button.n​ew-returnaction", "ReturnAction");
+ images.put("button.n​ew-sendaction", "SendAction");
+ images.put("button.n​ew-shallowhistory", "ShallowHistory");
+ images.put("button.new-signal", "Signal");
+ images.put("button.n​ew-simplestate", "SimpleState");
+ images.put("button.n​ew-stereotype", "Stereotype");
+ images.put("button.n​ew-stubstate", "StubState");
+ images.put("button.n​ew-subactivitystate"​, "SubactivityState");
+ images.put("button.n​ew-submachinestate",​ "SubmachineState");
+ images.put("button.n​ew-synchstate", "SynchState");
+ images.put("button.n​ew-tagdefinition", "TagDefinition");
+ images.put("button.n​ew-transition", "Transition");
+ images.put("button.n​ew-uniaggregation", "UniAggregation");
+ images.put("button.n​ew-uniassociation", "UniAssociation");
+ images.put("button.n​ew-unicomposition", "UniComposition");
+ images.put("button.new-usage", "Usage");
+ images.put("button.n​ew-usecase", "UseCase");
+ }
+
+ static {
+ images.put("button.select", "Select");
+ images.put("button.s​equence-expand", "SequenceExpand");
+ images.put("button.s​equence-contract", "SequenceContract");
+ }
+
+ /**
+ * Convert the key to the image file name.
+ *
+ * @param name the new i18n key
+ * @return the file name (base part only).
+ */
+ public static String getImageBinding(String name) {
+ String found = images.get(name);
+ if (found == null) {
+ return name;
+ }
+ return found;
+ }
+
+ /**
+ * Find the path to a given icon and return it as a URL.
+ *
+ * @param name base name of the icon to search for
+ * @param loader class loader to use or null to use the default class loader
+ * @return the URL where the icon was found
+ */
+ public static URL lookupIconUrl(String name, ClassLoader loader) {
+ return ResourceLoader.looku​pIconUrl(name, loader);
+ }
+
+ /**
+ * Find the path to a given icon and return it as a URL.
+ *
+ * @param name base name of the icon to search for
+ * @return the URL where the icon was found
+ */
+ public static URL lookupIconUrl(String name) {
+ return lookupIconUrl(name, null);
+ }
+}

Added: trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/pa​ckage.html
Url: http://argouml-spl.t​igris.org/source/bro​wse/argouml-spl/trun​k/src/argouml-app/sr​c/org/argouml/applic​ation/helpers/packag​e.html?view=markup​&pathrev=36
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/argouml-ap​p/src/org/argouml/ap​plication/helpers/pa​ckage.html 2010-04-03 12:13:31-0700
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<title>org.ar​gouml.application.he​lpers package</title>
+<!--
+ Copyright (c) 1996-2007 The Regents of the University of California. All
+ Rights Reserved. Permission to use, copy, modify, and distribute this
+ software and its documentation without fee, and without a written
+ agreement is hereby granted, provided that the above copyright notice
+ and this paragraph appear in all copies. This software program and
+ documentation are copyrighted by The Regents of the University of
+ California. The software program and documentation are supplied "AS
+ IS", without any accompanying services from The Regents. The Regents
+ does not warrant that the operation of the program will be
+ uninterrupted or error-free. The end-user understands that the program
+ was developed for research purposes and is advised not to rely
+ exclusively on the program for any reason. IN NO EVENT SHALL THE
+ UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+ SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+ ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+ THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+ CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+-->
+</head>
+<body bgcolor="white">
+
+ Provides "helper" classes that provide
+ basic functionality for the application.
+
+<h2>Package Specification</h2>
+
+
+<h2>Related Documentation </h2>
+
+ (none)
+
+ @since ARGO0.9.4
+
+</body>
+</html>
+
+

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r36 - trunk/src/argouml-app/src/org/argouml/application/helpers marcusvnac Marcus Vinícius de Ávila Couto 2010-04-03 12:13:32 PDT
Messages per page: