svn commit: r13771 - trunk/src_new/org/argouml/uml/ui/TabStyle.java
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2007-11-15 14:13:46-0800
New Revision: 13771
Modified:
trunk/src_new/org/argouml/uml/ui/TabStyle.java
Log:
Simplify class loading code
Modified: trunk/src_new/org/argouml/uml/ui/TabStyle.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/TabStyle.java?view=diff&rev=13771&p1=trunk/src_new/org/argouml/uml/ui/TabStyle.java&p2=trunk/src_new/org/argouml/uml/ui/TabStyle.java&r1=13770&r2=13771
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/TabStyle.java (original)
+++ trunk/src_new/org/argouml/uml/ui/TabStyle.java 2007-11-15 14:13:46-0800
@@ -305,12 +305,14 @@
/**
* Get the class for the required stylepanel.
*
- * @param targetClass the class of the current seelcted target.
+ * @param targetClass the class of the current selected target.
* @return the panel class for the class given or
* null if none available.
*/
public Class panelClassFor(Class targetClass) {
- if (targetClass == null) return null;
+ if (targetClass == null) {
+ return null;
+ }
StringNamespace classNs = (StringNamespace) StringNamespace
.parse(targetClass);
@@ -325,31 +327,31 @@
classNs.popNamespaceElement();
- Class cls;
-
- for (int i = 0; i < stylePanelNames.length; i++) {
- try {
- cls = Class.forName(classNs.toString() + "."
- + stylePanelNames[i] + targetClassElement);
- return cls;
- } catch (ClassNotFoundException ignore) {
- LOG.debug("ClassNotFoundException. Could not find class:"
- + classNs.toString() + "." + stylePanelNames[i]
- + targetClassElement);
- }
- try {
- cls = Class.forName(baseNs.toString() + "."
- + stylePanelNames[i] + targetClassElement);
- return cls;
- } catch (ClassNotFoundException ignore) {
- LOG.debug("ClassNotFoundException. Could not find class:"
- + classNs.toString() + "." + stylePanelNames[i]
- + targetClassElement);
+ String[] bases = new String[] { classNs.toString(), baseNs.toString() };
+ for (String stylePanelName : stylePanelNames) {
+ for (String baseName : bases) {
+ String name = baseName + "." + stylePanelName
+ + targetClassElement;
+ Class cls = loadClass(name);
+ if (cls != null) {
+ return cls;
+ }
}
}
return null;
}
+ private Class loadClass(String name) {
+ try {
+ Class cls = Class.forName(name);
+ return cls;
+ } catch (ClassNotFoundException ignore) {
+ LOG.debug("ClassNotFoundException. Could not find class:"
+ + name);
+ }
+ return null;
+ }
+
/**
* @return the style panel names
*/