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 @ 47423
History | View | Annotate | Download (19.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 | 41735 | jjdelcerro | import java.util.HashMap; |
33 | import java.util.Map; |
||
34 | 44704 | jjdelcerro | import java.util.Objects; |
35 | 40435 | jjdelcerro | import java.util.Properties; |
36 | 44238 | jjdelcerro | import java.util.prefs.Preferences; |
37 | 41620 | jjdelcerro | import javax.swing.JOptionPane; |
38 | 41706 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
39 | 40435 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
40 | 41620 | jjdelcerro | import org.gvsig.andami.PluginServices; |
41 | 40435 | jjdelcerro | import org.gvsig.andami.PluginsLocator; |
42 | import org.gvsig.andami.PluginsManager; |
||
43 | 41620 | jjdelcerro | import org.gvsig.andami.actioninfo.ActionInfoManager; |
44 | 40435 | jjdelcerro | import org.gvsig.andami.plugins.Extension; |
45 | 43095 | jjdelcerro | import org.gvsig.andami.ui.mdiManager.IWindow; |
46 | 40435 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
47 | import org.gvsig.app.ApplicationManager; |
||
48 | 44238 | jjdelcerro | import static org.gvsig.app.extension.ProjectExtension.PROJECT_FILE_CHOOSER_ID; |
49 | 45679 | jjdelcerro | import org.gvsig.app.project.Project; |
50 | 43095 | jjdelcerro | import org.gvsig.app.project.ProjectManager; |
51 | import org.gvsig.app.project.ProjectPreferences; |
||
52 | import org.gvsig.app.project.documents.view.ViewDocument; |
||
53 | import org.gvsig.app.project.documents.view.ViewManager; |
||
54 | import org.gvsig.app.project.documents.view.gui.IView; |
||
55 | 40435 | jjdelcerro | import org.gvsig.app.project.documents.view.toolListeners.InfoListener; |
56 | import org.gvsig.app.util.BaseOpenErrorHandler; |
||
57 | 44404 | omartinez | import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
58 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
59 | 44129 | jjdelcerro | import org.gvsig.fmap.dal.DataManager; |
60 | 44704 | jjdelcerro | import org.gvsig.fmap.dal.DataServerExplorerPool; |
61 | import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
||
62 | import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
||
63 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.OpenErrorHandler; |
64 | import org.gvsig.fmap.dal.resource.ResourceManager; |
||
65 | import org.gvsig.fmap.dal.resource.exception.DisposeResorceManagerException; |
||
66 | 44238 | jjdelcerro | import static org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanelController.OPEN_LAYER_FILE_CHOOSER_ID; |
67 | 40435 | jjdelcerro | import org.gvsig.installer.lib.api.InstallerLocator; |
68 | import org.gvsig.installer.lib.api.InstallerManager; |
||
69 | import org.gvsig.installer.lib.api.PackageInfo; |
||
70 | 41620 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
71 | 47219 | fdiaz | import org.gvsig.tools.dispose.DisposeUtils; |
72 | 41620 | jjdelcerro | import org.gvsig.tools.dynobject.DynObject; |
73 | 44238 | jjdelcerro | import org.gvsig.tools.folders.FoldersManager; |
74 | 41620 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
75 | 44829 | omartinez | import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
76 | 47423 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
77 | import org.gvsig.tools.swing.icontheme.IconTheme; |
||
78 | 40435 | jjdelcerro | import org.slf4j.Logger; |
79 | import org.slf4j.LoggerFactory; |
||
80 | |||
81 | 44704 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
82 | 40435 | jjdelcerro | public class InitializeApplicationExtension extends Extension { |
83 | 41576 | jjdelcerro | |
84 | 44704 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(InitializeApplicationExtension.class); |
85 | 40435 | jjdelcerro | |
86 | 44238 | jjdelcerro | // Copiadas de org.gvsig.coreplugin.PreferencesExtension
|
87 | public static final String PROJECTS_FOLDER_PROPERTY_NAME = "ProjectsFolder"; |
||
88 | public static final String DATA_FOLDER_PROPERTY_NAME = "DataFolder"; |
||
89 | public static final String TEMPLATES_FOLDER_PROPERTY_NAME = "TemplatesFolder"; |
||
90 | public static final String SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME = "SymbolLibraryFolder"; |
||
91 | 40435 | jjdelcerro | |
92 | 44404 | omartinez | private OpenErrorHandler openErrorHandler = null; |
93 | 44238 | jjdelcerro | |
94 | 44189 | jjdelcerro | |
95 | 43095 | jjdelcerro | @Override
|
96 | 41576 | jjdelcerro | public void initialize() { |
97 | 42775 | jjdelcerro | DALLocator.registerFeatureTypeDefinitionsManager(DefaultFeatureTypeDefinitionsManager.class); |
98 | 44404 | omartinez | |
99 | 44750 | jjdelcerro | ExpressionEvaluatorLocator.getManager().registerClassLoader(this.getClass().getClassLoader());
|
100 | 44829 | omartinez | |
101 | 41576 | jjdelcerro | InfoListener.initializeExtensionPoint(); |
102 | 44404 | omartinez | |
103 | 44238 | jjdelcerro | initLastPath(); |
104 | 41576 | jjdelcerro | registerIcons(); |
105 | 44404 | omartinez | } |
106 | 40435 | jjdelcerro | |
107 | 47230 | fdiaz | private void loadHistoryAndBookmarks() { |
108 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
109 | ApplicationManager application = ApplicationLocator.getManager(); |
||
110 | application.message( |
||
111 | i18n.getTranslation("_loading_history_and_bookmarks"),
|
||
112 | JOptionPane.INFORMATION_MESSAGE
|
||
113 | ); |
||
114 | 44829 | omartinez | PluginsManager pluginmgr = PluginsLocator.getManager(); |
115 | 44855 | jjdelcerro | File folder = pluginmgr.getApplicationHomeFolder();
|
116 | 44829 | omartinez | String nameFolder = "bookmarks"; |
117 | |||
118 | 44855 | jjdelcerro | File storageFolder = new File(folder, nameFolder); |
119 | 44829 | omartinez | try {
|
120 | 44855 | jjdelcerro | if (!storageFolder.exists()) {
|
121 | storageFolder.mkdir(); |
||
122 | 44829 | omartinez | } |
123 | } catch (Exception ex) { |
||
124 | LOGGER.warn("Not able to create bookmarks folder. Load and save of bookmarks will be deactivated", ex);
|
||
125 | //Stop trying to load bookmarks and not create listener to save them
|
||
126 | return;
|
||
127 | } |
||
128 | 44855 | jjdelcerro | FilesResourcesStorage bookmarksResources = new FilesResourcesStorage(storageFolder.getAbsolutePath());
|
129 | ToolsLocator.getBookmarksAndHistoryManager().setPrimaryStorage(bookmarksResources); |
||
130 | 44829 | omartinez | ToolsLocator.getBookmarksAndHistoryManager().load(); |
131 | PluginsManager pluginManager = PluginsLocator.getManager(); |
||
132 | 44855 | jjdelcerro | pluginManager.addShutdownTask("saveBookmarksAndHistory", () -> {
|
133 | ToolsLocator.getBookmarksAndHistoryManager().save(); |
||
134 | 44829 | omartinez | }, false, 100); |
135 | |||
136 | } |
||
137 | |||
138 | 44238 | jjdelcerro | private void initLastPath() { |
139 | 44404 | omartinez | Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
140 | 44238 | jjdelcerro | FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
141 | String v;
|
||
142 | 44404 | omartinez | |
143 | 44238 | jjdelcerro | v = prefs.get(DATA_FOLDER_PROPERTY_NAME, folderManager.getHome().getAbsolutePath()); |
144 | folderManager.setLastPath(OPEN_LAYER_FILE_CHOOSER_ID, new File(v)); |
||
145 | 40435 | jjdelcerro | |
146 | 44238 | jjdelcerro | v = prefs.get(PROJECTS_FOLDER_PROPERTY_NAME, folderManager.getHome().getAbsolutePath()); |
147 | folderManager.setLastPath(PROJECT_FILE_CHOOSER_ID, new File(v)); |
||
148 | |||
149 | v = prefs.get("LegendsFolder", folderManager.getHome().getAbsolutePath());
|
||
150 | folderManager.setLastPath("LegendsFolder", new File(v)); |
||
151 | 46643 | jjdelcerro | |
152 | try {
|
||
153 | PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
||
154 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
155 | DynObject preferences = plugin.getPluginProperties(); |
||
156 | Map<String,String>paths = (Map<String,String>) preferences.getDynValue("folderManagerPaths"); |
||
157 | if( paths!=null ) { |
||
158 | for (Map.Entry<String, String> path : paths.entrySet()) { |
||
159 | String name = path.getKey();
|
||
160 | String path_s = path.getValue();
|
||
161 | folderManager.set(name, new File(path_s)); |
||
162 | } |
||
163 | } |
||
164 | pluginManager.addShutdownTask("saveFolderManagerPaths", () -> {
|
||
165 | doFolderManagerPaths(); |
||
166 | }, false, 100); |
||
167 | } catch (Exception ex) { |
||
168 | LOGGER.warn("Can't restore folder manager paths.", ex);
|
||
169 | } |
||
170 | |||
171 | 44238 | jjdelcerro | } |
172 | |||
173 | 43095 | jjdelcerro | @Override
|
174 | 41576 | jjdelcerro | public void postInitialize() { |
175 | 43095 | jjdelcerro | PluginsManager pluginManager = PluginsLocator.getManager(); |
176 | |||
177 | 40435 | jjdelcerro | openErrorHandler = new BaseOpenErrorHandler();
|
178 | ApplicationLocator.getManager().getDataManager().setOpenErrorHandler(openErrorHandler); |
||
179 | 41564 | jjdelcerro | |
180 | 41576 | jjdelcerro | DALLocator.getResourceManager().startResourceCollector( |
181 | 3 * (60 * 1000), // minutes --> miliseconds |
||
182 | null);
|
||
183 | 43095 | jjdelcerro | |
184 | 41913 | jjdelcerro | // showAddOnManagerOnStartIfNeed();
|
185 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
186 | if (projectPreferences.getOpenWithANewMaximizedView()) {
|
||
187 | pluginManager.addStartupTask( |
||
188 | "showNewViewMaximized",
|
||
189 | new ShowNewMaximizedView(),
|
||
190 | true,
|
||
191 | 44075 | jjdelcerro | 750
|
192 | 43095 | jjdelcerro | ); |
193 | } |
||
194 | 44075 | jjdelcerro | pluginManager.addStartupTask("OpenLayerOnStart", new OpenLayerOnStart(), true, 740); |
195 | 44404 | omartinez | |
196 | 44075 | jjdelcerro | pluginManager.addStartupTask("ApplicationStartedMessage", new Runnable() { |
197 | @Override
|
||
198 | public void run() { |
||
199 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
200 | ApplicationManager application = ApplicationLocator.getManager(); |
||
201 | application.message( |
||
202 | 44404 | omartinez | i18n.getTranslation("StatusBar.Aplicacion_iniciada"),
|
203 | 44075 | jjdelcerro | JOptionPane.INFORMATION_MESSAGE
|
204 | ); |
||
205 | } |
||
206 | }, true, -1); |
||
207 | 43095 | jjdelcerro | |
208 | 44704 | jjdelcerro | pluginManager.addStartupTask("ConnectoToDefaultWorkspace", () -> {
|
209 | 44829 | omartinez | connectToDefaultWorkspace(); |
210 | 44704 | jjdelcerro | }, false, 500); |
211 | 45654 | jolivas | |
212 | pluginManager.addStartupTask("InitilizeHistoryAndBookmarks", new Runnable() { |
||
213 | @Override
|
||
214 | public void run() { |
||
215 | loadHistoryAndBookmarks(); |
||
216 | } |
||
217 | 47230 | fdiaz | }, false, 100); |
218 | 41913 | jjdelcerro | } |
219 | |||
220 | 44704 | jjdelcerro | private void connectToDefaultWorkspace() { |
221 | 44829 | omartinez | String workspaceName = null; |
222 | try {
|
||
223 | DataManager dataManager = DALLocator.getDataManager(); |
||
224 | PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
||
225 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
226 | DynObject preferences = plugin.getPluginProperties(); |
||
227 | if ((Boolean) (preferences.getDynValue("connectAutomaticallyToDatabaseWorkspace"))) { |
||
228 | workspaceName = (String) preferences.getDynValue("databaseWorkspaceToConnect"); |
||
229 | DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
||
230 | DataServerExplorerPoolEntry entry = pool.get(workspaceName); |
||
231 | if (entry != null) { |
||
232 | 47230 | fdiaz | |
233 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
234 | ApplicationManager application = ApplicationLocator.getManager(); |
||
235 | application.message( |
||
236 | i18n.getTranslation("_connecting_to_repository")+" ("+workspaceName+")", |
||
237 | JOptionPane.INFORMATION_MESSAGE
|
||
238 | ); |
||
239 | |||
240 | 44829 | omartinez | DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager( |
241 | entry.getExplorerParameters() |
||
242 | ); |
||
243 | if (workspace != null && workspace.isValid()) { |
||
244 | workspace.connect(); |
||
245 | } |
||
246 | } |
||
247 | 44704 | jjdelcerro | } |
248 | 44829 | omartinez | } catch (Exception ex) { |
249 | LOGGER.warn("Can't connect to default workspace (" + Objects.toString(workspaceName) + ").", ex); |
||
250 | 44704 | jjdelcerro | } |
251 | } |
||
252 | 44829 | omartinez | |
253 | 41913 | jjdelcerro | private void showAddOnManagerOnStartIfNeed() { |
254 | 41620 | jjdelcerro | PluginsManager pluginManager = PluginsLocator.getManager(); |
255 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
256 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
257 | 43095 | jjdelcerro | Map<String, Boolean> showAddOnmanagerOnStart = null; |
258 | 41735 | jjdelcerro | try {
|
259 | 43095 | jjdelcerro | showAddOnmanagerOnStart = (Map<String, Boolean>) pluginProperties.getDynValue("showAddOnmanagerOnStart"); |
260 | } catch (Exception ex) { |
||
261 | 41735 | jjdelcerro | // Do nothing
|
262 | } |
||
263 | 43095 | jjdelcerro | if (showAddOnmanagerOnStart == null) { |
264 | showAddOnmanagerOnStart = new HashMap<>(); |
||
265 | pluginProperties.setDynValue("showAddOnmanagerOnStart", showAddOnmanagerOnStart);
|
||
266 | 41735 | jjdelcerro | } |
267 | 43095 | jjdelcerro | Boolean showAddOnmanagerOnStartForCurrentVersion = showAddOnmanagerOnStart.get(pluginManager.getApplicationVersion().fullFormat());
|
268 | |||
269 | if (showAddOnmanagerOnStartForCurrentVersion == null || showAddOnmanagerOnStartForCurrentVersion) { |
||
270 | 41620 | jjdelcerro | pluginManager.addStartupTask( |
271 | 43095 | jjdelcerro | "showAddOnmanagerOnStart",
|
272 | 41620 | jjdelcerro | new ShowAddOnManagerOnStart(),
|
273 | 43095 | jjdelcerro | true,
|
274 | 41620 | jjdelcerro | 500
|
275 | ); |
||
276 | } |
||
277 | 41576 | jjdelcerro | } |
278 | 43095 | jjdelcerro | |
279 | 46643 | jjdelcerro | private void doFolderManagerPaths() { |
280 | FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
||
281 | PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
||
282 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
283 | DynObject preferences = plugin.getPluginProperties(); |
||
284 | |||
285 | Map<String,String> paths = new HashMap<>(); |
||
286 | for (String name: folderManager) { |
||
287 | File f = folderManager.get(name);
|
||
288 | if( f!=null ) { |
||
289 | paths.put(name, f.getAbsolutePath()); |
||
290 | } |
||
291 | } |
||
292 | preferences.setDynValue("folderManagerPaths",paths);
|
||
293 | } |
||
294 | |||
295 | 43095 | jjdelcerro | private static class ShowNewMaximizedView implements Runnable { |
296 | |||
297 | @Override
|
||
298 | public void run() { |
||
299 | ApplicationManager application = ApplicationLocator.getManager(); |
||
300 | ProjectManager projectManager = application.getProjectManager(); |
||
301 | 45679 | jjdelcerro | Project project = projectManager.getCurrentProject(); |
302 | 43095 | jjdelcerro | |
303 | ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
||
304 | ViewDocument view = (ViewDocument) viewManager.createDocument(); |
||
305 | try {
|
||
306 | 47219 | fdiaz | project.addDocument(view); |
307 | |||
308 | IView viewWindow = (IView) viewManager.getMainWindow(view); |
||
309 | |||
310 | application.getUIManager().addWindow(viewWindow, GridBagConstraints.CENTER);
|
||
311 | try {
|
||
312 | application.getUIManager().setMaximum((IWindow) viewWindow, true);
|
||
313 | } catch (PropertyVetoException e) { |
||
314 | LOGGER.info("Can't maximize view.", e);
|
||
315 | } |
||
316 | project.setModified(false);
|
||
317 | } finally {
|
||
318 | DisposeUtils.disposeQuietly(view); |
||
319 | 43095 | jjdelcerro | } |
320 | } |
||
321 | |||
322 | } |
||
323 | |||
324 | 41620 | jjdelcerro | private static class ShowAddOnManagerOnStart implements Runnable { |
325 | |||
326 | 43095 | jjdelcerro | @Override
|
327 | 41620 | jjdelcerro | public void run() { |
328 | ApplicationManager application = ApplicationLocator.getManager(); |
||
329 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
330 | PluginsManager pluginManager = PluginsLocator.getManager(); |
||
331 | PluginServices plugin = pluginManager.getPlugin(this);
|
||
332 | DynObject pluginProperties = plugin.getPluginProperties(); |
||
333 | |||
334 | 41723 | jjdelcerro | String msg = i18nManager.getTranslation("_Instalar_complementos_adicionales_no_disponibles_durante_el_proceso_de_instalacion"); |
335 | 41620 | jjdelcerro | int resp = application.confirmDialog(
|
336 | 43095 | jjdelcerro | msg, |
337 | i18nManager.getTranslation("_Finalizando_proceso_de_instalacion"),
|
||
338 | JOptionPane.YES_NO_OPTION,
|
||
339 | 41620 | jjdelcerro | JOptionPane.QUESTION_MESSAGE
|
340 | ); |
||
341 | 43095 | jjdelcerro | if (resp == JOptionPane.YES_OPTION) { |
342 | 41620 | jjdelcerro | ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
343 | actionManager.execute( |
||
344 | "tools-addonsmanager",
|
||
345 | 43095 | jjdelcerro | new Object[]{"skipBundleSelection"} |
346 | 41620 | jjdelcerro | ); |
347 | } |
||
348 | 43095 | jjdelcerro | Map<String, Boolean> showAddOnmanagerOnStart = (Map<String, Boolean>) pluginProperties.getDynValue("showAddOnmanagerOnStart"); |
349 | 41735 | jjdelcerro | showAddOnmanagerOnStart.put(pluginManager.getApplicationVersion().fullFormat(), Boolean.FALSE);
|
350 | 41620 | jjdelcerro | } |
351 | } |
||
352 | 43095 | jjdelcerro | |
353 | 41576 | jjdelcerro | private void registerIcons() { |
354 | IconThemeHelper.registerIcon("action", "edit-clear", this); |
||
355 | IconThemeHelper.registerIcon("action", "edit-copy", this); |
||
356 | IconThemeHelper.registerIcon("action", "edit-cut", this); |
||
357 | IconThemeHelper.registerIcon("action", "edit-delete", this); |
||
358 | IconThemeHelper.registerIcon("action", "edit-find", this); |
||
359 | IconThemeHelper.registerIcon("action", "edit-find-replace", this); |
||
360 | IconThemeHelper.registerIcon("action", "edit-paste", this); |
||
361 | IconThemeHelper.registerIcon("action", "edit-redo", this); |
||
362 | IconThemeHelper.registerIcon("action", "edit-select-all", this); |
||
363 | IconThemeHelper.registerIcon("action", "edit-undo", this); |
||
364 | IconThemeHelper.registerIcon("action", "edit-undo-redo-actions", this); |
||
365 | IconThemeHelper.registerIcon("action", "document-print", this); |
||
366 | 40435 | jjdelcerro | |
367 | 47423 | jjdelcerro | IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
368 | iconTheme.setGroupDescription("action", "Images in the 'action' group are associated with menus and toolbar buttons."); |
||
369 | 41576 | jjdelcerro | } |
370 | 40435 | jjdelcerro | |
371 | 43095 | jjdelcerro | @Override
|
372 | 41576 | jjdelcerro | public void execute(String actionCommand) { |
373 | 40435 | jjdelcerro | |
374 | 41576 | jjdelcerro | } |
375 | 40435 | jjdelcerro | |
376 | 43095 | jjdelcerro | @Override
|
377 | 41576 | jjdelcerro | public boolean isEnabled() { |
378 | return false; |
||
379 | } |
||
380 | 40435 | jjdelcerro | |
381 | 43095 | jjdelcerro | @Override
|
382 | 41576 | jjdelcerro | public boolean isVisible() { |
383 | return false; |
||
384 | } |
||
385 | 40435 | jjdelcerro | |
386 | 41576 | jjdelcerro | private void addToLogInfo() { |
387 | String info[] = this.getStringInfo().split("\n"); |
||
388 | 43095 | jjdelcerro | for (String line : info) { |
389 | 44704 | jjdelcerro | LOGGER.info(line); |
390 | 41576 | jjdelcerro | } |
391 | } |
||
392 | 40435 | jjdelcerro | |
393 | 41576 | jjdelcerro | public String getStringInfo() { |
394 | ApplicationManager application = ApplicationLocator.getManager(); |
||
395 | PluginsManager pluginmgr = PluginsLocator.getManager(); |
||
396 | InstallerManager installmgr = InstallerLocator.getInstallerManager(); |
||
397 | 40435 | jjdelcerro | |
398 | 41576 | jjdelcerro | StringWriter writer = new StringWriter(); |
399 | 40435 | jjdelcerro | |
400 | 41576 | jjdelcerro | Properties props = System.getProperties(); |
401 | 40435 | jjdelcerro | |
402 | 41576 | jjdelcerro | // OS information
|
403 | String osName = props.getProperty("os.name"); |
||
404 | writer.write("OS\n");
|
||
405 | writer.write(" name : " + osName + "\n"); |
||
406 | writer.write(" arch : " + props.get("os.arch") + "\n"); |
||
407 | writer.write(" version: " + props.get("os.version") + "\n"); |
||
408 | if (osName.startsWith("Linux")) { |
||
409 | try {
|
||
410 | String[] command = {"lsb_release", "-a"}; |
||
411 | Process p = Runtime.getRuntime().exec(command); |
||
412 | InputStream is = p.getInputStream();
|
||
413 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
||
414 | String line;
|
||
415 | while ((line = reader.readLine()) != null) { |
||
416 | writer.write(" " + line + "\n"); |
||
417 | } |
||
418 | } catch (Exception ex) { |
||
419 | writer.write("Can't get detailled os information (lsb_release -a).");
|
||
420 | } |
||
421 | } |
||
422 | 40435 | jjdelcerro | |
423 | 41576 | jjdelcerro | // JRE information
|
424 | writer.write("JRE\n");
|
||
425 | writer.write(" vendor : " + props.get("java.vendor") + "\n"); |
||
426 | writer.write(" version: " + props.get("java.version") + "\n"); |
||
427 | writer.write(" home : " + props.get("java.home") + "\n"); |
||
428 | 40435 | jjdelcerro | |
429 | 41576 | jjdelcerro | writer.write("gvSIG\n");
|
430 | writer.write(" version : " + application.getVersion().getLongFormat() + "\n"); |
||
431 | writer.write(" locale language : " + application.getLocaleLanguage() + "\n"); |
||
432 | writer.write(" application forlder : " + pluginmgr.getApplicationFolder() + "\n"); |
||
433 | writer.write(" install forlder : " + pluginmgr.getInstallFolder() + "\n"); |
||
434 | writer.write(" application home forlder: " + pluginmgr.getApplicationHomeFolder() + "\n"); |
||
435 | 41706 | jjdelcerro | writer.write(" plugins forlder : " + StringUtils.join(pluginmgr.getPluginsFolders()) + "\n"); |
436 | 41576 | jjdelcerro | |
437 | try {
|
||
438 | 41706 | jjdelcerro | PackageInfo[] pkgs = installmgr.getInstalledPackages();
|
439 | 41576 | jjdelcerro | writer.write("Installed packages\n");
|
440 | 43095 | jjdelcerro | for (PackageInfo pkg : pkgs) {
|
441 | 41576 | jjdelcerro | writer.write(" ");
|
442 | 43095 | jjdelcerro | writer.write(pkg.toStringCompact()); |
443 | 41576 | jjdelcerro | writer.write("\n");
|
444 | } |
||
445 | } catch (Throwable e) { |
||
446 | writer.write("Can't get installed package information.");
|
||
447 | } |
||
448 | return writer.toString();
|
||
449 | } |
||
450 | |||
451 | 43095 | jjdelcerro | @Override
|
452 | 41576 | jjdelcerro | public void terminate() { |
453 | ResourceManager resMan = DALLocator.getResourceManager(); |
||
454 | resMan.stopResourceCollector(); |
||
455 | try {
|
||
456 | resMan.dispose(); |
||
457 | } catch (DisposeResorceManagerException e) {
|
||
458 | 44704 | jjdelcerro | LOGGER.warn(e.getMessageStack()); |
459 | 41576 | jjdelcerro | } |
460 | super.terminate();
|
||
461 | } |
||
462 | 40435 | jjdelcerro | } |