01: // AttributeEditorFactory.java
02: // $Id: AttributeEditorFactory.java,v 1.9 2000/08/16 21:37:26 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigadm.editors;
07:
08: import java.util.Properties;
09: import org.w3c.jigsaw.admin.RemoteResource;
10: import org.w3c.tools.resources.Attribute;
11: import org.w3c.jigadm.PropertyManager;
12: import org.w3c.jigadm.RemoteResourceWrapper;
13:
14: public class AttributeEditorFactory {
15:
16: /**
17: * Get an editor for the Attribute element of the Resource. If the editor
18: * for the specified attribute in the specified resource is not found,
19: * we try to find an editor for the same attribute in the superclasses
20: * of the resource. If it is still not found, we try to find an editor
21: * for the superclass of the attribute in the specified resource,
22: * if still not found, we iterate the process.
23: * @param resource the RemoteResource which contains informations about
24: * the server resource.
25: * @param attribute the attribute to be edited
26: * @return an AttributeEditor, or <strong>null</strong> if none found
27: */
28:
29: public static synchronized AttributeEditor getEditor(
30: RemoteResourceWrapper rrw, Attribute attribute) {
31: RemoteResource resource = rrw.getResource();
32:
33: PropertyManager pm = PropertyManager.getPropertyManager();
34: Properties props = pm.getAttributeProperties(rrw, attribute);
35: String className = (String) props.get("class");
36: if (className == null) {
37: System.out.println("can't edit " + attribute.getName()
38: + " !");
39: return null;
40: }
41: try {
42: Class cls = Class.forName(className);
43: return (AttributeEditor) cls.newInstance();
44: } catch (Exception ex) {
45: ex.printStackTrace();
46: }
47: return null;
48: }
49: }
|