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 / changes / VCSGisJChangesImpl.java @ 3458
History | View | Annotate | Download (10.3 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
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 3
|
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, see <https://www.gnu.org/licenses/>.
|
18 |
*
|
19 |
* For any additional information, do not hesitate to contact us
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
21 |
*/
|
22 |
|
23 |
package org.gvsig.vcsgis.swing.impl.changes; |
24 |
|
25 |
import java.awt.Dimension; |
26 |
import java.awt.event.ActionEvent; |
27 |
import java.util.List; |
28 |
import javax.swing.ImageIcon; |
29 |
import javax.swing.JComponent; |
30 |
import javax.swing.SwingUtilities; |
31 |
import javax.swing.Timer; |
32 |
import org.gvsig.tools.ToolsLocator; |
33 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
34 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
35 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
36 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
37 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
38 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
39 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
40 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
41 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
42 |
import org.gvsig.vcsgis.swing.VCSGisJChanges; |
43 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
44 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
45 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
46 |
import org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl; |
47 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl.ICON_COMMON_GROUP_NAME; |
48 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl.ICON_GROUP_NAME; |
49 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl.ICON_PROVIDER_NAME; |
50 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl.registerIcons; |
51 |
import org.slf4j.Logger; |
52 |
import org.slf4j.LoggerFactory; |
53 |
|
54 |
/**
|
55 |
*
|
56 |
* @author gvSIG Team
|
57 |
*/
|
58 |
@SuppressWarnings("UseSpecificCatch") |
59 |
public class VCSGisJChangesImpl |
60 |
extends VCSGisJChangesView
|
61 |
implements VCSGisJChanges
|
62 |
{ |
63 |
|
64 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisJChangesImpl.class); |
65 |
|
66 |
public static final int LOCAL_TAB_INDEX = 0; |
67 |
public static final int REMOTE_TAB_INDEX = 1; |
68 |
|
69 |
private PickerController<VCSGisWorkspace> workspacePicker;
|
70 |
private LocalChangesController localChangesController;
|
71 |
private RemoteChangesController remoteChangesController;
|
72 |
private final List<VCSGisWorkspaceEntity> workspaceEntities = null; |
73 |
private final List<VCSGisEntity> repositoryEntities = null; |
74 |
private boolean entitiesUpdateds; |
75 |
private VCSGisWorkspace currentWorkspace;
|
76 |
private TaskStatusController taskStatusController;
|
77 |
private Timer timerClearMsg; |
78 |
/* friend */ boolean processing; |
79 |
|
80 |
|
81 |
public VCSGisJChangesImpl() {
|
82 |
processing = false;
|
83 |
initComponents(); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public JComponent asJComponent() { |
88 |
return this; |
89 |
} |
90 |
|
91 |
@Override
|
92 |
public ImageIcon loadImage(String imageName) { |
93 |
return VCSGisSwingManagerImpl.loadImage(imageName);
|
94 |
} |
95 |
|
96 |
private void translate() { |
97 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
98 |
swingManager.translate(this.lblWorkspace);
|
99 |
swingManager.translate(this.btnWorkspace);
|
100 |
|
101 |
swingManager.translate(this.tabLocalAndRemote);
|
102 |
} |
103 |
|
104 |
private void initComponents() { |
105 |
VCSGisSwingManager vcsSwingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
106 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
107 |
|
108 |
this.timerClearMsg = new Timer(5000, (ActionEvent e) -> { |
109 |
getTaskStatusController().message("");
|
110 |
}); |
111 |
this.timerClearMsg.setRepeats(false); |
112 |
|
113 |
translate(); |
114 |
|
115 |
this.taskStatusController = taskStatusManager.createTaskStatusController(
|
116 |
this.lblStatusCaption,
|
117 |
this.lblStatusMessages,
|
118 |
this.pbStatus
|
119 |
); |
120 |
this.taskStatusController.setShowCancelButton(false); |
121 |
this.taskStatusController.setShowRemoveTaskButton(false); |
122 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager());
|
123 |
SwingUtilities.invokeLater(() -> {this.setVisibleStatus(false); }); |
124 |
|
125 |
|
126 |
this.workspacePicker = vcsSwingManager.createWorkspacePickerController(
|
127 |
this.cboWorkspace,
|
128 |
this.btnWorkspace
|
129 |
); |
130 |
|
131 |
|
132 |
|
133 |
this.localChangesController = new LocalChangesController( |
134 |
this,
|
135 |
this.workspacePicker,
|
136 |
this.btnLocalCheckAllEntities,
|
137 |
this.btnLocalUnCheckAllEntities,
|
138 |
this.tblLocalChanges,
|
139 |
this.btnLocalCheckAll,
|
140 |
this.btnLocalUnCheckAll,
|
141 |
this.btnLocalShowForm,
|
142 |
this.btnLocalRefresh,
|
143 |
this.btnLocalCommit,
|
144 |
this.btnLocalRevert,
|
145 |
this.lblLocalEffectiveDate,
|
146 |
this.txtLocalEffectiveDate,
|
147 |
this.txtLocalComment,
|
148 |
this.btnLocalEffectiveDate,
|
149 |
this.lblLocalComment,
|
150 |
this.btnLocalZoom,
|
151 |
this.btnLocalCenter,
|
152 |
this.btnLocalCleanHighligthed,
|
153 |
this.lblLocalChangesCount,
|
154 |
this.txtLocalTablesFilter,
|
155 |
this.btnLocalTable,
|
156 |
this.treeLocalTables
|
157 |
); |
158 |
|
159 |
this.remoteChangesController = new RemoteChangesController( |
160 |
this,
|
161 |
|
162 |
this.workspacePicker,
|
163 |
|
164 |
this.lstRemoteTables,
|
165 |
this.btnRemoteTablesReload,
|
166 |
|
167 |
this.tblRemoteChanges,
|
168 |
this.btnRemoteCheckAll,
|
169 |
this.btnRemoteUncheckAll,
|
170 |
this.btnRemoteDownloadChanges,
|
171 |
this.btnRemoteReloadChanges,
|
172 |
this.btnRemoteCleanChanges,
|
173 |
this.btnRemoteUpdate,
|
174 |
this.btnRemoteMerge,
|
175 |
this.btnRemoteShowForm,
|
176 |
this.btnRemoteZoom,
|
177 |
this.btnRemoteCenter,
|
178 |
this.btnRemoteCheckout,
|
179 |
this.btnRemoteCleanHighligthed,
|
180 |
this.lblRemoteChangesCount
|
181 |
); |
182 |
|
183 |
this.setPreferredSize(new Dimension(640, 480)); |
184 |
} |
185 |
|
186 |
/* friend */ void doUpdateComponents() { |
187 |
if( notInSwingThreadInvokeLater(() -> {doUpdateComponents();}) ) {
|
188 |
return;
|
189 |
} |
190 |
|
191 |
if(this.localChangesController != null){ |
192 |
this.localChangesController.doUpdateComponents();
|
193 |
} |
194 |
if(this.remoteChangesController != null){ |
195 |
this.remoteChangesController.doUpdateComponents();
|
196 |
} |
197 |
} |
198 |
|
199 |
public void updateLocalChangesTable() { |
200 |
if( notInSwingThreadInvokeLater(() -> {updateLocalChangesTable();}) ) {
|
201 |
return;
|
202 |
} |
203 |
this.localChangesController.doReloadTables();
|
204 |
this.localChangesController.doUpdateTableLocalChanges();
|
205 |
} |
206 |
|
207 |
public VCSGisWorkspace getWorkspace() {
|
208 |
VCSGisWorkspace ws = this.workspacePicker.get();
|
209 |
return ws;
|
210 |
} |
211 |
|
212 |
public void updateEntitiesFromRepository(boolean forceUpdateEntities) { |
213 |
VCSGisWorkspace ws = this.getWorkspace();
|
214 |
if( ws == null ) { |
215 |
return;
|
216 |
} |
217 |
if( !forceUpdateEntities && this.currentWorkspace==ws && this.entitiesUpdateds ) { |
218 |
return;
|
219 |
} |
220 |
setVisibleStatus(true);
|
221 |
ws.updateEntitiesFromRepository(); |
222 |
this.currentWorkspace = ws;
|
223 |
this.entitiesUpdateds = true; |
224 |
setVisibleStatus(false);
|
225 |
} |
226 |
|
227 |
|
228 |
public void message(final String msg) { |
229 |
if( notInSwingThreadInvokeLater(() -> {message(msg);})) {
|
230 |
return;
|
231 |
} |
232 |
this.timerClearMsg.stop();
|
233 |
this.getTaskStatusController().message(msg);
|
234 |
this.timerClearMsg.start();
|
235 |
} |
236 |
|
237 |
public void setVisibleStatus(boolean visible) { |
238 |
if( notInSwingThreadInvokeLater(() -> {setVisibleStatus(visible);}) ) {
|
239 |
return;
|
240 |
} |
241 |
this.lblStatusCaption.setVisible(visible);
|
242 |
this.pbStatus.setVisible(visible);
|
243 |
this.lblStatusMessages.setVisible(true); |
244 |
} |
245 |
|
246 |
public TaskStatusController getTaskStatusController() {
|
247 |
return this.taskStatusController; |
248 |
} |
249 |
|
250 |
public static void selfRegister() { |
251 |
String[][] iconsInfo = new String[][]{ |
252 |
new String[]{ICON_PROVIDER_NAME, ICON_COMMON_GROUP_NAME, "common-check-off"}, |
253 |
new String[]{ICON_PROVIDER_NAME, ICON_COMMON_GROUP_NAME, "common-check-on"}, |
254 |
new String[]{ICON_PROVIDER_NAME, ICON_COMMON_GROUP_NAME, "common-showform"}, |
255 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-commit-all"}, |
256 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-refresh-status"}, |
257 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-revert"}, |
258 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-update-all"}, |
259 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-merge"}, |
260 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-show-local-changes"}, |
261 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-show-remote-changes"}, |
262 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-show-local-and-remote-changes"}, |
263 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-center-context"}, |
264 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-zoom-context"}, |
265 |
new String[]{ICON_PROVIDER_NAME, ICON_GROUP_NAME, "vcsgis-clean-highlighted"}, |
266 |
}; |
267 |
registerIcons(iconsInfo); |
268 |
|
269 |
} |
270 |
|
271 |
@Override
|
272 |
public boolean isProcessing() { |
273 |
return this.processing; |
274 |
} |
275 |
|
276 |
public void selectTab(int tab){ |
277 |
this.tabLocalAndRemote.setSelectedIndex(tab);
|
278 |
} |
279 |
|
280 |
public void selectOnlyALocalEntity(VCSGisEntity selectedTable){ |
281 |
this.localChangesController.selectOnlyAEntity(selectedTable);
|
282 |
} |
283 |
|
284 |
@Override
|
285 |
public void setDialog(Dialog dialog) { |
286 |
// Do nothing
|
287 |
} |
288 |
} |