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 / checkout / VCSGisJCheckoutImpl.java @ 2728
History | View | Annotate | Download (7.53 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 |
package org.gvsig.vcsgis.swing.impl.checkout; |
23 |
|
24 |
import java.awt.Dimension; |
25 |
import java.util.List; |
26 |
import javax.swing.JComponent; |
27 |
import javax.swing.ListSelectionModel; |
28 |
import javax.swing.event.ChangeEvent; |
29 |
import javax.swing.event.ListSelectionEvent; |
30 |
import org.gvsig.tools.swing.api.Component; |
31 |
import org.gvsig.tools.swing.api.FilteredListController; |
32 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
33 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
34 |
import org.gvsig.tools.swing.api.pickercontroller.DatePickerController; |
35 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
36 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
37 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
38 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
39 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
40 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
41 |
import org.gvsig.vcsgis.swing.VCSGisJCheckout; |
42 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
43 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
44 |
import org.slf4j.LoggerFactory; |
45 |
|
46 |
/**
|
47 |
*
|
48 |
* @author gvSIG Team
|
49 |
*/
|
50 |
public class VCSGisJCheckoutImpl extends VCSGisJCheckoutView |
51 |
implements Component, VCSGisJCheckout { |
52 |
|
53 |
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(VCSGisJCheckoutImpl.class); |
54 |
|
55 |
private Dialog dialog; |
56 |
|
57 |
private PickerController<VCSGisWorkspace> workspacePicker;
|
58 |
private DatePickerController datePicker;
|
59 |
private FilteredListController filteredList;
|
60 |
|
61 |
public VCSGisJCheckoutImpl() {
|
62 |
translate(); |
63 |
|
64 |
initializeComponents(); |
65 |
} |
66 |
|
67 |
private void initializeComponents() { |
68 |
|
69 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
70 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
71 |
this.workspacePicker = swingManager.createWorkspacePickerController(
|
72 |
cboWorkspaces, |
73 |
btnInitWorkspace |
74 |
); |
75 |
|
76 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
77 |
doChangeWorkspace(); |
78 |
doUpdateEnableComponents(); |
79 |
}); |
80 |
|
81 |
// this.cboWorkspaces.addItemListener((ItemEvent e) -> {
|
82 |
// if (e.getStateChange() == ItemEvent.SELECTED) {
|
83 |
// doChangeWorkspace();
|
84 |
// doUpdateEnableComponents();
|
85 |
// }
|
86 |
// });
|
87 |
|
88 |
this.lstTables.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
89 |
this.lstTables.addListSelectionListener((ListSelectionEvent e) -> { |
90 |
//FIXME: for use when branches are included
|
91 |
// dochangeTable();
|
92 |
doUpdateEnableComponents(); |
93 |
}); |
94 |
|
95 |
filteredList = toolsSwingManager.createFilteredListController(lstTables, txtFilter, btnTable); |
96 |
|
97 |
this.datePicker = toolsSwingManager.createDatePickerController(txtEffectiveDate, btnEffectiveDate);
|
98 |
|
99 |
this.rdbRevision.setEnabled(false); |
100 |
this.lstRevisions.setEnabled(false); |
101 |
//Effective date dissabled
|
102 |
this.rdbEffectiveDate.setEnabled(false); |
103 |
this.btnEffectiveDate.setEnabled(false); |
104 |
this.txtEffectiveDate.setEnabled(false); |
105 |
// this.rdbBranch.setEnabled(false);
|
106 |
// this.cboBranches.setEnabled(false);
|
107 |
|
108 |
//FIXME: for use when branches are included
|
109 |
|
110 |
// this.rdbBranch.addActionListener(new ActionListener() {
|
111 |
// @Override
|
112 |
// public void actionPerformed(ActionEvent e) {
|
113 |
// if(rdbBranch.isSelected()){
|
114 |
// cboBranches.setEnabled(true);
|
115 |
// lstRevisions.setEnabled(false);
|
116 |
// }
|
117 |
// }
|
118 |
// });
|
119 |
//
|
120 |
// this.rdbRevision.addActionListener(new ActionListener() {
|
121 |
// @Override
|
122 |
// public void actionPerformed(ActionEvent e) {
|
123 |
// if(rdbRevision.isSelected()){
|
124 |
// rdbBranch.setSelected(true);
|
125 |
// }
|
126 |
// }
|
127 |
// });
|
128 |
|
129 |
|
130 |
this.setPreferredSize(
|
131 |
new Dimension(520, 340) |
132 |
); |
133 |
|
134 |
} |
135 |
|
136 |
@Override
|
137 |
public JComponent asJComponent() { |
138 |
return this; |
139 |
} |
140 |
|
141 |
@Override
|
142 |
public void setDialog(Dialog dialog) { |
143 |
this.dialog = dialog;
|
144 |
this.doUpdateEnableComponents();
|
145 |
} |
146 |
|
147 |
private void doChangeWorkspace() { |
148 |
VCSGisWorkspace workspace = workspacePicker.get(); |
149 |
|
150 |
workspace.updateEntities(); |
151 |
List<VCSGisWorkspaceEntity> wsEntities = workspace.getWorkspaceEntities();
|
152 |
this.filteredList.getModel().clear();
|
153 |
// for (VCSGisWorkspace.LocalEntity entity : wsEntities) {
|
154 |
// this.filteredList.getModel().addElement(entity);
|
155 |
// }
|
156 |
|
157 |
//Obtenemos la entidades del repositorio que no estan todavia en el workspace
|
158 |
List<VCSGisEntity> repoEntities = workspace.getRepositoryEntities();
|
159 |
for (VCSGisEntity rentity : repoEntities) {
|
160 |
VCSGisEntity lentity = workspace.getWorkspaceEntityByCode(rentity.getEntityCode()); |
161 |
if(lentity == null){ |
162 |
this.filteredList.getModel().addElement(rentity);
|
163 |
} |
164 |
|
165 |
} |
166 |
} |
167 |
|
168 |
|
169 |
// FIXME: for use when branches are included
|
170 |
// private void doChangeTable() {
|
171 |
// vcsgisWorkspace.Entity entity = (vcsgisWorkspace.Entity) lstTables.getSelectedValue();
|
172 |
// entity.getEntityName()
|
173 |
// }
|
174 |
|
175 |
@Override
|
176 |
public VCSGisWorkspace getWorkspace() {
|
177 |
return this.workspacePicker.get(); |
178 |
} |
179 |
|
180 |
// @Override
|
181 |
// public VCSGisWorkspace.LocalEntity getTable() {
|
182 |
// return (VCSGisWorkspace.LocalEntity) lstTables.getSelectedValue();
|
183 |
// }// @Override
|
184 |
// public VCSGisWorkspace.LocalEntity getTable() {
|
185 |
// return (VCSGisWorkspace.LocalEntity) lstTables.getSelectedValue();
|
186 |
// }
|
187 |
|
188 |
|
189 |
@Override
|
190 |
public VCSGisEntity getTable() {
|
191 |
return (VCSGisEntity) lstTables.getSelectedValue();
|
192 |
} |
193 |
|
194 |
|
195 |
|
196 |
private void doUpdateEnableComponents() { |
197 |
boolean enableInit = (this.getWorkspace() != null && this.getTable() != null); |
198 |
if (dialog != null) { |
199 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK,
|
200 |
enableInit |
201 |
); |
202 |
} |
203 |
} |
204 |
|
205 |
@Override
|
206 |
public int checkout() { |
207 |
if (this.getWorkspace() != null && this.getTable() != null) { |
208 |
return this.getWorkspace().checkout(getTable().getEntityName()); |
209 |
} |
210 |
return -1; |
211 |
} |
212 |
|
213 |
|
214 |
private void translate() { |
215 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
216 |
swingManager.translate(this.lblWorkspace);
|
217 |
swingManager.translate(this.lblTable);
|
218 |
swingManager.translate(this.rdbEffectiveDate);
|
219 |
swingManager.translate(this.rdbRevision);
|
220 |
} |
221 |
|
222 |
} |