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 / revisions / VCSGisJRevisionsDialog.java @ 3458
History | View | Annotate | Download (5.11 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.revisions; |
24 |
|
25 |
import javax.swing.ImageIcon; |
26 |
import javax.swing.JComponent; |
27 |
import javax.swing.SwingUtilities; |
28 |
import javax.swing.event.ChangeEvent; |
29 |
import org.gvsig.tools.ToolsLocator; |
30 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
31 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
32 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
33 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
34 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
35 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
36 |
import org.gvsig.vcsgis.lib.VCSGisRevision; |
37 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
38 |
import org.gvsig.vcsgis.swing.VCSGisJRevisions; |
39 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
40 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
41 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
42 |
import org.gvsig.vcsgis.swing.impl.VCSGisSwingManagerImpl; |
43 |
|
44 |
/**
|
45 |
*
|
46 |
* @author gvSIG Team
|
47 |
*/
|
48 |
public class VCSGisJRevisionsDialog extends VCSGisJRevisionsDialogView implements VCSGisJRevisions { |
49 |
|
50 |
private boolean processing; |
51 |
private TaskStatusController taskStatusController;
|
52 |
private VCSGisJRevisionsController revisionsController;
|
53 |
private final VCSGisWorkspace workspace; |
54 |
private final VCSGisEntity entity; |
55 |
|
56 |
public VCSGisJRevisionsDialog(VCSGisWorkspace workspace, VCSGisEntity entity) {
|
57 |
this.processing = false; |
58 |
this.workspace = workspace;
|
59 |
this.entity = entity;
|
60 |
this.initComponents();
|
61 |
} |
62 |
|
63 |
@Override
|
64 |
public boolean isProcessing() { |
65 |
return this.processing; |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public JComponent asJComponent() { |
70 |
return this; |
71 |
} |
72 |
|
73 |
private void initComponents() { |
74 |
VCSGisSwingManager vcsSwingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
75 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
76 |
|
77 |
this.taskStatusController = taskStatusManager.createTaskStatusController(
|
78 |
null,
|
79 |
this.lblMessages,
|
80 |
null
|
81 |
); |
82 |
this.taskStatusController.setShowCancelButton(false); |
83 |
this.taskStatusController.setShowRemoveTaskButton(false); |
84 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager());
|
85 |
SwingUtilities.invokeLater(() -> {this.setVisibleStatus(false); }); |
86 |
|
87 |
|
88 |
this.revisionsController = new VCSGisJRevisionsController( |
89 |
this.tblRevisions,
|
90 |
this.btnMore,
|
91 |
this.btnFilter,
|
92 |
this.lblMessages
|
93 |
); |
94 |
this.revisionsController.setWorkspace(this.workspace); |
95 |
this.revisionsController.setEntity(this.entity); |
96 |
this.revisionsController.addChangeListener((ChangeEvent e) -> { |
97 |
this.processing = this.revisionsController.isProcessing(); |
98 |
updateStateComponents(); |
99 |
}); |
100 |
|
101 |
translate(); |
102 |
|
103 |
} |
104 |
|
105 |
private void translate() { |
106 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
107 |
toolsSwingManager.translate(this.btnMore);
|
108 |
toolsSwingManager.translate(this.btnFilter);
|
109 |
} |
110 |
|
111 |
private void updateStateComponents() { |
112 |
if (notInSwingThreadInvokeLater(() -> {updateStateComponents();})) {
|
113 |
return;
|
114 |
} |
115 |
|
116 |
this.revisionsController.setEnabled(!processing && workspace!=null && entity!=null); |
117 |
} |
118 |
|
119 |
@Override
|
120 |
public ImageIcon loadImage(String imageName) { |
121 |
return VCSGisSwingManagerImpl.loadImage(imageName);
|
122 |
} |
123 |
|
124 |
private void message(final String msg) { |
125 |
if( notInSwingThreadInvokeLater(() -> {message(msg);})) {
|
126 |
return;
|
127 |
} |
128 |
this.getTaskStatusController().message(msg);
|
129 |
} |
130 |
|
131 |
public void setVisibleStatus(boolean visible) { |
132 |
if( notInSwingThreadInvokeLater(() -> {setVisibleStatus(visible);}) ) {
|
133 |
return;
|
134 |
} |
135 |
this.lblMessages.setVisible(visible);
|
136 |
} |
137 |
|
138 |
public TaskStatusController getTaskStatusController() {
|
139 |
return this.taskStatusController; |
140 |
} |
141 |
|
142 |
public VCSGisRevision getSelectedRevision() {
|
143 |
return this.revisionsController.getSelectedRevision(); |
144 |
} |
145 |
|
146 |
@Override
|
147 |
public void setDialog(Dialog dialog) { |
148 |
// Do nothing
|
149 |
} |
150 |
} |