001: // RemoteFrameWrapperNode.java
002: // $Id: RemoteFrameWrapperNode.java,v 1.9 2000/08/16 21:37:30 ylafon Exp $
003: // (c) COPYRIGHT MIT and INRIA, 1998.
004: // Please first read the full copyright statement in file COPYRIGHT.html
005:
006: package org.w3c.jigadmin.editors;
007:
008: import java.util.Vector;
009:
010: import org.w3c.jigadmin.RemoteResourceWrapper;
011: import org.w3c.jigadmin.gui.Message;
012:
013: import org.w3c.jigsaw.admin.RemoteResource;
014: import org.w3c.jigsaw.admin.RemoteAccessException;
015:
016: /**
017: * The TreeNode for Frames
018: * @version $Revision: 1.9 $
019: * @author Benoît Mahé (bmahe@w3.org)
020: */
021: public class RemoteFrameWrapperNode extends RemoteResourceWrapperNode {
022:
023: /**
024: * Get the pretty ResourceFrame name
025: * @param frame The ResourceFrame
026: * @param name The ResourceFrame name
027: * @exception RemoteAccessException if a remote access error occurs.
028: */
029: protected static String getFrameName(RemoteResource frame,
030: String name) throws RemoteAccessException {
031: String className = frame.getClassHierarchy()[0];
032: String shortName = className.substring(className
033: .lastIndexOf('.') + 1);
034: return shortName.concat(" (").concat(name).concat(")");
035: }
036:
037: /**
038: * Get the pretty ResourceFrame name
039: * @param frame The ResourceFrame
040: * @exception RemoteAccessException if a remote access error occurs.
041: */
042: protected static String getFrameName(RemoteResource frame)
043: throws RemoteAccessException {
044: String className = frame.getClassHierarchy()[0];
045: String shortName = className.substring(className
046: .lastIndexOf('.') + 1);
047: String frameName = (String) frame.getValue("identifier");
048: return shortName.concat(" (").concat(frameName).concat(")");
049: }
050:
051: /**
052: * Load the children of this node.
053: */
054: protected synchronized void loadChildren() {
055: RemoteResource frames[] = null;
056:
057: children = new Vector();
058:
059: try {
060: if (rrw.getResource().isFramed())
061: frames = rrw.getResource().getFrames();
062: } catch (RemoteAccessException ex) {
063: Message.showErrorMessage(rrw, ex);
064: }
065: if (frames == null)
066: return;
067: for (int i = 0; i < frames.length; i++) {
068: RemoteResourceWrapper rrwf = new RemoteResourceWrapper(rrw,
069: frames[i]);
070: try {
071: RemoteFrameWrapperNode node = new RemoteFrameWrapperNode(
072: this , rrwf, getFrameName(frames[i]));
073: children.add(node);
074: } catch (RemoteAccessException ex) {
075: Message.showErrorMessage(rrw, ex);
076: }
077: }
078: }
079:
080: /**
081: * Returns true if this node is allowed to have children.
082: * @return true if this node allows children, else false
083: */
084: public boolean getAllowsChildren() {
085: try {
086: return (rrw.getResource().isFramed());
087: } catch (RemoteAccessException ex) {
088: Message.showErrorMessage(rrw, ex);
089: }
090: return false;
091: }
092:
093: /**
094: * Constructor
095: * @param parent The parent node
096: * @param rrw The associated RemoteResourceWrapper
097: * @param name The name of this node
098: */
099: protected RemoteFrameWrapperNode(RemoteResourceWrapperNode parent,
100: RemoteResourceWrapper rrw, String name) {
101: super (parent, rrw, name);
102: }
103:
104: /**
105: * Constructor
106: * @param parent The parent node
107: * @param rrw The associated RemoteResourceWrapper
108: */
109: protected RemoteFrameWrapperNode(RemoteResourceWrapperNode parent,
110: RemoteResourceWrapper rrw) throws RemoteAccessException {
111: super (parent, rrw, getFrameName(rrw.getResource()));
112: }
113:
114: /**
115: * Constructor
116: * @param rrw The associated RemoteResourceWrapper
117: * @param name The name of this node
118: */
119: protected RemoteFrameWrapperNode(RemoteResourceWrapper rrw,
120: String name) {
121: super(rrw, name);
122: }
123:
124: }
|