gvsig-educa / org.gvsig.educa.portableview / trunk / org.gvsig.educa.portableview / org.gvsig.educa.portableview.app / org.gvsig.educa.portableview.app.viewer / src / main / java / org / gvsig / educa / portableview / app / viewer / PortableViewExtension.java @ 403
History | View | Annotate | Download (4.87 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.educa.portableview.app.viewer; |
23 |
|
24 |
import java.io.File; |
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.about.AboutManager; |
29 |
import org.gvsig.about.AboutParticipant; |
30 |
import org.gvsig.andami.PluginServices; |
31 |
import org.gvsig.andami.plugins.Extension; |
32 |
import org.gvsig.app.ApplicationLocator; |
33 |
import org.gvsig.app.ApplicationManager; |
34 |
import org.gvsig.educa.portableview.PortableViewLocator; |
35 |
import org.gvsig.educa.portableview.PortableViewManager; |
36 |
import org.gvsig.educa.portableview.app.viewer.ui.TocImageProvider; |
37 |
import org.gvsig.educa.portableview.swing.PortableViewSwingLocator; |
38 |
import org.gvsig.educa.portableview.swing.PortableViewSwingManager; |
39 |
import org.gvsig.installer.lib.api.InstallerLocator; |
40 |
import org.gvsig.installer.lib.api.InstallerManager; |
41 |
|
42 |
/**
|
43 |
* Andami extension to show PortableView in the application.
|
44 |
*
|
45 |
* @author gvSIG Team
|
46 |
* @version $Id$
|
47 |
*/
|
48 |
public class PortableViewExtension extends Extension { |
49 |
|
50 |
private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory |
51 |
.getLogger(PortableViewExtension.class); |
52 |
|
53 |
private PortableViewManager manager;
|
54 |
private PortableViewSwingManager swingManager;
|
55 |
|
56 |
public void initialize() { |
57 |
// Do nothing
|
58 |
} |
59 |
|
60 |
@Override
|
61 |
public void postInitialize() { |
62 |
super.postInitialize();
|
63 |
manager = PortableViewLocator.getManager(); |
64 |
swingManager = PortableViewSwingLocator.getSwingManager(); |
65 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
66 |
|
67 |
// Register the document's manager
|
68 |
PortableViewDocumentManager.register(); |
69 |
|
70 |
File appUserFolder =
|
71 |
PluginServices.getPluginServices(this).getPluginHomeFolder();
|
72 |
File portableViewIntallFolder = new File(appUserFolder, "portableViews"); |
73 |
LOG.debug("Try Portable View instalation folder: '{}'",
|
74 |
portableViewIntallFolder.getAbsolutePath()); |
75 |
if (!portableViewIntallFolder.exists()) {
|
76 |
LOG.debug("Creating Portable View instalation folder: '{}'",
|
77 |
portableViewIntallFolder.getAbsolutePath()); |
78 |
|
79 |
if (!portableViewIntallFolder.mkdirs()) {
|
80 |
LOG.warn("Cant create Portable View folder: '{}'");
|
81 |
} |
82 |
|
83 |
} |
84 |
LOG.info("Using Portable View instalation folder: '{}'",
|
85 |
portableViewIntallFolder.getAbsolutePath()); |
86 |
manager.setInstallationMapFolder(portableViewIntallFolder |
87 |
.getAbsolutePath()); |
88 |
|
89 |
swingManager.setDefaultTocImageProvider(new TocImageProvider());
|
90 |
|
91 |
installerManager.setDefaultLocalAddonRepository( |
92 |
new File(manager.getInstallationMapFolder()), |
93 |
PortableViewManager.INSTALLER_PROVIDER_NAME |
94 |
); |
95 |
|
96 |
registerAbout(); |
97 |
|
98 |
} |
99 |
|
100 |
/**
|
101 |
*
|
102 |
*/
|
103 |
private void registerAbout() { |
104 |
// Register the about panel
|
105 |
ApplicationManager application = ApplicationLocator.getManager(); |
106 |
|
107 |
AboutManager about = application.getAbout(); |
108 |
|
109 |
List<AboutParticipant> participants = new ArrayList<AboutParticipant>(); |
110 |
|
111 |
participants.add(about.addDeveloper("DISID", this.getClass() |
112 |
.getClassLoader().getResource("about/disid.html"), 1)); |
113 |
|
114 |
participants.add(about.addDeveloper("UdelaR.uy", this.getClass() |
115 |
.getClassLoader().getResource("about/universidad.edu.uy.html"), 1)); |
116 |
|
117 |
participants.add(about.addSponsor("MTOP.gub.uy", this.getClass() |
118 |
.getClassLoader().getResource("about/MTOP.html"), 1)); |
119 |
|
120 |
for (AboutParticipant participant : participants) {
|
121 |
participant |
122 |
.addContribution( |
123 |
"PortableViewExtension",
|
124 |
"Portable View document: read-only views which could share in packages (installed from standard gvSIG add-on installer)",
|
125 |
2011, 11, 1, 2012, 2, 29); |
126 |
} |
127 |
|
128 |
} |
129 |
|
130 |
public void execute(String actionCommand) { |
131 |
// TODO
|
132 |
} |
133 |
|
134 |
public boolean isEnabled() { |
135 |
return true; |
136 |
} |
137 |
|
138 |
public boolean isVisible() { |
139 |
return true; |
140 |
} |
141 |
|
142 |
} |