gvsig-scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.main / src / main / java / org / gvsig / scripting / main / Main.java @ 212
History | View | Annotate | Download (9.07 KB)
1 |
package org.gvsig.scripting.main; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
import java.io.File; |
7 |
import java.net.URL; |
8 |
import java.util.Calendar; |
9 |
import java.util.Date; |
10 |
import java.util.HashMap; |
11 |
import java.util.Map; |
12 |
|
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JMenu; |
16 |
import javax.swing.JMenuBar; |
17 |
import javax.swing.JMenuItem; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JToolBar; |
20 |
import javax.swing.WindowConstants; |
21 |
|
22 |
import org.gvsig.about.AboutLocator; |
23 |
import org.gvsig.about.AboutManager; |
24 |
import org.gvsig.about.AboutParticipant; |
25 |
import org.gvsig.scripting.ScriptingManager; |
26 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
27 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
28 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
29 |
|
30 |
public class Main { |
31 |
|
32 |
/**
|
33 |
*
|
34 |
*/
|
35 |
private static final long serialVersionUID = -6853523688803006280L; |
36 |
static ScriptingUIManager uimanager;
|
37 |
static AboutManager aboutManager;
|
38 |
|
39 |
public static void main(String args[]) { |
40 |
Main main = new Main();
|
41 |
main.doMain(args); |
42 |
} |
43 |
|
44 |
public void doMain(String args[]) { |
45 |
|
46 |
new DefaultLibrariesInitializer().fullInitialize();
|
47 |
|
48 |
// This step is necessary for extensions to work:
|
49 |
/*
|
50 |
* try {
|
51 |
* PlatformInit.getInstance().init(false, false);
|
52 |
* } catch (Exception e1) {
|
53 |
* // TODO Auto-generated catch block
|
54 |
* e1.printStackTrace();
|
55 |
* }
|
56 |
*/
|
57 |
|
58 |
aboutManager = AboutLocator.getManager(); |
59 |
|
60 |
Map<String, String> gvsig_vars = new HashMap<String, String>(); |
61 |
gvsig_vars.put("version", "2.0.0"); |
62 |
gvsig_vars.put("build", "2020"); |
63 |
aboutManager.setProject("gvSIG Desktop", getResource("gvsig.html"), |
64 |
null, gvsig_vars);
|
65 |
aboutManager.getProject().set("build", "2021"); |
66 |
|
67 |
AboutParticipant participant; |
68 |
|
69 |
participant = |
70 |
aboutManager.addSponsor("Generalitat Valenciana",
|
71 |
getResource("gva.html"), 1); |
72 |
|
73 |
participant = |
74 |
aboutManager.addDeveloper("IVER", getResource("iver.html"), 2); |
75 |
|
76 |
participant = |
77 |
aboutManager.addDeveloper("PRODEVELOP",
|
78 |
getResource("prodevelop.html"), 2); |
79 |
|
80 |
participant = |
81 |
aboutManager.addDeveloper("Software Colaborativo",
|
82 |
getResource("scolab.html"), 3); |
83 |
|
84 |
participant = |
85 |
aboutManager.addDeveloper("DISID", getResource("disid.html"), 4); |
86 |
|
87 |
participant = |
88 |
aboutManager.addDeveloper("UCLM", getResource("uclm.html"), 5); |
89 |
|
90 |
participant = |
91 |
aboutManager.addDeveloper("CSGIS", getResource("csgis.html"), 5); |
92 |
|
93 |
participant = aboutManager.getDeveloper("PRODEVELOP");
|
94 |
participant.addContribution("JDBC Oracle Spatial",
|
95 |
"Prodevelop S.L. ha mejorado y ampliado la extension extJDBC "
|
96 |
+ "y ha a?adido el driver para el acceso a informacion "
|
97 |
+ "geografica en bases de datos Oracle.", getDate(2009, 1, 2), |
98 |
getDate(2009, 12, 21)); |
99 |
participant.addContribution("ArcIMS", "Cliente ArcIMS para gvSIG", |
100 |
getDate(2009, 1, 2), getDate(2009, 12, 21)); |
101 |
|
102 |
participant = aboutManager.getDeveloper("DISID");
|
103 |
participant.addContribution("Gesti?n de Internacionalizacion",
|
104 |
"Extensi?n de Gesti?n de traducciones", getDate(2009, 1, 2), |
105 |
getDate(2009, 12, 21)); |
106 |
|
107 |
participant = aboutManager.getDeveloper("UCLM");
|
108 |
participant.addContribution("JCRS",
|
109 |
"Extensi?n para el manejo de Sistemas de Referencia de "
|
110 |
+ "Coordenadas", getDate(2009, 1, 2), getDate(2009, 12, 21)); |
111 |
|
112 |
participant = |
113 |
aboutManager.addSponsor("Junta Castilla y Le?n",
|
114 |
getResource("castillaLeon.html"), 2); |
115 |
participant.addContribution("Backup del fichero GVP",
|
116 |
"Backup automatico del gvp antes de guardar", getDate(2009, 6, 1), |
117 |
getDate(2009, 12, 1)); |
118 |
participant.addContribution("Herramienta de informacion rapida",
|
119 |
"Herramienta que muestra un tip con la informacion de las "
|
120 |
+ "geometrias sobre las que pasa el puntero",
|
121 |
getDate(2009, 6, 1), getDate(2009, 12, 1)); |
122 |
participant.addContribution("Herramientas de seleccion",
|
123 |
"Varias herramientas de seleccion", 2009, 6, 1, 2009, 12, 1); |
124 |
|
125 |
participant = |
126 |
aboutManager.addSponsor("Region de Murcia",
|
127 |
getResource("regionDeMurcia.html"), 2); |
128 |
participant.addContribution("ArcSDE",
|
129 |
"Extesi?n de la Aplicaci?n para la conexi?n con una Base de "
|
130 |
+ "Datos ArcSDE.", getDate(2009, 6, 1), getDate(2009, 12, 1)); |
131 |
|
132 |
participant = |
133 |
aboutManager.addTranslator("Gustavo P?rez",
|
134 |
getResource("gustavoPerez.html"), 1); |
135 |
participant |
136 |
.addContribution("traducci?n multidioma", "traducci?n al franc?s", |
137 |
getDate(2009, 1, 2), getDate(2009, 12, 21)); |
138 |
|
139 |
// Asignamos el locator e iniciamos la instancia
|
140 |
uimanager = ScriptingSwingLocator.getUIManager(); |
141 |
final ScriptingManager manager = uimanager.getManager();
|
142 |
|
143 |
// Ejemplo de mecanismo de registro de paquetes para la Browser del
|
144 |
// Sistema
|
145 |
URL u =
|
146 |
Main.class.getClassLoader().getResource( |
147 |
"org/gvsig/scripting/impl/scripts/");
|
148 |
File f = new File(u.getPath()); |
149 |
manager.registerSystemFolder("Tests", f);
|
150 |
|
151 |
uimanager.addUserHelp("es", Main.class.getResource("/")); |
152 |
|
153 |
JFrame frame = new JFrame("gvSIG's Script Framework"); |
154 |
frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
155 |
|
156 |
// Create the menu bar.
|
157 |
JMenuBar menuBar = new JMenuBar(); |
158 |
|
159 |
// Build the menu.
|
160 |
JMenu menu_file = new JMenu("File"); |
161 |
JMenuItem menuItem_launcher = new JMenuItem("Open Launcher"); |
162 |
menuItem_launcher.addActionListener(new ActionListener() { |
163 |
|
164 |
public void actionPerformed(ActionEvent e) { |
165 |
showLauncher(manager); |
166 |
} |
167 |
}); |
168 |
menu_file.add(menuItem_launcher); |
169 |
|
170 |
JMenuItem menuItem_composer = new JMenuItem("Open Composer"); |
171 |
menuItem_composer.addActionListener(new ActionListener() { |
172 |
|
173 |
public void actionPerformed(ActionEvent e) { |
174 |
showComposer(manager); |
175 |
} |
176 |
}); |
177 |
menu_file.add(menuItem_composer); |
178 |
|
179 |
JMenuItem menuItem_installer = new JMenuItem("Open Installer"); |
180 |
menuItem_installer.addActionListener(new ActionListener() { |
181 |
|
182 |
public void actionPerformed(ActionEvent e) { |
183 |
showInstaller(manager); |
184 |
} |
185 |
}); |
186 |
menu_file.add(menuItem_installer); |
187 |
|
188 |
menu_file.addSeparator(); |
189 |
|
190 |
JMenuItem menuItem_exit = new JMenuItem("Exit"); |
191 |
menuItem_exit.addActionListener(new ActionListener() { |
192 |
|
193 |
public void actionPerformed(ActionEvent e) { |
194 |
System.exit(0); |
195 |
} |
196 |
}); |
197 |
menu_file.add(menuItem_exit); |
198 |
|
199 |
menuBar.add(menu_file); |
200 |
|
201 |
JToolBar toolBar = new JToolBar(); |
202 |
|
203 |
JButton launch = new JButton("Launcher"); |
204 |
launch.addActionListener(new ActionListener() { |
205 |
|
206 |
public void actionPerformed(ActionEvent arg0) { |
207 |
showLauncher(manager); |
208 |
} |
209 |
|
210 |
}); |
211 |
JButton comp = new JButton("Composer"); |
212 |
comp.addActionListener(new ActionListener() { |
213 |
|
214 |
public void actionPerformed(ActionEvent arg0) { |
215 |
showComposer(manager); |
216 |
} |
217 |
|
218 |
}); |
219 |
JButton install = new JButton("Installer"); |
220 |
install.addActionListener(new ActionListener() { |
221 |
|
222 |
public void actionPerformed(ActionEvent e) { |
223 |
showInstaller(manager); |
224 |
} |
225 |
}); |
226 |
toolBar.add(launch); |
227 |
toolBar.add(comp); |
228 |
toolBar.add(install); |
229 |
|
230 |
uimanager.setMainFrame(frame); |
231 |
// frame.setPreferredSize(new Dimension(450, 130));
|
232 |
frame.add(menuBar, BorderLayout.NORTH);
|
233 |
frame.add(toolBar, BorderLayout.LINE_END);
|
234 |
|
235 |
// Display the window.
|
236 |
frame.pack(); |
237 |
frame.setVisible(true);
|
238 |
|
239 |
} |
240 |
|
241 |
public Date getDate(int year, int month, int day) { |
242 |
Calendar cal = Calendar.getInstance(); |
243 |
cal.set(year, month, day); |
244 |
return cal.getTime();
|
245 |
} |
246 |
|
247 |
public URL getResource(String name) { |
248 |
URL resource = this.getClass().getResource(name); |
249 |
return resource;
|
250 |
} |
251 |
|
252 |
public static void showLauncher(ScriptingManager manager) { |
253 |
showWindow(uimanager.createLauncher(), "Scripting Launcher");
|
254 |
} |
255 |
|
256 |
public static void showComposer(ScriptingManager manager) { |
257 |
showWindow(uimanager.createComposer(), "Scripting Composer");
|
258 |
} |
259 |
|
260 |
public static void showInstaller(ScriptingManager manager) { |
261 |
|
262 |
} |
263 |
|
264 |
public static void showWindow(JPanel panel, String title) { |
265 |
JFrame frame = new JFrame(title); |
266 |
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
267 |
|
268 |
frame.setContentPane(panel); |
269 |
|
270 |
// Display the window.
|
271 |
frame.pack(); |
272 |
frame.setVisible(true);
|
273 |
} |
274 |
} |