root / trunk / extensions / extPublish / src / com / iver / cit / gvsig / publish / gui / panelServices / LayerTreeModel.java @ 8969
History | View | Annotate | Download (3.37 KB)
1 |
package com.iver.cit.gvsig.publish.gui.panelServices; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
|
5 |
import javax.swing.event.TreeModelListener; |
6 |
import javax.swing.tree.TreeModel; |
7 |
import javax.swing.tree.TreePath; |
8 |
|
9 |
import com.iver.cit.gvsig.publish.model.LayerInfo; |
10 |
import com.iver.cit.gvsig.publish.model.ServiceInfo; |
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id: LayerTreeModel.java 8969 2006-11-22 15:57:03Z jorpiell $
|
55 |
* $Log$
|
56 |
* Revision 1.1 2006-11-22 15:57:03 jorpiell
|
57 |
* Se ha ajustado el interfaz de usuario
|
58 |
*
|
59 |
* Revision 1.2 2006/11/22 12:48:21 jorpiell
|
60 |
* Subidos algunos cambios para ver las capas en forma de ?rbol
|
61 |
*
|
62 |
* Revision 1.1 2006/11/17 13:43:45 jorpiell
|
63 |
* A?adido el nuevo panel donde se muestran las capas
|
64 |
*
|
65 |
*
|
66 |
*/
|
67 |
/**
|
68 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
69 |
*/
|
70 |
public class LayerTreeModel implements TreeModel{ |
71 |
private ServiceInfo root = null; |
72 |
|
73 |
public LayerTreeModel(ServiceInfo root) {
|
74 |
super();
|
75 |
this.root = root;
|
76 |
} |
77 |
|
78 |
public Object getRoot() { |
79 |
return root;
|
80 |
} |
81 |
|
82 |
public int getChildCount(Object arg0) { |
83 |
if (arg0 instanceof ServiceInfo){ |
84 |
return ((ServiceInfo)arg0).getLayerList().size();
|
85 |
}else{
|
86 |
return ((LayerInfo)arg0).getLayerList().size();
|
87 |
} |
88 |
} |
89 |
|
90 |
public boolean isLeaf(Object arg0) { |
91 |
if (arg0 instanceof ServiceInfo){ |
92 |
if (((ServiceInfo)arg0).getLayerList().size() == 0){ |
93 |
return true; |
94 |
} |
95 |
}else{
|
96 |
if (((LayerInfo)arg0).getLayerList().size() == 0){ |
97 |
return true; |
98 |
} |
99 |
} |
100 |
return false; |
101 |
} |
102 |
|
103 |
public void addTreeModelListener(TreeModelListener arg0) { |
104 |
// TODO Auto-generated method stub
|
105 |
|
106 |
} |
107 |
|
108 |
public void removeTreeModelListener(TreeModelListener arg0) { |
109 |
// TODO Auto-generated method stub
|
110 |
|
111 |
} |
112 |
|
113 |
public Object getChild(Object arg0, int i) { |
114 |
if (arg0 instanceof ServiceInfo){ |
115 |
return ((ServiceInfo)arg0).getLayerList().get(i);
|
116 |
}else{
|
117 |
return ((LayerInfo)arg0).getLayerList().get(i);
|
118 |
} |
119 |
|
120 |
} |
121 |
|
122 |
public int getIndexOfChild(Object arg0, Object arg1) { |
123 |
ArrayList children;
|
124 |
if (arg0 instanceof ServiceInfo){ |
125 |
children = ((ServiceInfo)arg0).getLayerList(); |
126 |
}else{
|
127 |
children = ((LayerInfo)arg0).getLayerList(); |
128 |
} |
129 |
for (int i=0 ; i<children.size() ;i++){ |
130 |
if (children.get(i).equals(arg1)){
|
131 |
return i;
|
132 |
} |
133 |
} |
134 |
return -1; |
135 |
} |
136 |
|
137 |
public void valueForPathChanged(TreePath arg0, Object arg1) { |
138 |
|
139 |
} |
140 |
|
141 |
} |