gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.swing / org.gvsig.vcsgis.swing.impl / src / main / java / org / gvsig / vcsgis / swing / impl / VCSGisSwingManagerImpl.java @ 3603
History | View | Annotate | Download (7.43 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright (c) 2007-2020 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.vcsgis.swing.impl; |
24 |
|
25 |
import java.net.URL; |
26 |
import javax.swing.ImageIcon; |
27 |
import javax.swing.JButton; |
28 |
import javax.swing.JComboBox; |
29 |
import org.apache.commons.io.FilenameUtils; |
30 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
31 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
32 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
33 |
import org.gvsig.vcsgis.lib.VCSGisLocator; |
34 |
import static org.gvsig.vcsgis.lib.VCSGisManager.STATE_UNKNOWN; |
35 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
36 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
37 |
import org.gvsig.vcsgis.swing.VCSGisJAddToWorkspace; |
38 |
import org.gvsig.vcsgis.swing.VCSGisJChanges; |
39 |
import org.gvsig.vcsgis.swing.VCSGisJCheckout; |
40 |
import org.gvsig.vcsgis.swing.VCSGisJCheckoutDataModel; |
41 |
import org.gvsig.vcsgis.swing.VCSGisJCreateResourceTable; |
42 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
43 |
import org.gvsig.vcsgis.swing.VCSGisJImportHistory; |
44 |
import org.gvsig.vcsgis.swing.VCSGisJInitServer; |
45 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
46 |
import org.gvsig.vcsgis.swing.VCSGisJLogout; |
47 |
import org.gvsig.vcsgis.swing.VCSGisJRegisterWorkspace; |
48 |
import org.gvsig.vcsgis.swing.VCSGisJRevisions; |
49 |
import org.gvsig.vcsgis.swing.VCSGisJShowServerTableForm; |
50 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
51 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
52 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.getHTMLColorTag; |
53 |
import org.gvsig.vcsgis.swing.impl.addToWorkspace.VCSGisJAddToWorkspaceImpl; |
54 |
import org.gvsig.vcsgis.swing.impl.changes.VCSGisJChangesImpl; |
55 |
import org.gvsig.vcsgis.swing.impl.checkout.VCSGisJCheckoutImpl; |
56 |
import org.gvsig.vcsgis.swing.impl.checkoutDataModel.VCSGisJCheckoutDataModelImpl; |
57 |
import org.gvsig.vcsgis.swing.impl.export.VCSGisJExportImpl; |
58 |
import org.gvsig.vcsgis.swing.impl.importhistory.ImportHistoryImpl; |
59 |
import org.gvsig.vcsgis.swing.impl.initserver.VCSGisJInitServerImpl; |
60 |
import org.gvsig.vcsgis.swing.impl.initworkspace.VCSGisJInitWorkspaceImpl; |
61 |
import org.gvsig.vcsgis.swing.impl.loggin.VCSGisUserIdentificationRequesterDialog; |
62 |
import org.gvsig.vcsgis.swing.impl.logout.VCSGisJLogoutImpl; |
63 |
import org.gvsig.vcsgis.swing.impl.registerWorkspace.VCSGisJRegisterWorkspaceImpl; |
64 |
import org.gvsig.vcsgis.swing.impl.resourceTable.VCSGisJCreateResourceTableImpl; |
65 |
import org.gvsig.vcsgis.swing.impl.revisions.VCSGisJRevisionsImpl; |
66 |
import org.gvsig.vcsgis.swing.impl.showServerTableForm.VCSGisJShowServerTableFormImpl; |
67 |
|
68 |
/**
|
69 |
* @author gvSIG Team
|
70 |
*
|
71 |
*/
|
72 |
public class VCSGisSwingManagerImpl implements VCSGisSwingManager { |
73 |
|
74 |
public static final String ICON_COMMON_GROUP_NAME = "Common"; |
75 |
public static final String ICON_GROUP_NAME = "VCSGis"; |
76 |
public static final String ICON_PROVIDER_NAME = "VCSGis"; |
77 |
|
78 |
private VCSGisSwingServices services;
|
79 |
|
80 |
public VCSGisSwingManagerImpl() {
|
81 |
VCSGisLocator.getVCSGisManager().setUserIdentificationRequester( |
82 |
new VCSGisUserIdentificationRequesterDialog()
|
83 |
); |
84 |
} |
85 |
|
86 |
public static void registerIcons(String[][] iconsInfo) { |
87 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
88 |
for (String[] icon : iconsInfo) { |
89 |
// 0 - Provider, 1 - Group, 2 - Name
|
90 |
URL url = VCSGisSwingManagerImpl.class.getResource("images/"+ icon[2] + ".png"); |
91 |
theme.registerDefault(icon[0], icon[1], icon[2], null, url); |
92 |
} |
93 |
} |
94 |
|
95 |
public static ImageIcon loadImage(String imageName) { |
96 |
String name = FilenameUtils.getBaseName(imageName);
|
97 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
98 |
if (theme.exists(name)) {
|
99 |
return theme.get(name);
|
100 |
} |
101 |
URL url = VCSGisSwingManagerImpl.class.getResource("images/"+name + ".png"); |
102 |
if (url == null) { |
103 |
return null; |
104 |
} |
105 |
return new ImageIcon(url); |
106 |
} |
107 |
|
108 |
@Override
|
109 |
public VCSGisJChanges createChangesPanel() {
|
110 |
return new VCSGisJChangesImpl(); |
111 |
} |
112 |
|
113 |
@Override
|
114 |
public PickerController<VCSGisWorkspace> createPickerWorkspaceController(JComboBox combo) { |
115 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
116 |
} |
117 |
|
118 |
@Override
|
119 |
public VCSGisJInitServer createInitRepositoryPanel() {
|
120 |
return new VCSGisJInitServerImpl(); |
121 |
} |
122 |
|
123 |
@Override
|
124 |
public VCSGisJInitWorkspace createInitWorkspacePanel() {
|
125 |
return new VCSGisJInitWorkspaceImpl(); |
126 |
} |
127 |
|
128 |
@Override
|
129 |
public VCSGisJAddToWorkspace createAddToWorkspacePanel() {
|
130 |
return new VCSGisJAddToWorkspaceImpl(); |
131 |
} |
132 |
|
133 |
@Override
|
134 |
public VCSGisJCheckout createCheckoutPanel() {
|
135 |
return new VCSGisJCheckoutImpl(); |
136 |
} |
137 |
|
138 |
@Override
|
139 |
public VCSGisJCheckoutDataModel createCheckoutDataModelPanel() {
|
140 |
return new VCSGisJCheckoutDataModelImpl(); |
141 |
} |
142 |
|
143 |
@Override
|
144 |
public VCSGisJExport createExportPanel() {
|
145 |
return new VCSGisJExportImpl(); |
146 |
} |
147 |
|
148 |
@Override
|
149 |
public void setDefaultServices(VCSGisSwingServices services) { |
150 |
this.services = services;
|
151 |
} |
152 |
|
153 |
@Override
|
154 |
public VCSGisSwingServices getDefaultServices() {
|
155 |
return this.services; |
156 |
} |
157 |
|
158 |
@Override
|
159 |
public PickerController<VCSGisWorkspace> createWorkspacePickerController(JComboBox combo, JButton button) { |
160 |
return new VCSWorkspacePickerControllerImpl(combo, button); |
161 |
} |
162 |
|
163 |
@Override
|
164 |
public VCSGisJRegisterWorkspace createRegisterWorkspacePanel() {
|
165 |
return new VCSGisJRegisterWorkspaceImpl(); |
166 |
} |
167 |
|
168 |
@Override
|
169 |
public VCSGisJShowServerTableForm createShowTableServerFormPanel(String tableName) { |
170 |
return new VCSGisJShowServerTableFormImpl(tableName); |
171 |
} |
172 |
|
173 |
@Override
|
174 |
public String getHTMLColoredForEntity(VCSGisWorkspaceEntity entity, String name){ |
175 |
return getHTMLColoredForEntity(entity, name, STATE_UNKNOWN);
|
176 |
} |
177 |
|
178 |
@Override
|
179 |
public String getHTMLColoredForEntity(VCSGisWorkspaceEntity entity, String name, int defaultState){ |
180 |
return getHTMLColorTag(
|
181 |
entity == null ? defaultState : entity.getState(),
|
182 |
name |
183 |
); |
184 |
} |
185 |
|
186 |
@Override
|
187 |
public VCSGisJRevisions createRevisionsPanel() {
|
188 |
return new VCSGisJRevisionsImpl(); |
189 |
} |
190 |
|
191 |
@Override
|
192 |
public VCSGisJImportHistory createImportHistoryPanel() {
|
193 |
return new ImportHistoryImpl(); |
194 |
} |
195 |
|
196 |
@Override
|
197 |
public VCSGisJCreateResourceTable createResourceTablePanel() {
|
198 |
return new VCSGisJCreateResourceTableImpl(); |
199 |
} |
200 |
|
201 |
@Override
|
202 |
public VCSGisJLogout createLogoutPanel() {
|
203 |
return new VCSGisJLogoutImpl(); |
204 |
} |
205 |
} |