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 @ 3458
History | View | Annotate | Download (6.76 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.VCSGisJCreateResourceTable; |
41 |
import org.gvsig.vcsgis.swing.VCSGisJExport; |
42 |
import org.gvsig.vcsgis.swing.VCSGisJImportHistory; |
43 |
import org.gvsig.vcsgis.swing.VCSGisJInitServer; |
44 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
45 |
import org.gvsig.vcsgis.swing.VCSGisJRegisterWorkspace; |
46 |
import org.gvsig.vcsgis.swing.VCSGisJRevisions; |
47 |
import org.gvsig.vcsgis.swing.VCSGisJShowServerTableForm; |
48 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
49 |
import org.gvsig.vcsgis.swing.VCSGisSwingServices; |
50 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.getHTMLColorTag; |
51 |
import org.gvsig.vcsgis.swing.impl.addToWorkspace.VCSGisJAddToWorkspaceImpl; |
52 |
import org.gvsig.vcsgis.swing.impl.changes.VCSGisJChangesImpl; |
53 |
import org.gvsig.vcsgis.swing.impl.checkout.VCSGisJCheckoutImpl; |
54 |
import org.gvsig.vcsgis.swing.impl.export.VCSGisJExportImpl; |
55 |
import org.gvsig.vcsgis.swing.impl.importhistory.ImportHistoryImpl; |
56 |
import org.gvsig.vcsgis.swing.impl.initserver.VCSGisJInitServerImpl; |
57 |
import org.gvsig.vcsgis.swing.impl.initworkspace.VCSGisJInitWorkspaceImpl; |
58 |
import org.gvsig.vcsgis.swing.impl.loggin.VCSGisUserIdentificationRequesterDialog; |
59 |
import org.gvsig.vcsgis.swing.impl.registerWorkspace.VCSGisJRegisterWorkspaceImpl; |
60 |
import org.gvsig.vcsgis.swing.impl.resourceTable.VCSGisJCreateResourceTableImpl; |
61 |
import org.gvsig.vcsgis.swing.impl.revisions.VCSGisJRevisionsImpl; |
62 |
import org.gvsig.vcsgis.swing.impl.showServerTableForm.VCSGisJShowServerTableFormImpl; |
63 |
|
64 |
/**
|
65 |
* @author gvSIG Team
|
66 |
*
|
67 |
*/
|
68 |
public class VCSGisSwingManagerImpl implements VCSGisSwingManager { |
69 |
|
70 |
public static final String ICON_COMMON_GROUP_NAME = "Common"; |
71 |
public static final String ICON_GROUP_NAME = "VCSGis"; |
72 |
public static final String ICON_PROVIDER_NAME = "VCSGis"; |
73 |
|
74 |
private VCSGisSwingServices services;
|
75 |
|
76 |
public VCSGisSwingManagerImpl() {
|
77 |
VCSGisLocator.getVCSGisManager().setUserIdentificationRequester( |
78 |
new VCSGisUserIdentificationRequesterDialog()
|
79 |
); |
80 |
} |
81 |
|
82 |
public static void registerIcons(String[][] iconsInfo) { |
83 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
84 |
for (String[] icon : iconsInfo) { |
85 |
// 0 - Provider, 1 - Group, 2 - Name
|
86 |
URL url = VCSGisSwingManagerImpl.class.getResource("images/"+ icon[2] + ".png"); |
87 |
theme.registerDefault(icon[0], icon[1], icon[2], null, url); |
88 |
} |
89 |
} |
90 |
|
91 |
public static ImageIcon loadImage(String imageName) { |
92 |
String name = FilenameUtils.getBaseName(imageName);
|
93 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
94 |
if (theme.exists(name)) {
|
95 |
return theme.get(name);
|
96 |
} |
97 |
URL url = VCSGisSwingManagerImpl.class.getResource("images/"+name + ".png"); |
98 |
if (url == null) { |
99 |
return null; |
100 |
} |
101 |
return new ImageIcon(url); |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public VCSGisJChanges createChangesPanel() {
|
106 |
return new VCSGisJChangesImpl(); |
107 |
} |
108 |
|
109 |
@Override
|
110 |
public PickerController<VCSGisWorkspace> createPickerWorkspaceController(JComboBox combo) { |
111 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
112 |
} |
113 |
|
114 |
@Override
|
115 |
public VCSGisJInitServer createInitRepositoryPanel() {
|
116 |
return new VCSGisJInitServerImpl(); |
117 |
} |
118 |
|
119 |
@Override
|
120 |
public VCSGisJInitWorkspace createInitWorkspacePanel() {
|
121 |
return new VCSGisJInitWorkspaceImpl(); |
122 |
} |
123 |
|
124 |
@Override
|
125 |
public VCSGisJAddToWorkspace createAddToWorkspacePanel() {
|
126 |
return new VCSGisJAddToWorkspaceImpl(); |
127 |
} |
128 |
|
129 |
@Override
|
130 |
public VCSGisJCheckout createCheckoutPanel() {
|
131 |
return new VCSGisJCheckoutImpl(); |
132 |
} |
133 |
|
134 |
@Override
|
135 |
public VCSGisJExport createExportPanel() {
|
136 |
return new VCSGisJExportImpl(); |
137 |
} |
138 |
|
139 |
@Override
|
140 |
public void setDefaultServices(VCSGisSwingServices services) { |
141 |
this.services = services;
|
142 |
} |
143 |
|
144 |
@Override
|
145 |
public VCSGisSwingServices getDefaultServices() {
|
146 |
return this.services; |
147 |
} |
148 |
|
149 |
@Override
|
150 |
public PickerController<VCSGisWorkspace> createWorkspacePickerController(JComboBox combo, JButton button) { |
151 |
return new VCSWorkspacePickerControllerImpl(combo, button); |
152 |
} |
153 |
|
154 |
@Override
|
155 |
public VCSGisJRegisterWorkspace createRegisterWorkspacePanel() {
|
156 |
return new VCSGisJRegisterWorkspaceImpl(); |
157 |
} |
158 |
|
159 |
@Override
|
160 |
public VCSGisJShowServerTableForm createShowTableServerFormPanel(String tableName) { |
161 |
return new VCSGisJShowServerTableFormImpl(tableName); |
162 |
} |
163 |
|
164 |
@Override
|
165 |
public String getHTMLColoredForEntity(VCSGisWorkspaceEntity entity, String name){ |
166 |
return getHTMLColorTag(
|
167 |
entity == null ? STATE_UNKNOWN : entity.getState(),
|
168 |
name |
169 |
); |
170 |
} |
171 |
|
172 |
@Override
|
173 |
public VCSGisJRevisions createRevisionsPanel() {
|
174 |
return new VCSGisJRevisionsImpl(); |
175 |
} |
176 |
|
177 |
@Override
|
178 |
public VCSGisJImportHistory createImportHistoryPanel() {
|
179 |
return new ImportHistoryImpl(); |
180 |
} |
181 |
|
182 |
@Override
|
183 |
public VCSGisJCreateResourceTable createResourceTablePanel() {
|
184 |
return new VCSGisJCreateResourceTableImpl(); |
185 |
} |
186 |
} |