svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / InitializeApplicationExtension.java @ 44750
History | View | Annotate | Download (20.6 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | 41576 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 40558 | jjdelcerro | *
|
11 | 41576 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 40558 | jjdelcerro | *
|
16 | 41576 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 40558 | jjdelcerro | *
|
20 | 41576 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40558 | jjdelcerro | */
|
23 | 40435 | jjdelcerro | package org.gvsig.app.extension; |
24 | |||
25 | 43095 | jjdelcerro | import java.awt.GridBagConstraints; |
26 | import java.beans.PropertyVetoException; |
||
27 | 40435 | jjdelcerro | import java.io.BufferedReader; |
28 | 44238 | jjdelcerro | import java.io.File; |
29 | 40435 | jjdelcerro | import java.io.InputStream; |
30 | import java.io.InputStreamReader; |
||
31 | import java.io.StringWriter; |
||
32 | 44404 | omartinez | import java.util.ArrayList; |
33 | 41735 | jjdelcerro | import java.util.HashMap; |
34 | 44404 | omartinez | import java.util.List; |
35 | 41735 | jjdelcerro | import java.util.Map; |
36 | 44704 | jjdelcerro | import java.util.Objects; |
37 | 40435 | jjdelcerro | import java.util.Properties; |
38 | 44238 | jjdelcerro | import java.util.prefs.Preferences; |
39 | 41620 | jjdelcerro | import javax.swing.JOptionPane; |
40 | 41706 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
41 | 40435 | jjdelcerro | |
42 | import org.gvsig.andami.IconThemeHelper; |
||
43 | 41620 | jjdelcerro | import org.gvsig.andami.PluginServices; |
44 | 40435 | jjdelcerro | import org.gvsig.andami.PluginsLocator; |
45 | import org.gvsig.andami.PluginsManager; |
||
46 | 41620 | jjdelcerro | import org.gvsig.andami.actioninfo.ActionInfoManager; |
47 | 40435 | jjdelcerro | import org.gvsig.andami.plugins.Extension; |
48 | 43095 | jjdelcerro | import org.gvsig.andami.ui.mdiManager.IWindow; |
49 | 40435 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
50 | import org.gvsig.app.ApplicationManager; |
||
51 | 44238 | jjdelcerro | import static org.gvsig.app.extension.ProjectExtension.PROJECT_FILE_CHOOSER_ID; |
52 | 43095 | jjdelcerro | import org.gvsig.app.project.ProjectManager; |
53 | import org.gvsig.app.project.ProjectPreferences; |
||
54 | import org.gvsig.app.project.documents.view.ViewDocument; |
||
55 | import org.gvsig.app.project.documents.view.ViewManager; |
||
56 | import org.gvsig.app.project.documents.view.gui.IView; |
||
57 | 40435 | jjdelcerro | import org.gvsig.app.project.documents.view.toolListeners.InfoListener; |
58 | import org.gvsig.app.util.BaseOpenErrorHandler; |
||
59 | 44404 | omartinez | import org.gvsig.expressionevaluator.Expression; |
60 | import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
||
61 | import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
||
62 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
63 | 44129 | jjdelcerro | import org.gvsig.fmap.dal.DataManager; |
64 | 44704 | jjdelcerro | import org.gvsig.fmap.dal.DataServerExplorerPool; |
65 | import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
||
66 | import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
||
67 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.OpenErrorHandler; |
68 | 44189 | jjdelcerro | import org.gvsig.fmap.dal.feature.AbstractDataProfile; |
69 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.resource.ResourceManager; |
70 | import org.gvsig.fmap.dal.resource.exception.DisposeResorceManagerException; |
||
71 | 44238 | jjdelcerro | import static org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanelController.OPEN_LAYER_FILE_CHOOSER_ID; |
72 | 40435 | jjdelcerro | import org.gvsig.installer.lib.api.InstallerLocator; |
73 | import org.gvsig.installer.lib.api.InstallerManager; |
||
74 | import org.gvsig.installer.lib.api.PackageInfo; |
||
75 | 41620 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
76 | 44404 | omartinez | import org.gvsig.tools.bookmarksandhistory.Bookmark; |
77 | import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
||
78 | import org.gvsig.tools.bookmarksandhistory.History; |
||
79 | 44448 | jjdelcerro | import org.gvsig.tools.dataTypes.CoercionException; |
80 | import org.gvsig.tools.dataTypes.DataType; |
||
81 | import org.gvsig.tools.dataTypes.DataTypes; |
||
82 | 41620 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject; |
83 | 44253 | jjdelcerro | import org.gvsig.tools.dynobject.Tags; |
84 | 44238 | jjdelcerro | import org.gvsig.tools.folders.FoldersManager; |
85 | 41620 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
86 | 44129 | jjdelcerro | import org.gvsig.tools.swing.api.SimpleImage; |
87 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
88 | import org.gvsig.tools.swing.api.ToolsSwingManager; |
||
89 | 40435 | jjdelcerro | import org.slf4j.Logger; |
90 | import org.slf4j.LoggerFactory; |
||
91 | |||
92 | 44704 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
93 | 40435 | jjdelcerro | public class InitializeApplicationExtension extends Extension { |
94 | 41576 | jjdelcerro | |
95 | 44704 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(InitializeApplicationExtension.class); |
96 | 40435 | jjdelcerro | |
97 | 44238 | jjdelcerro | // Copiadas de org.gvsig.coreplugin.PreferencesExtension
|
98 | public static final String PROJECTS_FOLDER_PROPERTY_NAME = "ProjectsFolder"; |
||
99 | public static final String DATA_FOLDER_PROPERTY_NAME = "DataFolder"; |
||
100 | public static final String TEMPLATES_FOLDER_PROPERTY_NAME = "TemplatesFolder"; |
||
101 | public static final String SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME = "SymbolLibraryFolder"; |
||
102 | 40435 | jjdelcerro | |
103 | 44404 | omartinez | private OpenErrorHandler openErrorHandler = null; |
104 | 44238 | jjdelcerro | |
105 | 44189 | jjdelcerro | private static class SimpleImageDataProfile extends AbstractDataProfile { |
106 | |||
107 | public SimpleImageDataProfile() {
|
||
108 | super("Image", SimpleImage.class); |
||
109 | } |
||
110 | 44404 | omartinez | |
111 | 44189 | jjdelcerro | @Override
|
112 | 44253 | jjdelcerro | public Object createData(Object data, Tags tags) { |
113 | 44189 | jjdelcerro | final ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
|
114 | SimpleImage image = toolsSwingManager.createSimpleImage(data); |
||
115 | return image;
|
||
116 | } |
||
117 | 44448 | jjdelcerro | |
118 | @Override
|
||
119 | public Object coerce(DataType dataType, Object data, Tags tags) throws CoercionException { |
||
120 | final ToolsSwingManager toolsSwingManager;
|
||
121 | final SimpleImage image;
|
||
122 | try {
|
||
123 | switch(dataType.getType()) {
|
||
124 | case DataTypes.BYTEARRAY:
|
||
125 | toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
||
126 | image = toolsSwingManager.createSimpleImage(data); |
||
127 | return image.toBytearray();
|
||
128 | case DataTypes.STRING:
|
||
129 | toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
||
130 | image = toolsSwingManager.createSimpleImage(data); |
||
131 | return image.toString();
|
||
132 | default:
|
||
133 | break;
|
||
134 | } |
||
135 | } catch(Exception ex) { |
||
136 | throw new CoercionException("Can't convert imagen to "+dataType.getName(), ex); |
||
137 | } |
||
138 | throw new CoercionException("Can't convert imagen to "+dataType.getName()); |
||
139 | } |
||
140 | |||
141 | 44189 | jjdelcerro | } |
142 | 44404 | omartinez | |
143 | 43095 | jjdelcerro | @Override
|
144 | 41576 | jjdelcerro | public void initialize() { |
145 | 42775 | jjdelcerro | DALLocator.registerFeatureTypeDefinitionsManager(DefaultFeatureTypeDefinitionsManager.class); |
146 | 44404 | omartinez | |
147 | 44750 | jjdelcerro | ExpressionEvaluatorLocator.getManager().registerClassLoader(this.getClass().getClassLoader());
|
148 | |||
149 | 44129 | jjdelcerro | DataManager dataManager = DALLocator.getDataManager(); |
150 | 44189 | jjdelcerro | dataManager.registerDataProfile(new SimpleImageDataProfile());
|
151 | 44404 | omartinez | |
152 | 41576 | jjdelcerro | InfoListener.initializeExtensionPoint(); |
153 | 44404 | omartinez | |
154 | 44238 | jjdelcerro | initLastPath(); |
155 | 41576 | jjdelcerro | registerIcons(); |
156 | 44404 | omartinez | loadExpressionBookmarks(); |
157 | loadExpressionHistory(); |
||
158 | } |
||
159 | 40435 | jjdelcerro | |
160 | 44404 | omartinez | public void loadExpressionHistory() { |
161 | PluginsManager pluginManager = PluginsLocator.getManager(); |
||
162 | final PluginServices plugin = pluginManager.getPlugin(this); |
||
163 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
164 | List<Expression> dynBookmarks = (List<Expression>) pluginProperties.getDynValue("expressionHistory"); |
||
165 | if (dynBookmarks == null) { |
||
166 | return;
|
||
167 | } |
||
168 | final ExpressionEvaluatorManager expressionManager = ExpressionEvaluatorLocator.getExpressionEvaluatorManager();
|
||
169 | History<Expression> history = expressionManager.getHistory();
|
||
170 | for (Expression expression : dynBookmarks) { |
||
171 | history.add(expression); |
||
172 | } |
||
173 | pluginManager.addShutdownTask("saveExpressionHistory", new Runnable() { |
||
174 | @Override
|
||
175 | public void run() { |
||
176 | DynObject properties = plugin.getPluginProperties(); |
||
177 | ArrayList<Expression> var = new ArrayList<>(); |
||
178 | for (Expression expression : history) { |
||
179 | var.add(expression); |
||
180 | } |
||
181 | properties.setDynValue("expressionHistory", var);
|
||
182 | } |
||
183 | }, false, 100); |
||
184 | |||
185 | 41576 | jjdelcerro | } |
186 | 44404 | omartinez | |
187 | public void loadExpressionBookmarks() { |
||
188 | PluginsManager pluginManager = PluginsLocator.getManager(); |
||
189 | final PluginServices plugin = pluginManager.getPlugin(this); |
||
190 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
191 | Map<String, Expression> dynBookmarks = (Map<String, Expression>) pluginProperties.getDynValue("expressionBookmarks"); |
||
192 | if (dynBookmarks == null) { |
||
193 | return;
|
||
194 | } |
||
195 | final ExpressionEvaluatorManager expressionManager = ExpressionEvaluatorLocator.getExpressionEvaluatorManager();
|
||
196 | Bookmarks<Expression> bookmarks = expressionManager.getBookmarks();
|
||
197 | for (String key : dynBookmarks.keySet()) { |
||
198 | Expression bookmark = dynBookmarks.get(key);
|
||
199 | bookmarks.add(bookmark); |
||
200 | } |
||
201 | pluginManager.addShutdownTask("saveExpressionBookmarks", new Runnable() { |
||
202 | @Override
|
||
203 | public void run() { |
||
204 | DynObject properties = plugin.getPluginProperties(); |
||
205 | Map<String, Expression> var = new HashMap<>(); |
||
206 | for (Bookmark<Expression> bookmark : bookmarks) { |
||
207 | var.put(bookmark.getName(), bookmark.getValue()); |
||
208 | } |
||
209 | properties.setDynValue("expressionBookmarks", var);
|
||
210 | } |
||
211 | }, false, 100); |
||
212 | |||
213 | } |
||
214 | |||
215 | 44238 | jjdelcerro | private void initLastPath() { |
216 | 44404 | omartinez | Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
217 | 44238 | jjdelcerro | FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
218 | String v;
|
||
219 | 44404 | omartinez | |
220 | 44238 | jjdelcerro | v = prefs.get(DATA_FOLDER_PROPERTY_NAME, folderManager.getHome().getAbsolutePath()); |
221 | folderManager.setLastPath(OPEN_LAYER_FILE_CHOOSER_ID, new File(v)); |
||
222 | 40435 | jjdelcerro | |
223 | 44238 | jjdelcerro | v = prefs.get(PROJECTS_FOLDER_PROPERTY_NAME, folderManager.getHome().getAbsolutePath()); |
224 | folderManager.setLastPath(PROJECT_FILE_CHOOSER_ID, new File(v)); |
||
225 | |||
226 | v = prefs.get("LegendsFolder", folderManager.getHome().getAbsolutePath());
|
||
227 | folderManager.setLastPath("LegendsFolder", new File(v)); |
||
228 | } |
||
229 | |||
230 | 43095 | jjdelcerro | @Override
|
231 | 41576 | jjdelcerro | public void postInitialize() { |
232 | 43095 | jjdelcerro | PluginsManager pluginManager = PluginsLocator.getManager(); |
233 | |||
234 | 40435 | jjdelcerro | openErrorHandler = new BaseOpenErrorHandler();
|
235 | ApplicationLocator.getManager().getDataManager().setOpenErrorHandler(openErrorHandler); |
||
236 | 41564 | jjdelcerro | |
237 | 41576 | jjdelcerro | DALLocator.getResourceManager().startResourceCollector( |
238 | 3 * (60 * 1000), // minutes --> miliseconds |
||
239 | null);
|
||
240 | 43095 | jjdelcerro | |
241 | 41913 | jjdelcerro | // showAddOnManagerOnStartIfNeed();
|
242 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
243 | if (projectPreferences.getOpenWithANewMaximizedView()) {
|
||
244 | pluginManager.addStartupTask( |
||
245 | "showNewViewMaximized",
|
||
246 | new ShowNewMaximizedView(),
|
||
247 | true,
|
||
248 | 44075 | jjdelcerro | 750
|
249 | 43095 | jjdelcerro | ); |
250 | } |
||
251 | 44075 | jjdelcerro | pluginManager.addStartupTask("OpenLayerOnStart", new OpenLayerOnStart(), true, 740); |
252 | 44404 | omartinez | |
253 | 44075 | jjdelcerro | pluginManager.addStartupTask("ApplicationStartedMessage", new Runnable() { |
254 | @Override
|
||
255 | public void run() { |
||
256 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
257 | ApplicationManager application = ApplicationLocator.getManager(); |
||
258 | application.message( |
||
259 | 44404 | omartinez | i18n.getTranslation("StatusBar.Aplicacion_iniciada"),
|
260 | 44075 | jjdelcerro | JOptionPane.INFORMATION_MESSAGE
|
261 | ); |
||
262 | } |
||
263 | }, true, -1); |
||
264 | 43095 | jjdelcerro | |
265 | 44704 | jjdelcerro | pluginManager.addStartupTask("ConnectoToDefaultWorkspace", () -> {
|
266 | connectToDefaultWorkspace(); |
||
267 | }, false, 500); |
||
268 | 41913 | jjdelcerro | } |
269 | |||
270 | 44704 | jjdelcerro | private void connectToDefaultWorkspace() { |
271 | String workspaceName = null; |
||
272 | try {
|
||
273 | DataManager dataManager = DALLocator.getDataManager(); |
||
274 | PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
||
275 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
276 | DynObject preferences = plugin.getPluginProperties(); |
||
277 | if ((Boolean) (preferences.getDynValue("connectAutomaticallyToDatabaseWorkspace"))) { |
||
278 | workspaceName = (String) preferences.getDynValue("databaseWorkspaceToConnect"); |
||
279 | DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
||
280 | DataServerExplorerPoolEntry entry = pool.get(workspaceName); |
||
281 | if (entry != null) { |
||
282 | DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager( |
||
283 | entry.getExplorerParameters() |
||
284 | ); |
||
285 | 44728 | jjdelcerro | if (workspace != null && workspace.isValid() ) { |
286 | workspace.connect(); |
||
287 | 44704 | jjdelcerro | } |
288 | } |
||
289 | } |
||
290 | } catch (Exception ex) { |
||
291 | LOGGER.warn("Can't connect to default workspace ("+Objects.toString(workspaceName)+").", ex); |
||
292 | } |
||
293 | } |
||
294 | |||
295 | 41913 | jjdelcerro | private void showAddOnManagerOnStartIfNeed() { |
296 | 41620 | jjdelcerro | PluginsManager pluginManager = PluginsLocator.getManager(); |
297 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
298 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
299 | 43095 | jjdelcerro | Map<String, Boolean> showAddOnmanagerOnStart = null; |
300 | 41735 | jjdelcerro | try {
|
301 | 43095 | jjdelcerro | showAddOnmanagerOnStart = (Map<String, Boolean>) pluginProperties.getDynValue("showAddOnmanagerOnStart"); |
302 | } catch (Exception ex) { |
||
303 | 41735 | jjdelcerro | // Do nothing
|
304 | } |
||
305 | 43095 | jjdelcerro | if (showAddOnmanagerOnStart == null) { |
306 | showAddOnmanagerOnStart = new HashMap<>(); |
||
307 | pluginProperties.setDynValue("showAddOnmanagerOnStart", showAddOnmanagerOnStart);
|
||
308 | 41735 | jjdelcerro | } |
309 | 43095 | jjdelcerro | Boolean showAddOnmanagerOnStartForCurrentVersion = showAddOnmanagerOnStart.get(pluginManager.getApplicationVersion().fullFormat());
|
310 | |||
311 | if (showAddOnmanagerOnStartForCurrentVersion == null || showAddOnmanagerOnStartForCurrentVersion) { |
||
312 | 41620 | jjdelcerro | pluginManager.addStartupTask( |
313 | 43095 | jjdelcerro | "showAddOnmanagerOnStart",
|
314 | 41620 | jjdelcerro | new ShowAddOnManagerOnStart(),
|
315 | 43095 | jjdelcerro | true,
|
316 | 41620 | jjdelcerro | 500
|
317 | ); |
||
318 | } |
||
319 | 41576 | jjdelcerro | } |
320 | 43095 | jjdelcerro | |
321 | private static class ShowNewMaximizedView implements Runnable { |
||
322 | |||
323 | @Override
|
||
324 | public void run() { |
||
325 | ApplicationManager application = ApplicationLocator.getManager(); |
||
326 | ProjectManager projectManager = application.getProjectManager(); |
||
327 | |||
328 | ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
||
329 | ViewDocument view = (ViewDocument) viewManager.createDocument(); |
||
330 | projectManager.getCurrentProject().add(view); |
||
331 | |||
332 | IView viewWindow = (IView) viewManager.getMainWindow(view); |
||
333 | |||
334 | application.getUIManager().addWindow(viewWindow, GridBagConstraints.CENTER);
|
||
335 | try {
|
||
336 | application.getUIManager().setMaximum((IWindow) viewWindow, true);
|
||
337 | } catch (PropertyVetoException e) { |
||
338 | 44704 | jjdelcerro | LOGGER.info("Can't maximize view.", e);
|
339 | 43095 | jjdelcerro | } |
340 | } |
||
341 | |||
342 | } |
||
343 | |||
344 | 41620 | jjdelcerro | private static class ShowAddOnManagerOnStart implements Runnable { |
345 | |||
346 | 43095 | jjdelcerro | @Override
|
347 | 41620 | jjdelcerro | public void run() { |
348 | ApplicationManager application = ApplicationLocator.getManager(); |
||
349 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
350 | PluginsManager pluginManager = PluginsLocator.getManager(); |
||
351 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
352 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
353 | |||
354 | 41723 | jjdelcerro | String msg = i18nManager.getTranslation("_Instalar_complementos_adicionales_no_disponibles_durante_el_proceso_de_instalacion"); |
355 | 41620 | jjdelcerro | int resp = application.confirmDialog(
|
356 | 43095 | jjdelcerro | msg, |
357 | i18nManager.getTranslation("_Finalizando_proceso_de_instalacion"),
|
||
358 | JOptionPane.YES_NO_OPTION,
|
||
359 | 41620 | jjdelcerro | JOptionPane.QUESTION_MESSAGE
|
360 | ); |
||
361 | 43095 | jjdelcerro | if (resp == JOptionPane.YES_OPTION) { |
362 | 41620 | jjdelcerro | ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
363 | actionManager.execute( |
||
364 | "tools-addonsmanager",
|
||
365 | 43095 | jjdelcerro | new Object[]{"skipBundleSelection"} |
366 | 41620 | jjdelcerro | ); |
367 | } |
||
368 | 43095 | jjdelcerro | Map<String, Boolean> showAddOnmanagerOnStart = (Map<String, Boolean>) pluginProperties.getDynValue("showAddOnmanagerOnStart"); |
369 | 41735 | jjdelcerro | showAddOnmanagerOnStart.put(pluginManager.getApplicationVersion().fullFormat(), Boolean.FALSE);
|
370 | 41620 | jjdelcerro | } |
371 | } |
||
372 | 43095 | jjdelcerro | |
373 | 41576 | jjdelcerro | private void registerIcons() { |
374 | IconThemeHelper.registerIcon("action", "edit-clear", this); |
||
375 | IconThemeHelper.registerIcon("action", "edit-copy", this); |
||
376 | IconThemeHelper.registerIcon("action", "edit-cut", this); |
||
377 | IconThemeHelper.registerIcon("action", "edit-delete", this); |
||
378 | IconThemeHelper.registerIcon("action", "edit-find", this); |
||
379 | IconThemeHelper.registerIcon("action", "edit-find-replace", this); |
||
380 | IconThemeHelper.registerIcon("action", "edit-paste", this); |
||
381 | IconThemeHelper.registerIcon("action", "edit-redo", this); |
||
382 | IconThemeHelper.registerIcon("action", "edit-select-all", this); |
||
383 | IconThemeHelper.registerIcon("action", "edit-undo", this); |
||
384 | IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this); |
||
385 | IconThemeHelper.registerIcon("action", "document-print", this); |
||
386 | 40435 | jjdelcerro | |
387 | 41576 | jjdelcerro | IconThemeHelper.registerIcon("toolbar-go", "go-next", this); |
388 | IconThemeHelper.registerIcon("toolbar-go", "go-previous", this); |
||
389 | IconThemeHelper.registerIcon("toolbar-go", "go-next-fast", this); |
||
390 | IconThemeHelper.registerIcon("toolbar-go", "go-previous-fast", this); |
||
391 | IconThemeHelper.registerIcon("toolbar-go", "go-first", this); |
||
392 | IconThemeHelper.registerIcon("toolbar-go", "go-last", this); |
||
393 | 40435 | jjdelcerro | |
394 | 41576 | jjdelcerro | } |
395 | 40435 | jjdelcerro | |
396 | 43095 | jjdelcerro | @Override
|
397 | 41576 | jjdelcerro | public void execute(String actionCommand) { |
398 | 40435 | jjdelcerro | |
399 | 41576 | jjdelcerro | } |
400 | 40435 | jjdelcerro | |
401 | 43095 | jjdelcerro | @Override
|
402 | 41576 | jjdelcerro | public boolean isEnabled() { |
403 | return false; |
||
404 | } |
||
405 | 40435 | jjdelcerro | |
406 | 43095 | jjdelcerro | @Override
|
407 | 41576 | jjdelcerro | public boolean isVisible() { |
408 | return false; |
||
409 | } |
||
410 | 40435 | jjdelcerro | |
411 | 41576 | jjdelcerro | private void addToLogInfo() { |
412 | String info[] = this.getStringInfo().split("\n"); |
||
413 | 43095 | jjdelcerro | for (String line : info) { |
414 | 44704 | jjdelcerro | LOGGER.info(line); |
415 | 41576 | jjdelcerro | } |
416 | } |
||
417 | 40435 | jjdelcerro | |
418 | 41576 | jjdelcerro | public String getStringInfo() { |
419 | ApplicationManager application = ApplicationLocator.getManager(); |
||
420 | PluginsManager pluginmgr = PluginsLocator.getManager(); |
||
421 | InstallerManager installmgr = InstallerLocator.getInstallerManager(); |
||
422 | 40435 | jjdelcerro | |
423 | 41576 | jjdelcerro | StringWriter writer = new StringWriter(); |
424 | 40435 | jjdelcerro | |
425 | 41576 | jjdelcerro | Properties props = System.getProperties(); |
426 | 40435 | jjdelcerro | |
427 | 41576 | jjdelcerro | // OS information
|
428 | String osName = props.getProperty("os.name"); |
||
429 | writer.write("OS\n");
|
||
430 | writer.write(" name : " + osName + "\n"); |
||
431 | writer.write(" arch : " + props.get("os.arch") + "\n"); |
||
432 | writer.write(" version: " + props.get("os.version") + "\n"); |
||
433 | if (osName.startsWith("Linux")) { |
||
434 | try {
|
||
435 | String[] command = {"lsb_release", "-a"}; |
||
436 | Process p = Runtime.getRuntime().exec(command); |
||
437 | InputStream is = p.getInputStream();
|
||
438 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
||
439 | String line;
|
||
440 | while ((line = reader.readLine()) != null) { |
||
441 | writer.write(" " + line + "\n"); |
||
442 | } |
||
443 | } catch (Exception ex) { |
||
444 | writer.write("Can't get detailled os information (lsb_release -a).");
|
||
445 | } |
||
446 | } |
||
447 | 40435 | jjdelcerro | |
448 | 41576 | jjdelcerro | // JRE information
|
449 | writer.write("JRE\n");
|
||
450 | writer.write(" vendor : " + props.get("java.vendor") + "\n"); |
||
451 | writer.write(" version: " + props.get("java.version") + "\n"); |
||
452 | writer.write(" home : " + props.get("java.home") + "\n"); |
||
453 | 40435 | jjdelcerro | |
454 | 41576 | jjdelcerro | writer.write("gvSIG\n");
|
455 | writer.write(" version : " + application.getVersion().getLongFormat() + "\n"); |
||
456 | writer.write(" locale language : " + application.getLocaleLanguage() + "\n"); |
||
457 | writer.write(" application forlder : " + pluginmgr.getApplicationFolder() + "\n"); |
||
458 | writer.write(" install forlder : " + pluginmgr.getInstallFolder() + "\n"); |
||
459 | writer.write(" application home forlder: " + pluginmgr.getApplicationHomeFolder() + "\n"); |
||
460 | 41706 | jjdelcerro | writer.write(" plugins forlder : " + StringUtils.join(pluginmgr.getPluginsFolders()) + "\n"); |
461 | 41576 | jjdelcerro | |
462 | try {
|
||
463 | 41706 | jjdelcerro | PackageInfo[] pkgs = installmgr.getInstalledPackages();
|
464 | 41576 | jjdelcerro | writer.write("Installed packages\n");
|
465 | 43095 | jjdelcerro | for (PackageInfo pkg : pkgs) {
|
466 | 41576 | jjdelcerro | writer.write(" ");
|
467 | 43095 | jjdelcerro | writer.write(pkg.toStringCompact()); |
468 | 41576 | jjdelcerro | writer.write("\n");
|
469 | } |
||
470 | } catch (Throwable e) { |
||
471 | writer.write("Can't get installed package information.");
|
||
472 | } |
||
473 | return writer.toString();
|
||
474 | } |
||
475 | |||
476 | 43095 | jjdelcerro | @Override
|
477 | 41576 | jjdelcerro | public void terminate() { |
478 | ResourceManager resMan = DALLocator.getResourceManager(); |
||
479 | resMan.stopResourceCollector(); |
||
480 | try {
|
||
481 | resMan.dispose(); |
||
482 | } catch (DisposeResorceManagerException e) {
|
||
483 | 44704 | jjdelcerro | LOGGER.warn(e.getMessageStack()); |
484 | 41576 | jjdelcerro | } |
485 | super.terminate();
|
||
486 | } |
||
487 | 40435 | jjdelcerro | } |