KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > xmleditor > XmlEditorPanel


1 package com.calipso.xmleditor;
2
3 import org.w3c.dom.Node JavaDoc;
4 import org.w3c.dom.NodeList JavaDoc;
5 import org.w3c.dom.NamedNodeMap JavaDoc;
6
7 import javax.swing.*;
8 import javax.swing.tree.*;
9 import javax.swing.event.TreeSelectionListener JavaDoc;
10 import javax.swing.event.TreeSelectionEvent JavaDoc;
11 import java.util.*;
12 import java.awt.*;
13
14 /**
15  *
16  * User: soliveri
17  * Date: 26-sep-2003
18  * Time: 14:17:16
19  *
20  */

21
22 public class XmlEditorPanel extends JPanel implements TreeSelectionListener JavaDoc {
23
24   private String JavaDoc name;
25   private JPanel pnlMain;
26   private CardLayout cardLayout;
27   private JTree tree;
28   private DefaultTreeModel model;
29   private XmlEditorTreeModelNode currentNode;
30   private XmlEditorTreeModelNode lastNode;
31   private HashMap subPanels;
32   private XmlEditorTreeDefinitionNode nodeDefinition;
33   private Vector treeNodesHistory;
34   private boolean isBlocked;
35   private Node JavaDoc domRoot;
36   private boolean isJustXml;
37   private boolean isOnlyXsd = false;
38
39   public void setOnlyXsd(boolean onlyXsd) {
40     this.isOnlyXsd = onlyXsd;
41   }
42
43   /**
44    * Crea un nuevo panel en base a una definicion
45    * @param nodeDefinition
46    * @throws XmlEditorException
47    */

48   public XmlEditorPanel(XmlEditorTreeDefinitionNode nodeDefinition) throws XmlEditorException{
49     name = nodeDefinition.getValue();
50     isBlocked = false;
51     isJustXml = false;
52     initialize(nodeDefinition);
53   }
54
55   /**
56    * Crea un nuevo panel con un modelo y un nodo Root
57    * @param model
58    * @param domRoot
59    */

60   public XmlEditorPanel(DefaultTreeModel model, Node JavaDoc domRoot) {
61     this.model = model;
62     isJustXml = true;
63     this.domRoot = domRoot;
64     initialize();
65   }
66
67   /**
68    * Inicializa los paneles. Inicializa el panel con CardLayout
69    */

70   private void initialize() {
71     createCardLayoutPanels();
72     setLayout(new BorderLayout());
73     JSplitPane splitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createCenterPanel(), createSouthPanel());
74     splitPanel.setDividerLocation(200);
75     splitPanel.setDividerSize(2);
76     add(splitPanel, BorderLayout.CENTER);
77   }
78
79   /**
80    * Crea el panel con CardLayout, genera los subpaneles y llena los datos.
81    */

82   private void createCardLayoutPanels() {
83     cardLayout = new CardLayout();
84     pnlMain = new JPanel(cardLayout);
85     HashMap subPanels = new HashMap();
86     getLeafsFrom(domRoot, subPanels);
87     Iterator iterator = subPanels.keySet().iterator();
88     while(iterator.hasNext()) {
89       String JavaDoc currentKey = iterator.next().toString();
90       pnlMain.add(((JPanel)subPanels.get(currentKey)), currentKey);
91     }
92     this.subPanels = (HashMap) subPanels.clone();
93   }
94
95   /**
96    * Inicia la creacion recursiva de los subpaneles, en base a los hijos de los nodos.
97    * @param node
98    * @param subPanels
99    */

100   private void getLeafsFrom(Node JavaDoc node, HashMap subPanels) {
101     if(node.getAttributes().getLength() > 0) {
102       subPanels.put(node.getNodeName(), new XmlEditorSubPanel(getAttrsNamesFrom(node)));
103       getSubPanelsFrom(node.getChildNodes(), subPanels);
104     } else {
105       getSubPanelsFrom(node.getChildNodes(), subPanels);
106     }
107   }
108
109   /**
110    * Obtiene los subpaneles en base a una lista de nodos hijos. Se llama recursivamente con los hijos de cada nodo visitado
111    * @param children
112    * @param subPanels
113    */

114   private void getSubPanelsFrom(NodeList JavaDoc children, HashMap subPanels) {
115     for(int i = 0 ; i < children.getLength(); i++) {
116       Node JavaDoc node = children.item(i);
117       if(node.getNodeType() == Node.ELEMENT_NODE) {
118         if(node.getAttributes().getLength() > 0) {
119           subPanels.put(node.getNodeName(), new XmlEditorSubPanel(getAttrsNamesFrom(node)));
120         } else {
121           subPanels.put(node.getNodeName(), new XmlEditorSubPanel(new Vector()));
122           getSubPanelsFrom(node.getChildNodes(), subPanels);
123         }
124       }
125     }
126   }
127
128   /**
129    * Obtiene los nombres de los atributos de un nodo.
130    * @param node
131    * @return
132    */

133   private Vector getAttrsNamesFrom(Node JavaDoc node) {
134     Vector vector = new Vector();
135     NamedNodeMap JavaDoc attrs = node.getAttributes();
136     for(int i = 0 ; i < attrs.getLength() ; i++) {
137       Node JavaDoc attr = attrs.item(i);
138       vector.add(attr.getNodeName());
139     }
140     return vector;
141   }
142
143   /**
144    * Inicializa los paneles, pero basandose en una definicion.
145    * @param nodeDefinition
146    * @throws XmlEditorException
147    */

148   private void initialize(XmlEditorTreeDefinitionNode nodeDefinition) throws XmlEditorException{
149     this.nodeDefinition = nodeDefinition;
150     model = getModelFrom(nodeDefinition);
151     createCardLayoutPanels(nodeDefinition);
152     setLayout(new BorderLayout());
153     JSplitPane splitPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createCenterPanel(), createSouthPanel());
154     splitPanel.setDividerLocation(200);
155     splitPanel.setDividerSize(2);
156     add(splitPanel, BorderLayout.CENTER);
157   }
158
159   /**
160    * Obtiene un modelo de arbol en base a un definicion.
161    * @param nodeDefinition
162    * @return
163    */

164   private DefaultTreeModel getModelFrom(XmlEditorTreeDefinitionNode nodeDefinition) {
165     XmlEditorTreeModelNode node = new XmlEditorTreeModelNode(nodeDefinition.getValue());
166     fillTreeModel(nodeDefinition, node);
167     return new DefaultTreeModel(node);
168   }
169
170   /**
171    * Llena un nodo en base a una definicion de nodo. Itera los subnodos llamandose recursivamente para cada uno.
172    * @param nodeDefinition
173    * @param node
174    */

175   private void fillTreeModel(XmlEditorTreeDefinitionNode nodeDefinition, XmlEditorTreeModelNode node) {
176     Iterator iterator = nodeDefinition.getSubnodes().keySet().iterator();
177     while(iterator.hasNext()) {
178       XmlEditorTreeDefinitionNode definition = (XmlEditorTreeDefinitionNode) nodeDefinition.getSubnodes().get(iterator.next());
179       XmlEditorTreeModelNode newNode = new XmlEditorTreeModelNode(definition.getValue());
180       node.add(newNode);
181       fillTreeModel(definition, newNode);
182     }
183   }
184
185   private JPanel createSouthPanel() {
186     JPanel pnlSouth = new JPanel(new BorderLayout());
187     JScrollPane pane = new JScrollPane(pnlMain);
188     pnlSouth.add(pane, BorderLayout.CENTER);
189     return pnlSouth;
190   }
191
192   /**
193    * Crea los paneles CardLayout cuando hay una definicion.
194    * @param nodeDefinition
195    * @throws XmlEditorException
196    */

197   private void createCardLayoutPanels(XmlEditorTreeDefinitionNode nodeDefinition) throws XmlEditorException{
198     cardLayout = new CardLayout();
199     pnlMain = new JPanel(cardLayout);
200     HashMap subPanels = new HashMap();
201     getLeafsFrom(nodeDefinition, subPanels);
202     Iterator iterator = subPanels.keySet().iterator();
203     while(iterator.hasNext()) {
204       String JavaDoc currentKey = iterator.next().toString();
205       pnlMain.add(((JPanel)subPanels.get(currentKey)), currentKey);
206     }
207     this.subPanels = (HashMap) subPanels.clone();
208   }
209
210   /**
211    * Obtiene los paneles, en base a una definicion.
212    * @param nodeDefinition
213    * @param subPanels
214    * @throws XmlEditorException
215    */

216   private void getLeafsFrom(XmlEditorTreeDefinitionNode nodeDefinition, HashMap subPanels) throws XmlEditorException{
217     if(nodeDefinition.getItemsKeys().size() > 0) {
218       subPanels.put(nodeDefinition.getValue(), new XmlEditorSubPanel(nodeDefinition.getItemsKeys(), nodeDefinition.getItems()));
219       getSubPanelsFrom(nodeDefinition.getSubnodes(), subPanels);
220     } else {
221       getSubPanelsFrom(nodeDefinition.getSubnodes(), subPanels);
222     }
223   }
224
225   private void getSubPanelsFrom(Map JavaDoc nodes, HashMap subPanels) throws XmlEditorException{
226     Iterator iterator = nodes.keySet().iterator();
227     while(iterator.hasNext()) {
228       XmlEditorTreeDefinitionNode node = (XmlEditorTreeDefinitionNode) nodes.get(iterator.next().toString());
229       if(node.getItemsKeys().size() > 0) {
230         subPanels.put(node.getValue(), new XmlEditorSubPanel(node.getItemsKeys(), node.getItems()));
231         Map JavaDoc newNodes = node.getSubnodes();
232         getSubPanelsFrom(newNodes, subPanels);
233       } else {
234         subPanels.put(node.getValue(), new XmlEditorSubPanel(new Vector(), new HashMap()));
235         Map JavaDoc newNodes = node.getSubnodes();
236         getSubPanelsFrom(newNodes, subPanels);
237       }
238     }
239   }
240
241   private JPanel createCenterPanel() {
242     JPanel centerPanel = new JPanel(new BorderLayout());
243     tree = new JTree(model);
244     tree.addTreeSelectionListener(this);
245     JScrollPane scrollTree = new JScrollPane(tree);
246     centerPanel.add(scrollTree, BorderLayout.CENTER);
247     return centerPanel;
248   }
249
250   public void valueChanged(TreeSelectionEvent JavaDoc e) {
251     currentNode = (XmlEditorTreeModelNode) (e.getPath().getLastPathComponent());
252     valueChanged();
253   }
254
255   public void valueChanged(){
256     getTreeNodesHistory().add(currentNode);
257     if(getTreeNodesHistory().size() > 1) {
258       lastNode = (XmlEditorTreeModelNode) getTreeNodesHistory().elementAt(getTreeNodesHistory().size() - 2);
259     }
260     if(/*currentNode.getAttributes().size() != 0 &&*/ currentNode.isLeaf()) {
261       leafHasBeenSelected();
262     } else if(!currentNode.isLeaf() && currentNode.getChildCount() > 0) {
263       folderHasBeenSelected();
264     } else {
265       cardLayout.show(pnlMain, currentNode.toString());
266     }
267
268   }
269
270   /**
271    * Realiza las acciones necesarias a realizar cuando se ha seleccionado una carpeta
272    */

273   private void folderHasBeenSelected() {
274     if(!isJustXml) {
275       if(lastNode != currentNode) {
276         verifyModelNodeChanges(false);
277       }
278       if(!isBlocked) {
279         if(currentNode.getAttributes()!= null //((XmlEditorSubPanel) subPanels.get(currentNode.toString())).getInputComponents().isEmpty()
280
&& currentNode != getTreeModel().getRoot()){
281           cardLayout.show(pnlMain, currentNode.toString());
282         }//else{
283
//((XmlEditorSubPanel) subPanels.get(currentNode.toString())).eraseInputFields();
284
//}
285
}
286     } else {
287       verifyModelNodeChanges(false);
288       ((XmlEditorSubPanel) subPanels.get(currentNode.toString())).eraseInputFields();
289       cardLayout.show(pnlMain, currentNode.toString());
290     }
291   }
292
293   /**
294    * Realiza las acciones necesarias a realizar cuando se ha seleccionado una hoja
295    */

296   private void leafHasBeenSelected() {
297     if(!isJustXml) {
298       if(lastNode != currentNode) {
299         verifyModelNodeChanges(true);
300       }
301       if(!isBlocked) {
302         XmlEditorTreeModelNode parent = (XmlEditorTreeModelNode) currentNode.getParent();
303         XmlEditorSubPanel subPanel = null;
304         if(parent!=null){
305           subPanel = (XmlEditorSubPanel) subPanels.get(parent.toString());
306           if(subPanel!=null){
307             if(!isOnlyXsd){
308               subPanel.fillFrom(currentNode);
309               cardLayout.show(pnlMain, parent.toString());
310             }
311             cardLayout.show(pnlMain, currentNode.toString());
312           }
313         }
314       }
315     } else {
316       verifyModelNodeChanges(true);
317       XmlEditorTreeModelNode parent = (XmlEditorTreeModelNode) currentNode.getParent();
318       if(parent!=null){
319         XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(parent.toString());
320         subPanel.fillFrom(currentNode);
321         cardLayout.show(pnlMain, parent.toString());
322       }
323     }
324   }
325
326   /**
327    * Verifica que los cambios realizados para un nodo sean correctos.
328    * @param isLeaf
329    */

330   private void verifyModelNodeChanges(boolean isLeaf) {
331     if(getTreeNodesHistory().size() > 1) {
332       if(isLeaf) {
333         verifyModelNodeChangesIfLeaf();
334       } else {
335         verifyModelNodeChangesIfFolder();
336       }
337     }
338   }
339
340   /**
341    * Verifica las modificaciones si se selecciono una carpeta.
342    * Realiza el update del modelo.
343    */

344   private void verifyModelNodeChangesIfFolder() {
345     if(currentNode == lastNode.getParent() && lastNode.isLeaf()) {
346       XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(currentNode.toString());
347       updateModelNodeFrom(subPanel, lastNode);
348     } else if(currentNode != lastNode.getParent() && lastNode.isLeaf()) {
349       XmlEditorTreeModelNode parent = (XmlEditorTreeModelNode) lastNode.getParent();
350       XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(parent.toString());
351       updateModelNodeFrom(subPanel, lastNode);
352     }
353   }
354
355   /**
356    * Verifica las modificaciones si se selecciono una hoja.
357    * Realiza el update del modelo.
358    */

359   private void verifyModelNodeChangesIfLeaf() {
360     if((lastNode.getParent() == currentNode.getParent()) && lastNode.isLeaf()) {
361       XmlEditorTreeModelNode parent = (XmlEditorTreeModelNode) lastNode.getParent();
362       if(parent!=null){
363         XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(parent.toString());
364         updateModelNodeFrom(subPanel, lastNode);
365       }
366     } else if(lastNode.getParent() != null) {
367       if(lastNode.getParent() != currentNode.getParent() && lastNode.isLeaf()) {
368         XmlEditorTreeModelNode parent = (XmlEditorTreeModelNode) lastNode.getParent();
369         XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(parent.toString());
370         updateModelNodeFrom(subPanel, lastNode);
371       }
372     }
373   }
374
375   /**
376    * Verifica que no halla ningun error de datos. En ese caso actualiza los datos. Sino, bloquea el modelo.
377    * @param subPanel
378    * @param node
379    */

380   private void updateModelNodeFrom(XmlEditorSubPanel subPanel, XmlEditorTreeModelNode node) {
381     String JavaDoc id = "";
382     if(node.getId() != null){
383       id = node.getId();
384     }
385     if(!isJustXml && !isOnlyXsd) {
386       String JavaDoc wrongElement = validateFrom(subPanel, (XmlEditorTreeModelNode) node/*.getParent()*/);
387       if(wrongElement != null) {
388         JOptionPane.showMessageDialog(this, "Falta completar el campo " + wrongElement);
389         isBlocked = true;
390         getTreeNodesHistory().removeElementAt(getTreeNodesHistory().size() - 1);
391         tree.setSelectionPath(new TreePath(node));
392       } else {
393         isBlocked = false;
394         node.updateAttributesFrom(subPanel);
395       }
396     } else if(!isOnlyXsd){
397       node.updateAttributesFrom(subPanel);
398     }
399     String JavaDoc newId = "";
400     if(node.getId()!=null){
401       newId = node.getId();
402     }
403     if(!id.equalsIgnoreCase(newId)){
404       node.setUserObject(newId);
405       this.invalidate();
406     }
407   }
408
409   /**
410    * Obtiene el root para una definicion.
411    * @param children
412    * @return
413    */

414   private XmlEditorTreeModelNode getRootSpecs(Enumeration children) {
415     while(children.hasMoreElements()) {
416       XmlEditorTreeModelNode modelNode = (XmlEditorTreeModelNode) children.nextElement();
417       if(modelNode.isLeaf()) {
418         return modelNode;
419       }
420     }
421     return null;
422   }
423
424   /**
425    * Borra un nodo del arbol.
426    */

427   public void deleteNode() {
428     if(!isJustXml){
429       if(currentNode == getRootSpecs(((XmlEditorTreeModelNode)model.getRoot()).children()) || currentNode == model.getRoot()){
430         JOptionPane.showMessageDialog(this, "Debe existir una instancia de " + ((XmlEditorTreeModelNode)model.getRoot()).getUserObject());
431         return;
432       }
433     }
434     DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
435     TreeNode parent = currentNode.getParent();
436     if(parent!=null){
437       ((XmlEditorSubPanel) subPanels.get(parent.toString())).eraseInputFields();
438       model.removeNodeFromParent(currentNode);
439     }
440     //updateModelNodeFrom(, currentNode);
441
}
442
443   /**
444    * Agrega un nodo hijo al nodo seleccionado, en base a sus atributos.
445    */

446   public void addNode() {
447     if(!isJustXml) {
448       if(currentNode != getRootSpecs(((XmlEditorTreeModelNode)model.getRoot()).children()) && currentNode != model.getRoot()){
449       //if(getRootSpecs(((XmlEditorTreeModelNode)model.getRoot()).children()) == null) {
450
//XmlEditorSubPanel subPanel = (XmlEditorSubPanel) subPanels.get(currentNode.toString());
451
if(subPanels.get(currentNode.toString())==null){
452           currentNode = (XmlEditorTreeModelNode)currentNode.getParent();
453         }
454         XmlEditorSubPanel subPanel = getSubPanelFor(currentNode);
455         if(subPanel!=null){
456           String JavaDoc wrongElement = validateFrom(subPanel, currentNode);
457           if(wrongElement != null) {
458             JOptionPane.showMessageDialog(this, "Falta completar el campo " + wrongElement);
459           } else {
460             updateTreeModel(getId(currentNode), subPanel);
461           }
462         }
463       } else {
464         JOptionPane.showMessageDialog(this, "Solo debe existir una instancia de " + ((XmlEditorTreeModelNode)model.getRoot()).getUserObject());
465       }
466     } else {
467       XmlEditorSubPanel subPanel = getSubPanelFor(currentNode);
468       if(subPanel!=null){
469         updateTreeModel(getId(subPanel), subPanel);
470       }
471     }
472   }
473
474   private String JavaDoc getId(XmlEditorTreeModelNode node) {
475     if(subPanels.get(node.toString())!=null){
476       return node.toString();
477     }else{
478       return node.getParent().toString();
479     }
480   }
481
482   /**
483    * Obtiene el subpanel que corresponde a un nodo.
484    * @param node
485    * @return
486    */

487   private XmlEditorSubPanel getSubPanelFor(XmlEditorTreeModelNode node) {
488     XmlEditorSubPanel subPanel = (XmlEditorSubPanel)subPanels.get(node.toString());
489     if(subPanel==null){
490       subPanel = (XmlEditorSubPanel)subPanels.get(node.getParent().toString());
491     }
492     return subPanel;
493   }
494
495   private String JavaDoc validateFrom(XmlEditorSubPanel subPanel, XmlEditorTreeModelNode modelNode) {
496     //XmlEditorTreeDefinitionNode definition = getNodeDefinitionFrom(nodeDefinition, modelNode);
497
//return XmlEditorSubPanelValidator.validateFrom(subPanel, definition);
498
XmlEditorTreeModelNode auxModelNode;
499     if(subPanels.get(modelNode.toString())==null){
500       auxModelNode = (XmlEditorTreeModelNode)modelNode.getParent();
501     }else{
502       auxModelNode = modelNode;
503     }
504     XmlEditorTreeDefinitionNode definition = getNodeDefinitionFrom(nodeDefinition, auxModelNode);
505     if(definition!=null && !modelNode.toString().equalsIgnoreCase(definition.getValue())){
506       return XmlEditorSubPanelValidator.validateFrom(subPanel, definition);
507     }
508     return null;
509   }
510
511   private String JavaDoc getId(XmlEditorSubPanel subPanel) {
512     if(subPanel.getInputComponents()!=null && !subPanel.getInputComponents().isEmpty()){
513       return ((JTextField)subPanel.getInputComponents().elementAt(0)).getText();
514     }else{
515       return "";
516     }
517   }
518
519   /**
520    * Realiza el update del modelo despues de agregar un nodo. Crea el subpanel y limpia sus atributos.
521    * @param nodeName
522    * @param subPanel
523    */

524   private void updateTreeModel(String JavaDoc nodeName, XmlEditorSubPanel subPanel) {
525     XmlEditorTreeModelNode modelNode = new XmlEditorTreeModelNode("New " + nodeName);
526     modelNode.addAttributesFrom(subPanel);
527     ((XmlEditorSubPanel) subPanels.get(getId(currentNode))).eraseInputFields();
528     DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
529     model.insertNodeInto(modelNode, currentNode, 0);
530     int [] selRows = tree.getSelectionRows();
531     for(int i = 0 ; i < selRows.length ; i++) {
532       tree.expandRow(selRows [i]);
533     }
534   }
535
536   /**
537    * Obtiene la definicion para un nodo, en base a una definicion (si no es la correspondiente buscara recursivamente entre sus hijos)
538    * @param definition
539    * @param modelNode
540    * @return
541    */

542   private XmlEditorTreeDefinitionNode getNodeDefinitionFrom(XmlEditorTreeDefinitionNode definition, XmlEditorTreeModelNode modelNode) {
543     if(definition.getValue().equals(modelNode.toString())) {
544       return definition;
545     } else {
546       return getNodeDefinitionFrom(definition.getSubnodes(), false, modelNode);
547     }
548   }
549
550   private XmlEditorTreeDefinitionNode getNodeDefinitionFrom(Map JavaDoc subNodes, boolean found, XmlEditorTreeModelNode modelNode) {
551     XmlEditorTreeDefinitionNode returnVal = null;
552     Iterator iterator = subNodes.keySet().iterator();
553     while(iterator.hasNext() && !found) {
554       XmlEditorTreeDefinitionNode definition = (XmlEditorTreeDefinitionNode) subNodes.get(iterator.next().toString());
555       if(definition.getValue().equals(modelNode.toString())) {
556         return definition;
557       } else {
558         returnVal = getNodeDefinitionFrom(definition.getSubnodes(), found, modelNode);
559         if(returnVal != null) {
560           found = true;
561         }
562       }
563     }
564     return returnVal;
565   }
566
567   public DefaultTreeModel getTreeModel() {
568       return model;
569   }
570
571   public String JavaDoc getName() {
572     return name;
573   }
574
575   public Map JavaDoc getSubPanels() {
576     return subPanels;
577   }
578
579   private Vector getTreeNodesHistory() {
580     if(treeNodesHistory == null) {
581       treeNodesHistory = new Vector();
582     }
583     return treeNodesHistory;
584   }
585
586   public JTree getTree() {
587     return tree;
588   }
589
590   public XmlEditorTreeDefinitionNode getNodeDefinition() {
591     return nodeDefinition;
592   }
593
594   /**
595    * Colapsa todos los nodos del arbol recursivamente, dejando solo desplegada la raiz.
596    */

597   public void collapseAllNodes() {
598     int j = tree.getRowCount();
599     for(int i=0; j==tree.getRowCount() && i<tree.getRowCount(); i++){
600       tree.collapseRow(tree.getRowCount()-i);
601     }
602     if(j!=tree.getRowCount()){
603       collapseAllNodes();
604     }
605   }
606
607   private XmlEditorTreeModelNode getRootNode() {
608     XmlEditorTreeModelNode node = currentNode;
609     while(node.getParent() != null){
610       node = (XmlEditorTreeModelNode)node.getParent();
611     }
612     return node;
613   }
614
615 }
616
Popular Tags