Revision 107
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.catalog.CatalogLibrary |
|
2 |
org.gvsig.catalog.impl.DefaultCatalogLibrary |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/DateTime.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils; |
|
43 |
import java.util.Calendar; |
|
44 |
import java.util.Date; |
|
45 |
import java.util.GregorianCalendar; |
|
46 |
import java.util.Locale; |
|
47 |
|
|
48 |
/** |
|
49 |
* This class contains static methods to manage Dates. It was principally |
|
50 |
* created because of some problems doing the "String do DateTime" |
|
51 |
* and the "DateTime to String" conversions. |
|
52 |
* |
|
53 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
54 |
*/ |
|
55 |
public class DateTime { |
|
56 |
|
|
57 |
/** |
|
58 |
* returns the current date |
|
59 |
* |
|
60 |
* |
|
61 |
* @return java.util.Date |
|
62 |
*/ |
|
63 |
public static Date getCurrentDate() { |
|
64 |
Calendar cal = new GregorianCalendar(); |
|
65 |
|
|
66 |
return cal.getTime(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* It trnasforms one date in one String |
|
71 |
* |
|
72 |
* |
|
73 |
* @return A String |
|
74 |
* @param dtK Date |
|
75 |
* @param sFormat Date format. Example: "Y-m-d H:i:s.Z"; |
|
76 |
*/ |
|
77 |
public static String dateToString(Date dtK, String sFormat) { |
|
78 |
String sDate; |
|
79 |
int nYear; |
|
80 |
int nMonth; |
|
81 |
int nDay; |
|
82 |
int nHour; |
|
83 |
int nMinute; |
|
84 |
int nSecond; |
|
85 |
int nMS; |
|
86 |
Calendar clnK; |
|
87 |
String sf; |
|
88 |
int jc; |
|
89 |
clnK = Calendar.getInstance(Locale.US); |
|
90 |
clnK.setTime(dtK); |
|
91 |
nYear = clnK.get(Calendar.YEAR); |
|
92 |
nMonth = 1 + clnK.get(Calendar.MONTH); |
|
93 |
nDay = clnK.get(Calendar.DAY_OF_MONTH); |
|
94 |
nHour = clnK.get(Calendar.HOUR_OF_DAY); |
|
95 |
nMinute = clnK.get(Calendar.MINUTE); |
|
96 |
nSecond = clnK.get(Calendar.SECOND); |
|
97 |
nMS = clnK.get(Calendar.MILLISECOND); |
|
98 |
sDate = ""; |
|
99 |
for (jc = 0; jc < sFormat.length(); jc++) { |
|
100 |
switch (sFormat.charAt(jc)) { |
|
101 |
case 'Y': |
|
102 |
sDate += nYear; |
|
103 |
break; |
|
104 |
case 'm': |
|
105 |
sf = "" + nMonth; |
|
106 |
if (nMonth < 10) { |
|
107 |
sf = "0" + sf; |
|
108 |
} |
|
109 |
sDate += sf; |
|
110 |
break; |
|
111 |
case 'd': |
|
112 |
sf = "" + nDay; |
|
113 |
if (nDay < 10) { |
|
114 |
sf = "0" + sf; |
|
115 |
} |
|
116 |
sDate += sf; |
|
117 |
break; |
|
118 |
case 'H': |
|
119 |
sf = "" + nHour; |
|
120 |
if (nHour < 10) { |
|
121 |
sf = "0" + sf; |
|
122 |
} |
|
123 |
sDate += sf; |
|
124 |
break; |
|
125 |
case 'i': |
|
126 |
sf = "" + nMinute; |
|
127 |
if (nMinute < 10) { |
|
128 |
sf = "0" + sf; |
|
129 |
} |
|
130 |
sDate += sf; |
|
131 |
break; |
|
132 |
case 's': |
|
133 |
sf = "" + nSecond; |
|
134 |
if (nSecond < 10) { |
|
135 |
sf = "0" + sf; |
|
136 |
} |
|
137 |
sDate += sf; |
|
138 |
break; |
|
139 |
case 'Z': |
|
140 |
sf = "" + nMS; |
|
141 |
if (nMS < 10) { |
|
142 |
sf = "0" + sf; |
|
143 |
} |
|
144 |
sDate += sf; |
|
145 |
break; |
|
146 |
default: |
|
147 |
sDate += sFormat.substring(jc, jc + 1); |
|
148 |
} |
|
149 |
} |
|
150 |
return sDate; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* It transfoms one String in one Date |
|
155 |
* |
|
156 |
* |
|
157 |
* @return Date |
|
158 |
* @param sDate String |
|
159 |
*/ |
|
160 |
public static Date stringToDate(String sDate) { |
|
161 |
Date dtRes; |
|
162 |
Calendar clnK; |
|
163 |
int nYear; |
|
164 |
int nMonth; |
|
165 |
int nDay; |
|
166 |
int nHour; |
|
167 |
int nMinute; |
|
168 |
int nSecond; |
|
169 |
int nMS; |
|
170 |
String sf; |
|
171 |
for (; sDate.length() < 23;) |
|
172 |
sDate += "0"; |
|
173 |
sf = sDate.substring(0, 4); |
|
174 |
nYear = Integer.parseInt(sf); |
|
175 |
sf = sDate.substring(5, 7); |
|
176 |
nMonth = Integer.parseInt(sf) - 1; |
|
177 |
sf = sDate.substring(8, 10); |
|
178 |
nDay = Integer.parseInt(sf); |
|
179 |
sf = sDate.substring(11, 13); |
|
180 |
nHour = Integer.parseInt(sf); |
|
181 |
sf = sDate.substring(14, 16); |
|
182 |
nMinute = Integer.parseInt(sf); |
|
183 |
sf = sDate.substring(17, 19); |
|
184 |
nSecond = Integer.parseInt(sf); |
|
185 |
sf = sDate.substring(20, 23); |
|
186 |
nMS = Integer.parseInt(sf); |
|
187 |
clnK = Calendar.getInstance(Locale.US); |
|
188 |
clnK.set(nYear, nMonth, nDay, nHour, nMinute, nSecond); |
|
189 |
clnK.set(Calendar.MILLISECOND, nMS); |
|
190 |
dtRes = new Date(); |
|
191 |
dtRes = clnK.getTime(); |
|
192 |
// sf=dateToString(dtRes,"Y-m-d H:i:s.Z"); |
|
193 |
return dtRes; |
|
194 |
} |
|
195 |
} |
|
0 | 196 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/Doubles.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils; |
|
43 |
|
|
44 |
/** |
|
45 |
* This class has functions to work with Double's |
|
46 |
* |
|
47 |
* |
|
48 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
49 |
*/ |
|
50 |
public class Doubles { |
|
51 |
|
|
52 |
/** |
|
53 |
* This function returns a String that represents a double with just 5 decimal |
|
54 |
* numbers. |
|
55 |
* |
|
56 |
* |
|
57 |
* @return |
|
58 |
* @param number Double (like a String) |
|
59 |
*/ |
|
60 |
public static String get5Decimals(String number) { |
|
61 |
String parsedValue = null; |
|
62 |
if (number.indexOf(".") >= 0){ |
|
63 |
int pointPosition = number.indexOf("."); |
|
64 |
parsedValue = number.substring(0,pointPosition) + "."; |
|
65 |
if (number.substring(pointPosition,number.length()).length() > 5){ |
|
66 |
return parsedValue + number.substring(pointPosition + 1, pointPosition + 6); |
|
67 |
}else{ |
|
68 |
System.out.println(number); |
|
69 |
return parsedValue + number.substring(pointPosition + 1, number.length()); |
|
70 |
} |
|
71 |
} else { |
|
72 |
return number; |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
} |
|
77 |
} |
|
0 | 78 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/Frames.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils; |
|
43 |
import java.awt.GraphicsEnvironment; |
|
44 |
import java.awt.Point; |
|
45 |
|
|
46 |
import javax.swing.JDialog; |
|
47 |
import javax.swing.JFrame; |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
* |
|
52 |
* |
|
53 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
54 |
*/ |
|
55 |
public class Frames { |
|
56 |
|
|
57 |
/** |
|
58 |
* Sets a JFrame on the screen center |
|
59 |
* |
|
60 |
* |
|
61 |
* @param frame JFrams |
|
62 |
* @param width Frame width |
|
63 |
* @param height Frame height |
|
64 |
*/ |
|
65 |
public static void centerFrame(JFrame frame, int width, int height) { |
|
66 |
Point p = getWindowCenter(width,height); |
|
67 |
frame.setBounds(p.x, p.y, width, height); |
|
68 |
frame.validate(); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Sets a JDialog on the screen center |
|
73 |
* |
|
74 |
* |
|
75 |
* @param dialog JDilog |
|
76 |
* @param width Dilaog width |
|
77 |
* @param height Dialog height |
|
78 |
*/ |
|
79 |
public static void centerFrame(JDialog dialog, int width, int height) { |
|
80 |
Point p = getWindowCenter(width,height); |
|
81 |
dialog.setBounds(p.x, p.y, width, height); |
|
82 |
dialog.validate(); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* Sets a JDialog on the upper rigth corner |
|
87 |
* |
|
88 |
* |
|
89 |
* @param dialog JDilog |
|
90 |
* @param width Dilaog width |
|
91 |
* @param height Dialog height |
|
92 |
*/ |
|
93 |
public static void searchDialogPosition(JDialog dialog, int width, int height) { |
|
94 |
Point p = getWindowCenter(width,height); |
|
95 |
int x = new Double(p.x * 2).intValue(); |
|
96 |
int y = new Double(p.y * 0.25).intValue(); |
|
97 |
dialog.setBounds(x, y, width, height); |
|
98 |
dialog.validate(); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* It returns the screen center |
|
103 |
* |
|
104 |
* |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
private static Point getCenter() { |
|
108 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
109 |
return ge.getCenterPoint(); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* It returns the point to center a frame |
|
114 |
* |
|
115 |
* |
|
116 |
* @return |
|
117 |
* @param width Frame width |
|
118 |
* @param height Frame height |
|
119 |
*/ |
|
120 |
private static Point getWindowCenter(int width, int height) { |
|
121 |
Point center = getCenter(); |
|
122 |
center.x = center.x - (width / 2); |
|
123 |
center.y = center.y - (height / 2); |
|
124 |
return center; |
|
125 |
} |
|
126 |
} |
|
0 | 127 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/URIUtils.java | ||
---|---|---|
1 |
package org.gvsig.catalog.utils; |
|
2 |
|
|
3 |
import java.net.URI; |
|
4 |
import java.net.URISyntaxException; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id: URIUtils.java 561 2007-07-27 06:49:30 +0000 (Fri, 27 Jul 2007) jpiera $ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
51 |
* Added the registers |
|
52 |
* |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* Some utils to manage URI's |
|
57 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
58 |
*/ |
|
59 |
public class URIUtils { |
|
60 |
|
|
61 |
/** |
|
62 |
* It creates an URI from a String. If the port and the schema |
|
63 |
* have not been especified on the string this method |
|
64 |
* adds them |
|
65 |
* @param sUri |
|
66 |
* The uri like a string |
|
67 |
* @param defaultSchema |
|
68 |
* The deafulet schema |
|
69 |
* @param deafultPort |
|
70 |
* The default port |
|
71 |
* @return |
|
72 |
* An uri |
|
73 |
* @throws URISyntaxException |
|
74 |
*/ |
|
75 |
public static URI createUri(String sUri, String defaultSchema, int deafultPort) throws URISyntaxException{ |
|
76 |
String schema = defaultSchema; |
|
77 |
String host = null; |
|
78 |
int port = deafultPort; |
|
79 |
String path = ""; |
|
80 |
//Cut the schema |
|
81 |
int index = sUri.indexOf("://"); |
|
82 |
if (index > -1){ |
|
83 |
schema = sUri.substring(0,index); |
|
84 |
sUri = sUri.substring(index + 3, sUri.length()); |
|
85 |
} |
|
86 |
//Cut the path |
|
87 |
index = sUri.indexOf("/"); |
|
88 |
if (index > -1){ |
|
89 |
path = sUri.substring(index, sUri.length()); |
|
90 |
sUri = sUri.substring(0,index); |
|
91 |
} |
|
92 |
//Cut the host:port |
|
93 |
index = sUri.indexOf(":"); |
|
94 |
if (index > -1){ |
|
95 |
host = sUri.substring(0,index); |
|
96 |
port = Integer.valueOf(sUri.substring(index + 1, sUri.length())).intValue(); |
|
97 |
}else{ |
|
98 |
host = sUri; |
|
99 |
} |
|
100 |
return new URI(schema + "://" + host + ":" + port + path); |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
0 | 104 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/resourcestable/ButtonEditor.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.resourcestable; |
|
43 |
import java.awt.Component; |
|
44 |
import java.awt.event.ActionEvent; |
|
45 |
import java.awt.event.ActionListener; |
|
46 |
import java.util.Collection; |
|
47 |
|
|
48 |
import javax.swing.DefaultCellEditor; |
|
49 |
import javax.swing.JButton; |
|
50 |
import javax.swing.JCheckBox; |
|
51 |
import javax.swing.JTable; |
|
52 |
|
|
53 |
import org.gvsig.catalog.schemas.Resource; |
|
54 |
import org.gvsig.catalog.ui.chooseresource.ChooseResourceDialogPanel; |
|
55 |
|
|
56 |
/** |
|
57 |
* |
|
58 |
* |
|
59 |
* |
|
60 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
61 |
*/ |
|
62 |
public class ButtonEditor extends DefaultCellEditor { |
|
63 |
/** |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
protected JButton button; |
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* |
|
72 |
*/ |
|
73 |
private String label; |
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
* |
|
78 |
*/ |
|
79 |
private boolean isPushed; |
|
80 |
/** |
|
81 |
* |
|
82 |
* |
|
83 |
*/ |
|
84 |
private ChooseResourceDialogPanel dialog; |
|
85 |
|
|
86 |
/** |
|
87 |
* |
|
88 |
* |
|
89 |
*/ |
|
90 |
private java.util.Collection resources = new java.util.ArrayList(); |
|
91 |
|
|
92 |
/** |
|
93 |
* |
|
94 |
* |
|
95 |
* |
|
96 |
* @param checkBox |
|
97 |
* @param resources |
|
98 |
* @param dialog |
|
99 |
*/ |
|
100 |
public ButtonEditor(JCheckBox checkBox, Collection resources, ChooseResourceDialogPanel dialog) { |
|
101 |
super(checkBox); |
|
102 |
this.resources = resources; |
|
103 |
this.dialog = dialog; |
|
104 |
button = new JButton(); |
|
105 |
button.setOpaque(true); |
|
106 |
button.addActionListener(new ActionListener() { |
|
107 |
public void actionPerformed(ActionEvent e) { |
|
108 |
fireEditingStopped(); |
|
109 |
} |
|
110 |
}); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* |
|
115 |
* |
|
116 |
* |
|
117 |
* @return |
|
118 |
* @param table |
|
119 |
* @param value |
|
120 |
* @param isSelected |
|
121 |
* @param row |
|
122 |
* @param column |
|
123 |
*/ |
|
124 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
125 |
if (isSelected) { |
|
126 |
button.setForeground(table.getSelectionForeground()); |
|
127 |
button.setBackground(table.getSelectionBackground()); |
|
128 |
} else{ |
|
129 |
button.setForeground(table.getForeground()); |
|
130 |
button.setBackground(table.getBackground()); |
|
131 |
} |
|
132 |
label = (value == null) ? "" : value.toString(); |
|
133 |
button.setText( label ); |
|
134 |
button.setName(String.valueOf(row)); |
|
135 |
isPushed = true; |
|
136 |
return button; |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* |
|
141 |
* |
|
142 |
* |
|
143 |
* @return |
|
144 |
*/ |
|
145 |
public Object getCellEditorValue() { |
|
146 |
if (isPushed) { |
|
147 |
Resource resource = (Resource)resources.toArray()[Integer.valueOf(button.getName()).intValue()]; |
|
148 |
this.dialog.resourceButtonActionPerformed(resource); |
|
149 |
|
|
150 |
} |
|
151 |
isPushed = false; |
|
152 |
return new String(label) ; |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* |
|
157 |
* |
|
158 |
* |
|
159 |
* @return |
|
160 |
*/ |
|
161 |
public boolean stopCellEditing() { |
|
162 |
isPushed = false; |
|
163 |
return super.stopCellEditing(); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* |
|
168 |
* |
|
169 |
*/ |
|
170 |
protected void fireEditingStopped() { |
|
171 |
super.fireEditingStopped(); |
|
172 |
} |
|
173 |
} |
|
0 | 174 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/resourcestable/ButtonRenderer.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.resourcestable; |
|
43 |
import java.awt.Component; |
|
44 |
|
|
45 |
import javax.swing.JButton; |
|
46 |
import javax.swing.JTable; |
|
47 |
import javax.swing.UIManager; |
|
48 |
import javax.swing.table.TableCellRenderer; |
|
49 |
|
|
50 |
/** |
|
51 |
* |
|
52 |
* |
|
53 |
* |
|
54 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
55 |
*/ |
|
56 |
public class ButtonRenderer extends JButton implements TableCellRenderer { |
|
57 |
|
|
58 |
/** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
public ButtonRenderer() { |
|
63 |
setOpaque(true); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* |
|
68 |
* |
|
69 |
* |
|
70 |
* @return |
|
71 |
* @param table |
|
72 |
* @param value |
|
73 |
* @param isSelected |
|
74 |
* @param hasFocus |
|
75 |
* @param row |
|
76 |
* @param column |
|
77 |
*/ |
|
78 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
79 |
if (isSelected) { |
|
80 |
setForeground(table.getSelectionForeground()); |
|
81 |
setBackground(table.getSelectionBackground()); |
|
82 |
} else{ |
|
83 |
setForeground(table.getForeground()); |
|
84 |
setBackground(UIManager.getColor("Button.background")); |
|
85 |
} |
|
86 |
setText( (value ==null) ? "" : value.toString() ); |
|
87 |
return this; |
|
88 |
} |
|
89 |
} |
|
0 | 90 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/resourcestable/TableModel.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.resourcestable; |
|
43 |
import javax.swing.table.DefaultTableModel; |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* |
|
48 |
* |
|
49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
50 |
*/ |
|
51 |
public class TableModel extends DefaultTableModel { |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
* |
|
56 |
* |
|
57 |
* @param columnValues |
|
58 |
* @param columnNames |
|
59 |
*/ |
|
60 |
public TableModel(Object[][] columnValues, String[] columnNames) { |
|
61 |
setDataVector(columnValues,columnNames); |
|
62 |
|
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* |
|
67 |
* |
|
68 |
* |
|
69 |
* @return |
|
70 |
* @param c |
|
71 |
*/ |
|
72 |
public Class getColumnClass(int c) { |
|
73 |
return getValueAt(0, c).getClass(); |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/SOAPMessageParser.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils; |
|
43 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
44 |
import org.gvsig.catalog.metadataxml.XMLTree; |
|
45 |
|
|
46 |
/** |
|
47 |
* This class is used to parse a SOAP message |
|
48 |
* |
|
49 |
* |
|
50 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
51 |
*/ |
|
52 |
public class SOAPMessageParser { |
|
53 |
|
|
54 |
/** |
|
55 |
* Cut the SOAP Head |
|
56 |
* |
|
57 |
* |
|
58 |
* @return A new node without the SOAP Head |
|
59 |
* @param node Node retreived |
|
60 |
*/ |
|
61 |
public static XMLNode cutHead(XMLNode node) { |
|
62 |
XMLNode[] children = node.getSubnodes(); |
|
63 |
for (int i = 0; i < node.getNumSubNodes(); i++) |
|
64 |
if (children[i].getName().equals("SOAP-ENV:Body")) { |
|
65 |
return children[i]; |
|
66 |
} |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Get the fault code (if it exists) |
|
72 |
* |
|
73 |
* |
|
74 |
* @return The Fault message or NULL |
|
75 |
* @param node The node retrieved |
|
76 |
*/ |
|
77 |
public static String getFault(XMLNode node) { |
|
78 |
if (node == null) { |
|
79 |
return null; |
|
80 |
} |
|
81 |
node = cutHead(node); |
|
82 |
if (node.getName().equals("SOAP-ENV:Fault")) { |
|
83 |
return "FAULT-CODE = " + |
|
84 |
XMLTree.searchNodeValue(node, "faultcode") + "\nREASON = " + |
|
85 |
"Este error se produce normalmente cuando el " + |
|
86 |
"servidor no implementa la operacion getCapabilities"; |
|
87 |
} |
|
88 |
//XMLTree.searchNodeValue(node,"faultstring"); |
|
89 |
return null; |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/CatalogConstants.java | ||
---|---|---|
1 |
package org.gvsig.catalog.utils; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
|
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
6 |
* |
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
8 |
* |
|
9 |
* This program is free software; you can redistribute it and/or |
|
10 |
* modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 |
|
12 |
* of the License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, |
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with this program; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
|
33 |
* www.gvsig.gva.es |
|
34 |
* |
|
35 |
* or |
|
36 |
* |
|
37 |
* IVER T.I. S.A |
|
38 |
* Salamanca 50 |
|
39 |
* 46005 Valencia |
|
40 |
* Spain |
|
41 |
* |
|
42 |
* +34 963163400 |
|
43 |
* dac@iver.es |
|
44 |
*/ |
|
45 |
/* CVS MESSAGES: |
|
46 |
* |
|
47 |
* $Id: CatalogConstants.java 602 2007-09-24 11:55:02 +0000 (Mon, 24 Sep 2007) jpiera $ |
|
48 |
* $Log$ |
|
49 |
* Revision 1.1.2.4 2007/07/24 09:45:52 jorpiell |
|
50 |
* Fix some interface bugs |
|
51 |
* |
|
52 |
* Revision 1.1.2.3 2007/07/23 07:14:25 jorpiell |
|
53 |
* Catalog refactoring |
|
54 |
* |
|
55 |
* Revision 1.1.2.2 2007/07/11 13:01:50 jorpiell |
|
56 |
* Catalog UI updated |
|
57 |
* |
|
58 |
* Revision 1.1.2.1 2007/07/10 11:18:04 jorpiell |
|
59 |
* Added the registers |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* This class has some constants for the catalog client |
|
65 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
66 |
*/ |
|
67 |
public class CatalogConstants { |
|
68 |
public static final int BUTTON_LENGHT = 80; |
|
69 |
public static final int BUTTON_WIDTH = 23; |
|
70 |
public static final Dimension BUTTON_SIZE = new Dimension(BUTTON_LENGHT,BUTTON_WIDTH); |
|
71 |
public static final int RESIZE_WINDOW_BUTTON_SIZE = 30; |
|
72 |
|
|
73 |
//Action commands |
|
74 |
public static final String CLOSE_BUTTON_ACTION_COMMAND = "close"; |
|
75 |
public static final String NEXT_BUTTON_ACTION_COMMAND = "next"; |
|
76 |
public static final String LAST_BUTTON_ACTION_COMMAND = "last"; |
|
77 |
public static final String CANCEL_BUTTON_ACTION_COMMAND = "cancel"; |
|
78 |
public static final String SEARCH_BUTTON_ACTION_COMMAND = "search"; |
|
79 |
public static final String PROTOCOL_COMBO_ACTION_COMMAND = "protocolCombo"; |
|
80 |
public static final String SERVER_COMBO_ACTION_COMMAND = "serverCombo"; |
|
81 |
public static final String RESIZE_BUTTON_ACTION_COMMAND = "resize"; |
|
82 |
public static final String CONNECT_BUTTON_ACTION_COMMAND = "connect"; |
|
83 |
public static final String SERVERPROPERTIES_BUTTON_ACTION_COMMAND = "serverProperties"; |
|
84 |
|
|
85 |
//conordancia |
|
86 |
public static final String EXACT_WORDS = "E"; |
|
87 |
public static final String ANY_WORD = "Y"; |
|
88 |
public static final String ALL_WORDS = "A"; |
|
89 |
public static final String OR = "Or"; |
|
90 |
public static final String AND = "And"; |
|
91 |
|
|
92 |
//Connection |
|
93 |
public static final int GET = 0; |
|
94 |
public static final int POST = 1; |
|
95 |
public static final int SOAP = 2; |
|
96 |
public static final int Z3950 = 4; |
|
97 |
|
|
98 |
//XML |
|
99 |
public static final String XML_HEADER_ENCODING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
|
100 |
public static final String XML_NS = "xmlns"; |
|
101 |
|
|
102 |
} |
|
0 | 103 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/xmltreetable/XMLTreeCellRenderer.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.xmltreetable; |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
* |
|
47 |
* |
|
48 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
49 |
*/ |
|
50 |
public class XMLTreeCellRenderer extends javax.swing.tree.DefaultTreeCellRenderer { |
|
51 |
|
|
52 |
/** |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
public XMLTreeCellRenderer() { |
|
57 |
this.setClosedIcon(null); |
|
58 |
this.setOpenIcon(null); |
|
59 |
this.setLeafIcon(null); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/xmltreetable/XMLTreeTable.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.xmltreetable; |
|
43 |
import javax.swing.JComponent; |
|
44 |
import javax.swing.JTree; |
|
45 |
|
|
46 |
import next.swing.JTreeTable; |
|
47 |
import next.swing.TreeTableModel; |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
* |
|
52 |
* |
|
53 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
54 |
*/ |
|
55 |
public class XMLTreeTable extends JTreeTable { |
|
56 |
|
|
57 |
/** |
|
58 |
* |
|
59 |
* |
|
60 |
* |
|
61 |
* @param treeTableModel |
|
62 |
*/ |
|
63 |
public XMLTreeTable(TreeTableModel treeTableModel) { |
|
64 |
super(treeTableModel); |
|
65 |
tree.setCellRenderer(new XMLTreeCellRenderer()); |
|
66 |
setDefaultEditor(JComponent.class, new XMLTreeTableCellEditor()); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* |
|
72 |
* |
|
73 |
* @return |
|
74 |
*/ |
|
75 |
public JTree getTree() { |
|
76 |
return tree; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* |
|
81 |
* |
|
82 |
* |
|
83 |
* @return |
|
84 |
* @param x |
|
85 |
* @param y |
|
86 |
*/ |
|
87 |
public boolean isCellEditable(int x, int y) { |
|
88 |
return true; |
|
89 |
} |
|
90 |
} |
|
0 | 91 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.10/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/utils/xmltreetable/XMLTreeTableModel.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
package org.gvsig.catalog.utils.xmltreetable; |
|
43 |
import java.awt.Font; |
|
44 |
import java.util.Enumeration; |
|
45 |
import java.util.Vector; |
|
46 |
|
|
47 |
import javax.swing.JEditorPane; |
|
48 |
import javax.swing.JLabel; |
|
49 |
import javax.swing.JScrollPane; |
|
50 |
import javax.swing.JTree; |
|
51 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
52 |
import javax.swing.tree.TreePath; |
|
53 |
|
|
54 |
import next.swing.AbstractTreeTableModel; |
|
55 |
import next.swing.TreeTableModel; |
|
56 |
|
|
57 |
import org.amic.util.date.Date; |
|
58 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
59 |
import org.gvsig.catalog.utils.Strings; |
|
60 |
|
|
61 |
/** |
|
62 |
* |
|
63 |
* |
|
64 |
* |
|
65 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
66 |
*/ |
|
67 |
public class XMLTreeTableModel extends AbstractTreeTableModel { |
|
68 |
|
|
69 |
/** |
|
70 |
* |
|
71 |
* |
|
72 |
*/ |
|
73 |
private Vector columns = null; |
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
* |
|
78 |
*/ |
|
79 |
private String[] allowed = null; |
|
80 |
|
|
81 |
/** |
|
82 |
* |
|
83 |
* |
|
84 |
*/ |
|
85 |
private String[] forbidden = null; |
|
86 |
|
|
87 |
/** |
|
88 |
* |
|
89 |
* |
|
90 |
*/ |
|
91 |
private boolean dynamic = false; |
|
92 |
|
|
93 |
/** |
|
94 |
* Creates new XmlTreeTableModel |
|
95 |
* |
|
96 |
* |
|
97 |
* @param node |
|
98 |
*/ |
|
99 |
public XMLTreeTableModel(XMLNode node) { |
|
100 |
this(node, -1, null, null); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* |
|
105 |
* |
|
106 |
* |
|
107 |
* @param node |
|
108 |
* @param level |
|
109 |
* @param allowed |
|
110 |
* @param forbidden |
|
111 |
*/ |
|
112 |
public XMLTreeTableModel(XMLNode node, int level, String[] allowed, String[] forbidden) { |
|
113 |
super(new DefaultMutableTreeNode(node)); |
|
114 |
this.allowed = allowed; |
|
115 |
this.forbidden = forbidden; |
|
116 |
processChildren((DefaultMutableTreeNode) getRoot(), level); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* |
|
121 |
* |
|
122 |
*/ |
|
123 |
public final int ALIGN_LEFT = JLabel.LEFT; |
|
124 |
|
|
125 |
/** |
|
126 |
* |
|
127 |
* |
|
128 |
*/ |
|
129 |
public final int ALIGN_RIGHT = JLabel.RIGHT; |
|
130 |
|
|
131 |
/** |
|
132 |
* |
|
133 |
* |
|
134 |
*/ |
|
135 |
public final int ALIGN_CENTER = JLabel.CENTER; |
|
136 |
|
|
137 |
/** |
|
138 |
* |
|
139 |
* |
|
140 |
* |
|
141 |
* @param value |
|
142 |
*/ |
|
143 |
public void setDynamic(boolean value) { |
|
144 |
dynamic = value; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* |
|
149 |
* |
|
150 |
* |
|
151 |
* @return |
|
152 |
* @param node |
|
153 |
*/ |
|
154 |
public boolean isLeaf(Object node) { |
|
155 |
return (getChildCount(node) == 0) && !dynamic; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* |
|
160 |
* |
|
161 |
* |
|
162 |
* @return |
|
163 |
* @param node |
|
164 |
* @param level |
|
165 |
*/ |
|
166 |
public boolean processChildren(DefaultMutableTreeNode node, int level) { |
|
167 |
if (level == 0) { |
|
168 |
return true; |
|
169 |
} |
|
170 |
boolean doIt = true; |
|
171 |
XMLNode n = (XMLNode) node.getUserObject(); |
Also available in: Unified diff