Revision 3379
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/VCSGisEntitySelectorControllerImpl.java | ||
---|---|---|
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; |
|
24 |
|
|
25 |
import java.awt.Cursor; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Collections; |
|
30 |
import java.util.HashSet; |
|
31 |
import java.util.List; |
|
32 |
import java.util.Set; |
|
33 |
import java.util.function.Predicate; |
|
34 |
import javax.swing.JButton; |
|
35 |
import javax.swing.JList; |
|
36 |
import javax.swing.JOptionPane; |
|
37 |
import javax.swing.JTextField; |
|
38 |
import javax.swing.ListModel; |
|
39 |
import javax.swing.ListSelectionModel; |
|
40 |
import javax.swing.event.ChangeListener; |
|
41 |
import javax.swing.event.ListSelectionEvent; |
|
42 |
import org.apache.commons.lang3.StringUtils; |
|
43 |
import org.gvsig.tools.ToolsLocator; |
|
44 |
import org.gvsig.tools.i18n.I18nManager; |
|
45 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
|
46 |
import org.gvsig.tools.swing.api.ChangeListenerHelper; |
|
47 |
import org.gvsig.tools.swing.api.FilteredListController; |
|
48 |
import org.gvsig.tools.swing.api.FilteredListModel; |
|
49 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
|
50 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
51 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
52 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
53 |
import org.gvsig.tools.util.LabeledValue; |
|
54 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
55 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
56 |
import static org.gvsig.vcsgis.lib.VCSGisManager.STATE_REPOSITORY_NEW; |
|
57 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
58 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
59 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
|
60 |
import org.slf4j.Logger; |
|
61 |
import org.slf4j.LoggerFactory; |
|
62 |
|
|
63 |
/** |
|
64 |
* |
|
65 |
* @author gvSIG Team |
|
66 |
*/ |
|
67 |
public class VCSGisEntitySelectorControllerImpl |
|
68 |
implements |
|
69 |
VCSGisEntitySelectorController |
|
70 |
{ |
|
71 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisEntitySelectorControllerImpl.class); |
|
72 |
|
|
73 |
private final JTextField txtFilter; |
|
74 |
private final JList lstTables; |
|
75 |
private JListWithCheckbox lstTablesWithCheckbox; |
|
76 |
private final JButton btnTable; |
|
77 |
private FilteredListController filteredList; |
|
78 |
private ActionListenerSupport actionListeners; |
|
79 |
private ChangeListenerHelper changeListeners; |
|
80 |
private VCSGisWorkspace workspace; |
|
81 |
private boolean processing; |
|
82 |
private boolean enabled; |
|
83 |
private Predicate<VCSGisEntity> viewFilter; |
|
84 |
private Predicate<VCSGisEntity> filter; |
|
85 |
|
|
86 |
public VCSGisEntitySelectorControllerImpl(JList lstTables) { |
|
87 |
this(lstTables, null, null); |
|
88 |
} |
|
89 |
|
|
90 |
public VCSGisEntitySelectorControllerImpl(JList lstTables, JTextField txtFilter, JButton btnTable) { |
|
91 |
viewFilter = ALL_ENTITIES; |
|
92 |
filter = ALL_ENTITIES; |
|
93 |
|
|
94 |
this.lstTables = lstTables; |
|
95 |
this.lstTablesWithCheckbox = null; |
|
96 |
if( txtFilter==null ) { |
|
97 |
this.txtFilter = new JTextField(); |
|
98 |
} else { |
|
99 |
this.txtFilter = txtFilter; |
|
100 |
} |
|
101 |
if( btnTable==null ) { |
|
102 |
this.btnTable = new JButton(); |
|
103 |
} else { |
|
104 |
this.btnTable = btnTable; |
|
105 |
} |
|
106 |
this.processing = false; |
|
107 |
|
|
108 |
this.initComponents(); |
|
109 |
} |
|
110 |
|
|
111 |
private void initComponents() { |
|
112 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
113 |
|
|
114 |
this.actionListeners = toolsSwingManager.createActionListenerSupport(); |
|
115 |
this.changeListeners = toolsSwingManager.createChangeListenerHelper(); |
|
116 |
|
|
117 |
this.btnTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
118 |
|
|
119 |
this.lstTables.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
120 |
this.lstTables.addListSelectionListener((ListSelectionEvent e) -> { |
|
121 |
if( e.getValueIsAdjusting() ) { |
|
122 |
return; |
|
123 |
} |
|
124 |
fireActionEvent(new ActionEvent(this, 0, "select")); |
|
125 |
}); |
|
126 |
filteredList = toolsSwingManager.createFilteredListController(lstTables, txtFilter, btnTable); |
|
127 |
this.lstTables.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public boolean isProcessing() { |
|
132 |
return this.processing; |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public VCSGisEntity getSelectedEntity() { |
|
137 |
if( this.workspace==null ) { |
|
138 |
return null; |
|
139 |
} |
|
140 |
LabeledValue selected = (LabeledValue) lstTables.getSelectedValue(); |
|
141 |
if (selected == null) { |
|
142 |
return null; |
|
143 |
} |
|
144 |
VCSGisEntity entity = (VCSGisEntity) selected.getValue(); |
|
145 |
if(!this.filter.test(entity)){ |
|
146 |
return null; |
|
147 |
} |
|
148 |
return entity; |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public List<VCSGisEntity> getCheckedEntities() { |
|
153 |
if (this.lstTablesWithCheckbox == null) { |
|
154 |
VCSGisEntity entity = this.getSelectedEntity(); |
|
155 |
if (entity == null) { |
|
156 |
return Collections.EMPTY_LIST; |
|
157 |
} |
|
158 |
return Collections.singletonList(this.getSelectedEntity()); |
|
159 |
} |
|
160 |
List<VCSGisEntity> checkedEntities = new ArrayList<>(); |
|
161 |
ListSelectionModel checkedModel = this.lstTablesWithCheckbox.getCheckedModel(); |
|
162 |
ListModel model = this.lstTablesWithCheckbox.getModel(); |
|
163 |
for (int i = 0; i < model.getSize(); i++) { |
|
164 |
if(checkedModel.isSelectedIndex(i)){ |
|
165 |
checkedEntities.add((VCSGisEntity) ((LabeledValue) model.getElementAt(i)).getValue()); |
|
166 |
} |
|
167 |
} |
|
168 |
return checkedEntities; |
|
169 |
} |
|
170 |
|
|
171 |
@Override |
|
172 |
public void setWorkspace(VCSGisWorkspace workspace) { |
|
173 |
this.workspace = workspace; |
|
174 |
if (workspace == null) { |
|
175 |
this.filteredList.getModel().clear(); |
|
176 |
return; |
|
177 |
} |
|
178 |
// this.filteredList.getModel().clear(); |
|
179 |
Thread task = new Thread(() -> {reloadTables(this.workspace);}, "VCSGisEntitySelectorReloadEntities"); |
|
180 |
task.start(); |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public VCSGisWorkspace getWorkspace() { |
|
185 |
return this.workspace; |
|
186 |
} |
|
187 |
|
|
188 |
private void reloadTables(VCSGisWorkspace workspace) { |
|
189 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
190 |
try { |
|
191 |
this.processing = true; |
|
192 |
this.doUpdateComponents(); |
|
193 |
workspace.reloadRepositoryEntities(null); |
|
194 |
List<VCSGisEntity> repoEntities = workspace.getRepositoryEntities(); |
|
195 |
|
|
196 |
List<LabeledValue<VCSGisEntity>> entities = new ArrayList<>(); |
|
197 |
for (VCSGisEntity rentity : repoEntities) { |
|
198 |
VCSGisEntity entity = rentity; |
|
199 |
VCSGisWorkspaceEntity lentity = workspace.getWorkspaceEntityByCode(rentity.getEntityCode()); |
|
200 |
LabeledValue entry; |
|
201 |
String s = VCSGisSwingCommons.getHTMLColorTag( |
|
202 |
lentity == null ? STATE_REPOSITORY_NEW : lentity.getState(), |
|
203 |
rentity.getEntityName() |
|
204 |
); |
|
205 |
if(lentity != null){ |
|
206 |
entity = lentity; |
|
207 |
} |
|
208 |
if(this.viewFilter.test(entity)){ |
|
209 |
entry = new LabeledValueImpl(s, entity); |
|
210 |
entities.add(entry); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
List<VCSGisWorkspaceEntity> localEntities = workspace.getWorkspaceEntities(); |
|
215 |
for (VCSGisWorkspaceEntity localEntity : localEntities) { |
|
216 |
if (StringUtils.isBlank(localEntity.getRepositoryRevisionCode())) { |
|
217 |
if (!this.viewFilter.test(localEntity)) { |
|
218 |
continue; |
|
219 |
} |
|
220 |
LabeledValue entry; |
|
221 |
String s = VCSGisSwingCommons.getHTMLColorTag( |
|
222 |
localEntity.getState(), |
|
223 |
localEntity.getEntityName() |
|
224 |
); |
|
225 |
entry = new LabeledValueImpl(s, localEntity); |
|
226 |
entities.add(entry); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
Collections.sort(entities, (LabeledValue<VCSGisEntity> o1, LabeledValue<VCSGisEntity> o2) -> StringUtils.compareIgnoreCase( |
|
231 |
o1.getValue().getEntityName(), |
|
232 |
o2.getValue().getEntityName() |
|
233 |
)); |
|
234 |
postReloadTables(entities); |
|
235 |
|
|
236 |
} catch (Exception e) { |
|
237 |
LOGGER.warn("_Cant_retrieve_entities_from_repository", e); |
|
238 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
239 |
dialogs.messageDialog( |
|
240 |
i18n.getTranslation("_Cant_retrieve_entities_from_repository") + "\n" + e.getMessage(), |
|
241 |
i18n.getTranslation("_Checkout"), |
|
242 |
JOptionPane.WARNING_MESSAGE |
|
243 |
); |
|
244 |
} finally { |
|
245 |
this.processing = false; |
|
246 |
this.doUpdateComponents(); |
|
247 |
} |
|
248 |
|
|
249 |
} |
|
250 |
|
|
251 |
private void postReloadTables(List<LabeledValue<VCSGisEntity>> entities ) { |
|
252 |
if( notInSwingThreadInvokeLater(() -> { postReloadTables(entities); }) ) { |
|
253 |
return; |
|
254 |
} |
|
255 |
FilteredListModel model = this.filteredList.getModel(); |
|
256 |
Set<String> checkeds = new HashSet<>(); |
|
257 |
ListSelectionModel checkedModel = null; |
|
258 |
if(lstTablesWithCheckbox != null) { |
|
259 |
checkedModel = lstTablesWithCheckbox.getCheckedModel(); |
|
260 |
for(int i = 0; i<model.getSize(); i++){ |
|
261 |
if(checkedModel.isSelectedIndex(i)){ |
|
262 |
checkeds.add(((VCSGisEntity) (model.getElementAt(i).getValue())).getEntityCode()); |
|
263 |
} |
|
264 |
} |
|
265 |
checkedModel.clearSelection(); |
|
266 |
} |
|
267 |
model.clear(); |
|
268 |
this.lstTables.getSelectionModel().clearSelection(); |
|
269 |
for (LabeledValue<VCSGisEntity> entity : entities) { |
|
270 |
if(entity != null){ |
|
271 |
this.filteredList.getModel().addElement(entity); |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
if(checkedModel != null) { |
|
276 |
for(int i = 0; i<model.getSize(); i++){ |
|
277 |
VCSGisEntity entity = (VCSGisEntity) (model.getElementAt(i).getValue()); |
|
278 |
if(checkeds.contains(entity.getEntityCode())){ |
|
279 |
checkedModel.addSelectionInterval(i, i); |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
this.processing = false; |
|
285 |
this.changeListeners.fireEvent(); |
|
286 |
} |
|
287 |
|
|
288 |
private void doUpdateComponents() { |
|
289 |
if( notInSwingThreadInvokeLater(this::doUpdateComponents) ) { |
|
290 |
return; |
|
291 |
} |
|
292 |
this.txtFilter.setEnabled(enabled && !processing); |
|
293 |
this.btnTable.setEnabled(enabled && !processing); |
|
294 |
this.lstTables.setEnabled(enabled && !processing); |
|
295 |
} |
|
296 |
|
|
297 |
@Override |
|
298 |
public void setEnabled(boolean enabled) { |
|
299 |
this.enabled = enabled; |
|
300 |
doUpdateComponents(); |
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public boolean isEnabled() { |
|
305 |
return enabled; |
|
306 |
} |
|
307 |
|
|
308 |
@Override |
|
309 |
public void setChecksEnabled(boolean enabled) { |
|
310 |
if(enabled){ |
|
311 |
lstTablesWithCheckbox = ToolsSwingLocator.getToolsSwingManager().createJListWithCheckbox(lstTables); |
|
312 |
} else { |
|
313 |
lstTablesWithCheckbox = null; |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
@Override |
|
318 |
public boolean isChecksEnabled() { |
|
319 |
return lstTablesWithCheckbox != null; |
|
320 |
} |
|
321 |
|
|
322 |
@Override |
|
323 |
public void addActionListener(ActionListener al) { |
|
324 |
this.actionListeners.addActionListener(al); |
|
325 |
} |
|
326 |
|
|
327 |
@Override |
|
328 |
public ActionListener[] getActionListeners() { |
|
329 |
return this.actionListeners.getActionListeners(); |
|
330 |
} |
|
331 |
|
|
332 |
@Override |
|
333 |
public void removeActionListener(ActionListener al) { |
|
334 |
this.actionListeners.removeActionListener(al); |
|
335 |
} |
|
336 |
|
|
337 |
@Override |
|
338 |
public void removeAllActionListener() { |
|
339 |
this.actionListeners.removeAllActionListener(); |
|
340 |
} |
|
341 |
|
|
342 |
@Override |
|
343 |
public void fireActionEvent(ActionEvent ae) { |
|
344 |
this.actionListeners.fireActionEvent(ae); |
|
345 |
} |
|
346 |
|
|
347 |
@Override |
|
348 |
public boolean hasActionListeners() { |
|
349 |
return this.actionListeners.hasActionListeners(); |
|
350 |
} |
|
351 |
|
|
352 |
@Override |
|
353 |
public void addChangeListener(ChangeListener cl) { |
|
354 |
this.changeListeners.addChangeListener(cl); |
|
355 |
} |
|
356 |
|
|
357 |
@Override |
|
358 |
public ChangeListener[] getChangeListeners() { |
|
359 |
return this.changeListeners.getChangeListeners(); |
|
360 |
} |
|
361 |
|
|
362 |
@Override |
|
363 |
public void removeChangeListener(ChangeListener cl) { |
|
364 |
this.changeListeners.removeChangeListener(cl); |
|
365 |
} |
|
366 |
|
|
367 |
@Override |
|
368 |
public void removeAllChangeListener() { |
|
369 |
this.changeListeners.removeAllChangeListener(); |
|
370 |
} |
|
371 |
|
|
372 |
@Override |
|
373 |
public boolean hasChangeListeners() { |
|
374 |
return this.changeListeners.hasChangeListeners(); |
|
375 |
} |
|
376 |
|
|
377 |
@Override |
|
378 |
public void setViewFilter(Predicate<VCSGisEntity> viewFilter) { |
|
379 |
this.viewFilter = viewFilter; |
|
380 |
} |
|
381 |
|
|
382 |
@Override |
|
383 |
public void setFilter(Predicate<VCSGisEntity> filter) { |
|
384 |
this.filter = filter; |
|
385 |
} |
|
386 |
|
|
387 |
@Override |
|
388 |
public ListSelectionModel getCheckedModel() { |
|
389 |
if(lstTablesWithCheckbox != null){ |
|
390 |
return lstTablesWithCheckbox.getCheckedModel(); |
|
391 |
} |
|
392 |
return null; |
|
393 |
} |
|
394 |
|
|
395 |
@Override |
|
396 |
public void check(VCSGisEntity entity) { |
|
397 |
if (lstTablesWithCheckbox != null && entity != null) { |
|
398 |
ListModel model = this.filteredList.getModel(); |
|
399 |
for (int i = 0; i < model.getSize(); i++) { |
|
400 |
LabeledValueImpl element = (LabeledValueImpl) model.getElementAt(i); |
|
401 |
VCSGisEntity ent = (VCSGisEntity) element.getValue(); |
|
402 |
if (StringUtils.equalsIgnoreCase( |
|
403 |
ent.getEntityCode(), |
|
404 |
entity.getEntityCode() |
|
405 |
)) { |
|
406 |
lstTablesWithCheckbox.getCheckedModel().addSelectionInterval(i, i); |
|
407 |
return; |
|
408 |
} |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
412 |
|
|
413 |
} |
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/VCSGisJChangesView.java | ||
---|---|---|
20 | 20 |
import javax.swing.JTabbedPane; |
21 | 21 |
import javax.swing.JTable; |
22 | 22 |
import javax.swing.JTextField; |
23 |
import javax.swing.JTree; |
|
23 | 24 |
import javax.swing.border.EmptyBorder; |
24 | 25 |
|
25 | 26 |
|
... | ... | |
46 | 47 |
JLabel lblLocalChangesCount = new JLabel(); |
47 | 48 |
JButton btnLocalCheckAllEntities = new JButton(); |
48 | 49 |
JButton btnLocalUnCheckAll1 = new JButton(); |
49 |
JList lstLocalTables = new JList(); |
|
50 | 50 |
JTextField txtLocalTablesFilter = new JTextField(); |
51 | 51 |
JButton btnLocalTable = new JButton(); |
52 |
JTree treeLocalTables = new JTree(); |
|
52 | 53 |
JTable tblRemoteChanges = new JTable(); |
53 | 54 |
JList lstRemoteTables = new JList(); |
54 | 55 |
JLabel lblRemoteChangesCount = new JLabel(); |
... | ... | |
389 | 390 |
CellConstraints cc = new CellConstraints(); |
390 | 391 |
jpanel1.setLayout(formlayout1); |
391 | 392 |
|
392 |
lstLocalTables.setName("lstLocalTables"); |
|
393 |
JScrollPane jscrollpane1 = new JScrollPane(); |
|
394 |
jscrollpane1.setViewportView(lstLocalTables); |
|
395 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
396 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
397 |
jpanel1.add(jscrollpane1,cc.xywh(1,3,3,1)); |
|
398 |
|
|
399 | 393 |
txtLocalTablesFilter.setName("txtLocalTablesFilter"); |
400 | 394 |
jpanel1.add(txtLocalTablesFilter,cc.xy(1,1)); |
401 | 395 |
|
... | ... | |
407 | 401 |
btnLocalTable.setBorder(emptyborder1); |
408 | 402 |
jpanel1.add(btnLocalTable,cc.xy(3,1)); |
409 | 403 |
|
404 |
treeLocalTables.setName("treeLocalTables"); |
|
405 |
JScrollPane jscrollpane1 = new JScrollPane(); |
|
406 |
jscrollpane1.setViewportView(treeLocalTables); |
|
407 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
408 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
409 |
jpanel1.add(jscrollpane1,cc.xywh(1,3,3,1)); |
|
410 |
|
|
410 | 411 |
addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2 }); |
411 | 412 |
return jpanel1; |
412 | 413 |
} |
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 | ||
---|---|---|
150 | 150 |
this.lblLocalChangesCount, |
151 | 151 |
this.txtLocalTablesFilter, |
152 | 152 |
this.btnLocalTable, |
153 |
this.lstLocalTables
|
|
153 |
this.treeLocalTables
|
|
154 | 154 |
); |
155 | 155 |
|
156 | 156 |
this.remoteChangesController = new RemoteChangesController( |
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/LocalChangesController.java | ||
---|---|---|
25 | 25 |
import java.awt.Cursor; |
26 | 26 |
import java.awt.Dimension; |
27 | 27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
|
28 | 29 |
import java.awt.event.KeyAdapter; |
29 | 30 |
import java.awt.event.KeyEvent; |
30 | 31 |
import java.sql.Timestamp; |
... | ... | |
43 | 44 |
import javax.swing.JOptionPane; |
44 | 45 |
import javax.swing.JTable; |
45 | 46 |
import javax.swing.JTextField; |
47 |
import javax.swing.JTree; |
|
46 | 48 |
import javax.swing.ListSelectionModel; |
47 | 49 |
import javax.swing.event.ChangeEvent; |
48 | 50 |
import javax.swing.event.ListSelectionEvent; |
... | ... | |
126 | 128 |
private final JButton btnLocalCleanHighlighted; |
127 | 129 |
private final JTextField txtLocalTablesFilter; |
128 | 130 |
private final JButton btnLocalTable; |
129 |
private final JList lstLocalTables;
|
|
131 |
private final JTree treeLocalTables;
|
|
130 | 132 |
private VCSGisEntitySelectorController entitySelector; |
131 | 133 |
|
132 | 134 |
public LocalChangesController( |
... | ... | |
150 | 152 |
JLabel lblLocalChangesCount, |
151 | 153 |
JTextField txtLocalTablesFilter, |
152 | 154 |
JButton btnLocalTable, |
153 |
JList lstLocalTables
|
|
155 |
JTree treeLocalTables
|
|
154 | 156 |
) { |
155 | 157 |
this.dissabledUncheckAllByEntities = false; |
156 | 158 |
|
... | ... | |
175 | 177 |
|
176 | 178 |
this.txtLocalTablesFilter = txtLocalTablesFilter; |
177 | 179 |
this.btnLocalTable = btnLocalTable; |
178 |
this.lstLocalTables = lstLocalTables;
|
|
180 |
this.treeLocalTables = treeLocalTables;
|
|
179 | 181 |
|
180 | 182 |
this.entitiesToUnCheckAll = new HashSet<>(); |
181 | 183 |
|
... | ... | |
205 | 207 |
}); |
206 | 208 |
|
207 | 209 |
this.entitySelector = VCSGisEntitySelectorController.create( |
208 |
this.lstLocalTables,
|
|
210 |
this.treeLocalTables,
|
|
209 | 211 |
txtLocalTablesFilter, |
210 | 212 |
btnLocalTable |
211 | 213 |
); |
... | ... | |
216 | 218 |
doUpdateTableLocalChanges(); |
217 | 219 |
// doUpdateComponents(); |
218 | 220 |
}); |
219 |
this.entitySelector.getCheckedModel().addListSelectionListener((ListSelectionEvent e) -> { |
|
220 |
doUpdateTableLocalChanges(); |
|
221 |
doUpdateComponents(); |
|
221 |
this.entitySelector.addActionListener((ActionEvent e) -> { |
|
222 |
switch(e.getID()) { |
|
223 |
case VCSGisEntitySelectorController.ACTION_SELECT_ID: |
|
224 |
break; |
|
225 |
case VCSGisEntitySelectorController.ACTION_CHECK_ID: |
|
226 |
doUpdateTableLocalChanges(); |
|
227 |
doUpdateComponents(); |
|
228 |
break; |
|
229 |
} |
|
222 | 230 |
}); |
223 | 231 |
|
224 | 232 |
this.tblLocalChanges.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
... | ... | |
839 | 847 |
} |
840 | 848 |
|
841 | 849 |
public void selectOnlyAEntity(VCSGisEntity entity){ |
842 |
ListSelectionModel checkedModel = entitySelector.getCheckedModel(); |
|
843 |
checkedModel.clearSelection(); |
|
850 |
entitySelector.clearChecks(); |
|
844 | 851 |
entitySelector.check(entity); |
845 | 852 |
} |
846 | 853 |
|
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/VCSGisJChangesView.xml | ||
---|---|---|
24 | 24 |
</at> |
25 | 25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
26 | 26 |
</super> |
27 |
<at name="id">/home/jovivas/datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/VCSGisJChangesView.xml</at>
|
|
28 |
<at name="path">datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/VCSGisJChangesView.xml</at>
|
|
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/changes/VCSGisJChangesView.xml</at>
|
|
28 |
<at name="path">src/main/java/org/gvsig/vcsgis/swing/impl/changes/VCSGisJChangesView.xml</at> |
|
29 | 29 |
<at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at> |
30 | 30 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE</at> |
31 | 31 |
<at name="components"> |
... | ... | |
75 | 75 |
</object> |
76 | 76 |
</at> |
77 | 77 |
<at name="name">lblWorkspace</at> |
78 |
<at name="width">82</at>
|
|
78 |
<at name="width">104</at>
|
|
79 | 79 |
<at name="text">_Working_copy</at> |
80 | 80 |
<at name="fill"> |
81 | 81 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
82 | 82 |
<at name="name">fill</at> |
83 | 83 |
</object> |
84 | 84 |
</at> |
85 |
<at name="height">14</at>
|
|
85 |
<at name="height">15</at>
|
|
86 | 86 |
</object> |
87 | 87 |
</at> |
88 | 88 |
</object> |
... | ... | |
135 | 135 |
</object> |
136 | 136 |
</at> |
137 | 137 |
<at name="name">cboWorkspace</at> |
138 |
<at name="width">723</at>
|
|
138 |
<at name="width">722</at>
|
|
139 | 139 |
<at name="items"> |
140 | 140 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
141 | 141 |
<at name="name">items</at> |
142 | 142 |
</object> |
143 | 143 |
</at> |
144 |
<at name="height">20</at>
|
|
144 |
<at name="height">24</at>
|
|
145 | 145 |
</object> |
146 | 146 |
</at> |
147 | 147 |
</object> |
... | ... | |
210 | 210 |
<at name="embedded">false</at> |
211 | 211 |
<at name="path">datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/resources/org/gvsig/vcsgis/swing/impl/images/vcsgis-show-local-changes.png</at> |
212 | 212 |
<at name="description">vcsgis-show-local-changes.png</at> |
213 |
<at name="width">18</at>
|
|
214 |
<at name="height">18</at>
|
|
213 |
<at name="width">16</at>
|
|
214 |
<at name="height">16</at>
|
|
215 | 215 |
</object> |
216 | 216 |
</at> |
217 | 217 |
<at name="form"> |
... | ... | |
230 | 230 |
</at> |
231 | 231 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
232 | 232 |
</super> |
233 |
<at name="id">embedded.1432837974</at>
|
|
233 |
<at name="id">embedded.655454836</at>
|
|
234 | 234 |
<at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at> |
235 | 235 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.2),FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at> |
236 | 236 |
<at name="components"> |
... | ... | |
280 | 280 |
</object> |
281 | 281 |
</at> |
282 | 282 |
<at name="name">tblLocalChanges</at> |
283 |
<at name="width">629</at>
|
|
283 |
<at name="width">649</at>
|
|
284 | 284 |
<at name="scollBars"> |
285 | 285 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
286 | 286 |
<at name="name">scollBars</at> |
... | ... | |
333 | 333 |
</at> |
334 | 334 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
335 | 335 |
</super> |
336 |
<at name="id">embedded.115135752</at>
|
|
336 |
<at name="id">embedded.527141517</at>
|
|
337 | 337 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
338 | 338 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
339 | 339 |
<at name="components"> |
... | ... | |
594 | 594 |
</at> |
595 | 595 |
</object> |
596 | 596 |
</at> |
597 |
<at name="width">365</at>
|
|
597 |
<at name="width">372</at>
|
|
598 | 598 |
<at name="name"/> |
599 | 599 |
<at name="fill"> |
600 | 600 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
... | ... | |
1132 | 1132 |
</at> |
1133 | 1133 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
1134 | 1134 |
</super> |
1135 |
<at name="id">embedded.1916434937</at>
|
|
1135 |
<at name="id">embedded.1334617366</at>
|
|
1136 | 1136 |
<at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE</at> |
1137 | 1137 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MIN(12DLU;DEFAULT):GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE</at> |
1138 | 1138 |
<at name="components"> |
... | ... | |
1182 | 1182 |
</object> |
1183 | 1183 |
</at> |
1184 | 1184 |
<at name="name">lblLocalEffectiveDate</at> |
1185 |
<at name="width">85</at>
|
|
1185 |
<at name="width">105</at>
|
|
1186 | 1186 |
<at name="text">_Effective_date</at> |
1187 | 1187 |
<at name="fill"> |
1188 | 1188 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
... | ... | |
1190 | 1190 |
</object> |
1191 | 1191 |
</at> |
1192 | 1192 |
<at name="toolTipText">_Date_when_the_changes_made_will_take_effect</at> |
1193 |
<at name="height">14</at>
|
|
1193 |
<at name="height">15</at>
|
|
1194 | 1194 |
</object> |
1195 | 1195 |
</at> |
1196 | 1196 |
</object> |
... | ... | |
1243 | 1243 |
</object> |
1244 | 1244 |
</at> |
1245 | 1245 |
<at name="name">txtLocalEffectiveDate</at> |
1246 |
<at name="width">656</at>
|
|
1247 |
<at name="height">20</at>
|
|
1246 |
<at name="width">649</at>
|
|
1247 |
<at name="height">19</at>
|
|
1248 | 1248 |
</object> |
1249 | 1249 |
</at> |
1250 | 1250 |
</object> |
... | ... | |
1297 | 1297 |
</object> |
1298 | 1298 |
</at> |
1299 | 1299 |
<at name="name">txtLocalComment</at> |
1300 |
<at name="width">683</at>
|
|
1301 |
<at name="height">20</at>
|
|
1300 |
<at name="width">681</at>
|
|
1301 |
<at name="height">19</at>
|
|
1302 | 1302 |
</object> |
1303 | 1303 |
</at> |
1304 | 1304 |
</object> |
... | ... | |
1357 | 1357 |
<at name="actionCommand">...</at> |
1358 | 1358 |
<at name="opaque">false</at> |
1359 | 1359 |
<at name="name">btnLocalEffectiveDate</at> |
1360 |
<at name="width">16</at>
|
|
1360 |
<at name="width">19</at>
|
|
1361 | 1361 |
<at name="text">...</at> |
1362 |
<at name="height">18</at>
|
|
1362 |
<at name="height">19</at>
|
|
1363 | 1363 |
</object> |
1364 | 1364 |
</at> |
1365 | 1365 |
</object> |
... | ... | |
1412 | 1412 |
</object> |
1413 | 1413 |
</at> |
1414 | 1414 |
<at name="name">lblLocalComment</at> |
1415 |
<at name="width">85</at>
|
|
1415 |
<at name="width">105</at>
|
|
1416 | 1416 |
<at name="text">_Comment</at> |
1417 | 1417 |
<at name="fill"> |
1418 | 1418 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
1419 | 1419 |
<at name="name">fill</at> |
1420 | 1420 |
</object> |
1421 | 1421 |
</at> |
1422 |
<at name="height">14</at>
|
|
1422 |
<at name="height">15</at>
|
|
1423 | 1423 |
</object> |
1424 | 1424 |
</at> |
1425 | 1425 |
</object> |
... | ... | |
1564 | 1564 |
</at> |
1565 | 1565 |
<at name="horizontalAlignment">4</at> |
1566 | 1566 |
<at name="name">lblLocalChangesCount</at> |
1567 |
<at name="width">798</at>
|
|
1567 |
<at name="width">822</at>
|
|
1568 | 1568 |
<at name="text">0</at> |
1569 | 1569 |
<at name="fill"> |
1570 | 1570 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
1571 | 1571 |
<at name="name">fill</at> |
1572 | 1572 |
</object> |
1573 | 1573 |
</at> |
1574 |
<at name="height">14</at>
|
|
1574 |
<at name="height">15</at>
|
|
1575 | 1575 |
</object> |
1576 | 1576 |
</at> |
1577 | 1577 |
</object> |
... | ... | |
1596 | 1596 |
</at> |
1597 | 1597 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
1598 | 1598 |
</super> |
1599 |
<at name="id">embedded.1940623612</at>
|
|
1599 |
<at name="id">embedded.38594567</at>
|
|
1600 | 1600 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
1601 | 1601 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)</at> |
1602 | 1602 |
<at name="components"> |
... | ... | |
1842 | 1842 |
</at> |
1843 | 1843 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
1844 | 1844 |
</super> |
1845 |
<at name="id">embedded.Zd3cb15K177a682e96fBT7ffd</at>
|
|
1845 |
<at name="id">embedded.2014088196</at>
|
|
1846 | 1846 |
<at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0)</at> |
1847 | 1847 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
1848 | 1848 |
<at name="components"> |
... | ... | |
1854 | 1854 |
<at name="cellconstraints"> |
1855 | 1855 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
1856 | 1856 |
<at name="column">1</at> |
1857 |
<at name="row">3</at>
|
|
1858 |
<at name="colspan">3</at>
|
|
1857 |
<at name="row">1</at>
|
|
1858 |
<at name="colspan">1</at>
|
|
1859 | 1859 |
<at name="rowspan">1</at> |
1860 | 1860 |
<at name="halign">default</at> |
1861 | 1861 |
<at name="valign">default</at> |
... | ... | |
1865 | 1865 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
1866 | 1866 |
</super> |
1867 | 1867 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
1868 |
<at name="beanclass">javax.swing.JList</at>
|
|
1868 |
<at name="beanclass">javax.swing.JTextField</at>
|
|
1869 | 1869 |
<at name="beanproperties"> |
1870 | 1870 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
1871 |
<at name="classname">javax.swing.JList</at>
|
|
1871 |
<at name="classname">javax.swing.JTextField</at>
|
|
1872 | 1872 |
<at name="properties"> |
1873 | 1873 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
1874 | 1874 |
<at name="border"> |
... | ... | |
1891 | 1891 |
</at> |
1892 | 1892 |
</object> |
1893 | 1893 |
</at> |
1894 |
<at name="scrollableTracksViewportHeight">true</at> |
|
1895 |
<at name="scrollableTracksViewportWidth">true</at> |
|
1896 |
<at name="name">lstLocalTables</at> |
|
1897 |
<at name="width">149</at> |
|
1898 |
<at name="items"> |
|
1899 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
|
1900 |
<at name="name">items</at> |
|
1901 |
</object> |
|
1902 |
</at> |
|
1903 |
<at name="scollBars"> |
|
1904 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
1905 |
<at name="name">scollBars</at> |
|
1906 |
<at name="verticalpolicy">20</at> |
|
1907 |
<at name="horizontalpolicy">30</at> |
|
1908 |
<at name="border"> |
|
1909 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
1910 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
1911 |
<at name="name">border</at> |
|
1912 |
</super> |
|
1913 |
<at name="borders"> |
|
1914 |
<object classname="java.util.LinkedList"> |
|
1915 |
<item > |
|
1916 |
<at name="value"> |
|
1917 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
1918 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
1919 |
<at name="name">border</at> |
|
1920 |
</super> |
|
1921 |
</object> |
|
1922 |
</at> |
|
1923 |
</item> |
|
1924 |
</object> |
|
1925 |
</at> |
|
1926 |
</object> |
|
1927 |
</at> |
|
1928 |
</object> |
|
1929 |
</at> |
|
1930 |
<at name="height">79</at> |
|
1894 |
<at name="name">txtLocalTablesFilter</at> |
|
1895 |
<at name="width">120</at> |
|
1896 |
<at name="height">19</at> |
|
1931 | 1897 |
</object> |
1932 | 1898 |
</at> |
1933 | 1899 |
</object> |
... | ... | |
1941 | 1907 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
1942 | 1908 |
<at name="cellconstraints"> |
1943 | 1909 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
1944 |
<at name="column">1</at>
|
|
1910 |
<at name="column">3</at>
|
|
1945 | 1911 |
<at name="row">1</at> |
1946 | 1912 |
<at name="colspan">1</at> |
1947 | 1913 |
<at name="rowspan">1</at> |
... | ... | |
1953 | 1919 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
1954 | 1920 |
</super> |
1955 | 1921 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
1956 |
<at name="beanclass">javax.swing.JTextField</at>
|
|
1922 |
<at name="beanclass">javax.swing.JButton</at>
|
|
1957 | 1923 |
<at name="beanproperties"> |
1958 | 1924 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
1959 |
<at name="classname">javax.swing.JTextField</at>
|
|
1925 |
<at name="classname">javax.swing.JButton</at>
|
|
1960 | 1926 |
<at name="properties"> |
1961 | 1927 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
1962 | 1928 |
<at name="border"> |
... | ... | |
1968 | 1934 |
<object classname="java.util.LinkedList"> |
1969 | 1935 |
<item > |
1970 | 1936 |
<at name="value"> |
1971 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
|
|
1937 |
<object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
|
|
1972 | 1938 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
1973 | 1939 |
<at name="name">border</at> |
1974 | 1940 |
</super> |
1941 |
<at name="top">2</at> |
|
1942 |
<at name="left">2</at> |
|
1943 |
<at name="bottom">2</at> |
|
1944 |
<at name="right">2</at> |
|
1975 | 1945 |
</object> |
1976 | 1946 |
</at> |
1977 | 1947 |
</item> |
... | ... | |
1979 | 1949 |
</at> |
1980 | 1950 |
</object> |
1981 | 1951 |
</at> |
1982 |
<at name="name">txtLocalTablesFilter</at> |
|
1983 |
<at name="width">124</at> |
|
1984 |
<at name="height">20</at> |
|
1952 |
<at name="actionCommand">...</at> |
|
1953 |
<at name="opaque">false</at> |
|
1954 |
<at name="name">btnLocalTable</at> |
|
1955 |
<at name="width">19</at> |
|
1956 |
<at name="text">...</at> |
|
1957 |
<at name="height">19</at> |
|
1985 | 1958 |
</object> |
1986 | 1959 |
</at> |
1987 | 1960 |
</object> |
... | ... | |
1995 | 1968 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
1996 | 1969 |
<at name="cellconstraints"> |
1997 | 1970 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
1998 |
<at name="column">3</at>
|
|
1999 |
<at name="row">1</at>
|
|
2000 |
<at name="colspan">1</at>
|
|
1971 |
<at name="column">1</at>
|
|
1972 |
<at name="row">3</at>
|
|
1973 |
<at name="colspan">3</at>
|
|
2001 | 1974 |
<at name="rowspan">1</at> |
2002 | 1975 |
<at name="halign">default</at> |
2003 | 1976 |
<at name="valign">default</at> |
... | ... | |
2007 | 1980 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
2008 | 1981 |
</super> |
2009 | 1982 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
2010 |
<at name="beanclass">javax.swing.JButton</at>
|
|
1983 |
<at name="beanclass">javax.swing.JTree</at>
|
|
2011 | 1984 |
<at name="beanproperties"> |
2012 | 1985 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
2013 |
<at name="classname">javax.swing.JButton</at>
|
|
1986 |
<at name="classname">javax.swing.JTree</at>
|
|
2014 | 1987 |
<at name="properties"> |
2015 | 1988 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
2016 | 1989 |
<at name="border"> |
... | ... | |
2022 | 1995 |
<object classname="java.util.LinkedList"> |
2023 | 1996 |
<item > |
2024 | 1997 |
<at name="value"> |
2025 |
<object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
|
|
1998 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
|
|
2026 | 1999 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
2027 | 2000 |
<at name="name">border</at> |
2028 | 2001 |
</super> |
2029 |
<at name="top">2</at> |
|
2030 |
<at name="left">2</at> |
|
2031 |
<at name="bottom">2</at> |
|
2032 |
<at name="right">2</at> |
|
2033 | 2002 |
</object> |
2034 | 2003 |
</at> |
2035 | 2004 |
</item> |
... | ... | |
2037 | 2006 |
</at> |
2038 | 2007 |
</object> |
2039 | 2008 |
</at> |
2040 |
<at name="actionCommand">...</at> |
|
2041 |
<at name="opaque">false</at> |
|
2042 |
<at name="name">btnLocalTable</at> |
|
2043 |
<at name="width">16</at> |
|
2044 |
<at name="text">...</at> |
|
2045 |
<at name="height">18</at> |
|
2009 |
<at name="scrollableTracksViewportHeight">true</at> |
|
2010 |
<at name="scrollableTracksViewportWidth">true</at> |
|
2011 |
<at name="name">treeLocalTables</at> |
|
2012 |
<at name="width">149</at> |
|
2013 |
<at name="scollBars"> |
|
2014 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
2015 |
<at name="name">scollBars</at> |
|
2016 |
<at name="verticalpolicy">20</at> |
|
2017 |
<at name="horizontalpolicy">30</at> |
|
2018 |
</object> |
|
2019 |
</at> |
|
2020 |
<at name="height">123</at> |
|
2046 | 2021 |
</object> |
2047 | 2022 |
</at> |
2048 | 2023 |
</object> |
... | ... | |
2067 | 2042 |
</at> |
2068 | 2043 |
</object> |
2069 | 2044 |
</at> |
2070 |
<at name="name"></at>
|
|
2045 |
<at name="name"/>
|
|
2071 | 2046 |
<at name="fill"> |
2072 | 2047 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
2073 | 2048 |
<at name="name">fill</at> |
... | ... | |
2078 | 2053 |
<at name="name">scollBars</at> |
2079 | 2054 |
<at name="verticalpolicy">21</at> |
2080 | 2055 |
<at name="horizontalpolicy">31</at> |
2056 |
<at name="border"> |
|
2057 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
2058 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
2059 |
<at name="name">border</at> |
|
2060 |
</super> |
|
2061 |
<at name="borders"> |
|
2062 |
<object classname="java.util.LinkedList"> |
|
2063 |
<item > |
|
2064 |
<at name="value"> |
|
2065 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
2066 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
2067 |
<at name="name">border</at> |
|
2068 |
</super> |
|
2069 |
</object> |
|
2070 |
</at> |
|
2071 |
</item> |
|
2072 |
</object> |
|
2073 |
</at> |
|
2074 |
</object> |
|
2075 |
</at> |
|
2081 | 2076 |
</object> |
2082 | 2077 |
</at> |
2083 | 2078 |
</object> |
... | ... | |
2236 | 2231 |
<at name="embedded">false</at> |
2237 | 2232 |
<at name="path">datos/devel/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/resources/org/gvsig/vcsgis/swing/impl/images/vcsgis-show-remote-changes.png</at> |
2238 | 2233 |
<at name="description">vcsgis-show-remote-changes.png</at> |
2239 |
<at name="width">18</at>
|
|
2240 |
<at name="height">18</at>
|
|
2234 |
<at name="width">16</at>
|
|
2235 |
<at name="height">16</at>
|
|
2241 | 2236 |
</object> |
2242 | 2237 |
</at> |
2243 | 2238 |
<at name="form"> |
... | ... | |
2256 | 2251 |
</at> |
2257 | 2252 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
2258 | 2253 |
</super> |
2259 |
<at name="id">embedded.1009625553</at>
|
|
2254 |
<at name="id">embedded.663199445</at>
|
|
2260 | 2255 |
<at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at> |
2261 | 2256 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.2),FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.8),FILL:4DLU:NONE</at> |
2262 | 2257 |
<at name="components"> |
... | ... | |
2306 | 2301 |
</object> |
2307 | 2302 |
</at> |
2308 | 2303 |
<at name="name">tblRemoteChanges</at> |
2309 |
<at name="width">617</at>
|
|
2304 |
<at name="width">633</at>
|
|
2310 | 2305 |
<at name="scollBars"> |
2311 | 2306 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
2312 | 2307 |
<at name="name">scollBars</at> |
... | ... | |
2389 | 2384 |
<at name="scrollableTracksViewportHeight">true</at> |
2390 | 2385 |
<at name="scrollableTracksViewportWidth">true</at> |
2391 | 2386 |
<at name="name">lstRemoteTables</at> |
2392 |
<at name="width">166</at>
|
|
2387 |
<at name="width">170</at>
|
|
2393 | 2388 |
<at name="items"> |
2394 | 2389 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
2395 | 2390 |
<at name="name">items</at> |
... | ... | |
2422 | 2417 |
</at> |
2423 | 2418 |
</object> |
2424 | 2419 |
</at> |
2425 |
<at name="height">251</at>
|
|
2420 |
<at name="height">293</at>
|
|
2426 | 2421 |
</object> |
2427 | 2422 |
</at> |
2428 | 2423 |
</object> |
... | ... | |
2476 | 2471 |
</at> |
2477 | 2472 |
<at name="horizontalAlignment">4</at> |
2478 | 2473 |
<at name="name">lblRemoteChangesCount</at> |
2479 |
<at name="width">619</at>
|
|
2474 |
<at name="width">636</at>
|
|
2480 | 2475 |
<at name="text">0</at> |
2481 | 2476 |
<at name="fill"> |
2482 | 2477 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
2483 | 2478 |
<at name="name">fill</at> |
2484 | 2479 |
</object> |
2485 | 2480 |
</at> |
2486 |
<at name="height">14</at>
|
|
2481 |
<at name="height">15</at>
|
|
2487 | 2482 |
</object> |
2488 | 2483 |
</at> |
2489 | 2484 |
</object> |
... | ... | |
2508 | 2503 |
</at> |
2509 | 2504 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
2510 | 2505 |
</super> |
2511 |
<at name="id">embedded.1037349340</at>
|
|
2506 |
<at name="id">embedded.1004352493</at>
|
|
2512 | 2507 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
2513 | 2508 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
2514 | 2509 |
<at name="components"> |
... | ... | |
3317 | 3312 |
</at> |
3318 | 3313 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
3319 | 3314 |
</super> |
3320 |
<at name="id">embedded.881707425</at>
|
|
3315 |
<at name="id">embedded.1609938516</at>
|
|
3321 | 3316 |
<at name="rowspecs">CENTER:DEFAULT:NONE</at> |
3322 | 3317 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE</at> |
3323 | 3318 |
<at name="components"> |
... | ... | |
3717 | 3712 |
</at> |
3718 | 3713 |
</object> |
3719 | 3714 |
</at> |
3720 |
<at name="width">843</at>
|
|
3715 |
<at name="width">871</at>
|
|
3721 | 3716 |
<at name="tabCount">2</at> |
3722 |
<at name="height">391</at>
|
|
3717 |
<at name="height">433</at>
|
|
3723 | 3718 |
</object> |
3724 | 3719 |
</at> |
3725 | 3720 |
</object> |
... | ... | |
3778 | 3773 |
<at name="actionCommand">...</at> |
3779 | 3774 |
<at name="opaque">false</at> |
3780 | 3775 |
<at name="name">btnWorkspace</at> |
3781 |
<at name="width">16</at>
|
|
3776 |
<at name="width">19</at>
|
|
3782 | 3777 |
<at name="text">...</at> |
3783 |
<at name="height">18</at>
|
|
3778 |
<at name="height">19</at>
|
|
3784 | 3779 |
</object> |
3785 | 3780 |
</at> |
3786 | 3781 |
</object> |
... | ... | |
3805 | 3800 |
</at> |
3806 | 3801 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
3807 | 3802 |
</super> |
3808 |
<at name="id">embedded.757837019</at>
|
|
3803 |
<at name="id">embedded.1591145980</at>
|
|
3809 | 3804 |
<at name="rowspecs">CENTER:MIN(16PX;DEFAULT):NONE,CENTER:MIN(16PX;DEFAULT):NONE,CENTER:MIN(16PX;DEFAULT):NONE</at> |
3810 | 3805 |
<at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE</at> |
3811 | 3806 |
<at name="components"> |
... | ... | |
3855 | 3850 |
</object> |
3856 | 3851 |
</at> |
3857 | 3852 |
<at name="name">lblStatusCaption</at> |
3858 |
<at name="width">822</at>
|
|
3853 |
<at name="width">850</at>
|
|
3859 | 3854 |
<at name="fill"> |
3860 | 3855 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
3861 | 3856 |
<at name="name">fill</at> |
... | ... | |
3914 | 3909 |
</object> |
3915 | 3910 |
</at> |
3916 | 3911 |
<at name="name">lblStatusMessages</at> |
3917 |
<at name="width">822</at>
|
|
3912 |
<at name="width">850</at>
|
|
3918 | 3913 |
<at name="fill"> |
3919 | 3914 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
3920 | 3915 |
<at name="name">fill</at> |
... | ... | |
3973 | 3968 |
</object> |
3974 | 3969 |
</at> |
3975 | 3970 |
<at name="name">pbStatus</at> |
3976 |
<at name="width">822</at>
|
|
3971 |
<at name="width">850</at>
|
|
3977 | 3972 |
<at name="percentComplete">0.25</at> |
3978 | 3973 |
<at name="value">25</at> |
3979 | 3974 |
<at name="height">12</at> |
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.swing/org.gvsig.vcsgis.swing.impl/src/main/java/org/gvsig/vcsgis/swing/impl/VCSGisEntitySelectorControllerJTree.java | ||
---|---|---|
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; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Cursor; |
|
26 |
import java.awt.FlowLayout; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.HashSet; |
|
32 |
import java.util.List; |
|
33 |
import java.util.Map; |
|
34 |
import java.util.Set; |
|
35 |
import java.util.TreeMap; |
|
36 |
import java.util.function.Predicate; |
|
37 |
import javax.swing.AbstractCellEditor; |
|
38 |
import javax.swing.JButton; |
|
39 |
import javax.swing.JCheckBox; |
|
40 |
import javax.swing.JLabel; |
|
41 |
import javax.swing.JOptionPane; |
|
42 |
import javax.swing.JPanel; |
|
43 |
import javax.swing.JTextField; |
|
44 |
import javax.swing.JTree; |
|
45 |
import javax.swing.event.ChangeListener; |
|
46 |
import javax.swing.event.TreeSelectionEvent; |
|
47 |
import javax.swing.event.TreeSelectionListener; |
|
48 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
49 |
import javax.swing.tree.DefaultTreeCellRenderer; |
|
50 |
import javax.swing.tree.DefaultTreeModel; |
|
51 |
import javax.swing.tree.TreeCellEditor; |
|
52 |
import javax.swing.tree.TreeCellRenderer; |
|
53 |
import javax.swing.tree.TreePath; |
|
54 |
import static javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION; |
|
55 |
import org.apache.commons.lang3.StringUtils; |
|
56 |
import org.gvsig.tools.ToolsLocator; |
|
57 |
import org.gvsig.tools.i18n.I18nManager; |
|
58 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
|
59 |
import org.gvsig.tools.swing.api.ChangeListenerHelper; |
|
60 |
import org.gvsig.tools.swing.api.FilteredTreeController; |
|
61 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
62 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
63 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
64 |
import org.gvsig.tools.util.LabeledValue; |
|
65 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
66 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
67 |
import static org.gvsig.vcsgis.lib.VCSGisManager.STATE_REPOSITORY_NEW; |
|
68 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
69 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
70 |
import static org.gvsig.vcsgis.swing.impl.VCSGisSwingCommons.notInSwingThreadInvokeLater; |
|
71 |
import org.slf4j.Logger; |
|
72 |
import org.slf4j.LoggerFactory; |
|
73 |
|
|
74 |
/** |
|
75 |
* |
|
76 |
* @author gvSIG Team |
|
77 |
*/ |
|
78 |
public class VCSGisEntitySelectorControllerJTree |
|
79 |
implements |
|
80 |
VCSGisEntitySelectorController { |
|
81 |
|
|
82 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisEntitySelectorControllerJTree.class); |
|
83 |
|
|
84 |
private final JTextField txtFilter; |
|
85 |
private final JTree treeEntities; |
|
86 |
private Set<String> checkedEntityCodes; |
|
87 |
private Map<String, VCSGisEntity> entities; |
|
88 |
private Map<String, DefaultMutableTreeNode> entityNodes; |
|
89 |
private final JButton btnEntities; |
|
90 |
private FilteredTreeController filteredTree; |
|
91 |
private ActionListenerSupport actionListeners; |
|
92 |
private ChangeListenerHelper changeListeners; |
|
93 |
private VCSGisWorkspace workspace; |
|
94 |
private boolean processing; |
|
95 |
private boolean enabled; |
|
96 |
private Predicate<VCSGisEntity> viewFilter; |
|
97 |
private Predicate<VCSGisEntity> filter; |
|
98 |
private boolean checksEnabled; |
|
99 |
|
|
100 |
private class EntityCellEditor extends AbstractCellEditor implements TreeCellEditor { |
|
101 |
|
|
102 |
@Override |
|
103 |
public Object getCellEditorValue() { |
|
104 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { |
|
109 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
private class EntityCellRenderer extends DefaultTreeCellRenderer { |
|
115 |
|
|
116 |
private final JCheckBox check; |
|
117 |
private final JLabel icon; |
|
118 |
private final JPanel panel; |
|
119 |
private final JLabel label; |
|
120 |
|
|
121 |
public EntityCellRenderer() { |
|
122 |
this.check = new JCheckBox(); |
|
123 |
this.icon = new JLabel(); |
|
124 |
this.label = new JLabel(); |
|
125 |
this.panel = new JPanel(); |
|
126 |
this.panel.setOpaque(false); |
|
127 |
this.icon.setOpaque(false); |
|
128 |
this.check.setOpaque(false); |
|
129 |
this.panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 2,1)); |
|
130 |
this.panel.add(this.icon); |
|
131 |
this.panel.add(this.check); |
|
132 |
this.panel.add(this.label); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { |
|
137 |
JLabel c = (JLabel) super.getTreeCellRendererComponent(tree, value, leaf, expanded, leaf, row, hasFocus); |
|
138 |
this.icon.setIcon(c.getIcon()); |
|
139 |
this.label.setText(c.getText()); |
|
140 |
this.label.setForeground(c.getForeground()); |
|
141 |
this.label.setBackground(c.getBackground()); |
|
142 |
if( checksEnabled ) { |
|
143 |
this.check.setVisible(true); |
|
144 |
this.check.setForeground(c.getForeground()); |
|
145 |
this.check.setBackground(c.getBackground()); |
|
146 |
this.check.setEnabled(false); |
|
147 |
this.check.setSelected(false); |
|
148 |
if( value instanceof LabeledValue ) { |
|
149 |
VCSGisEntity entity = ((LabeledValue<VCSGisEntity>) value).getValue(); |
|
150 |
if( entity != null ) { |
|
151 |
this.check.setEnabled(true); |
|
152 |
this.check.setSelected(checkedEntityCodes.contains(entity.getEntityCode())); |
|
153 |
} |
|
154 |
} else if( value instanceof String ) { |
|
155 |
this.check.setVisible(false); |
|
156 |
} |
|
157 |
} else { |
|
158 |
this.check.setVisible(false); |
|
159 |
} |
|
160 |
return this.panel; |
|
161 |
} |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
public VCSGisEntitySelectorControllerJTree(JTree treeEntities) { |
|
166 |
this(treeEntities, null, null); |
|
167 |
} |
|
168 |
|
|
169 |
public VCSGisEntitySelectorControllerJTree(JTree treeEntities, JTextField txtFilter, JButton btnTable) { |
|
170 |
viewFilter = ALL_ENTITIES; |
|
171 |
filter = ALL_ENTITIES; |
|
172 |
|
|
173 |
this.treeEntities = treeEntities; |
|
174 |
this.checkedEntityCodes = new HashSet<>(); |
|
175 |
this.entityNodes = new TreeMap<>(); |
|
176 |
if (txtFilter == null) { |
|
177 |
this.txtFilter = new JTextField(); |
|
178 |
} else { |
|
179 |
this.txtFilter = txtFilter; |
|
180 |
} |
|
181 |
if (btnTable == null) { |
|
182 |
this.btnEntities = new JButton(); |
|
183 |
} else { |
|
184 |
this.btnEntities = btnTable; |
|
185 |
} |
|
186 |
this.processing = false; |
|
187 |
|
|
188 |
this.initComponents(); |
|
189 |
} |
|
190 |
|
|
191 |
private void initComponents() { |
|
192 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
193 |
|
|
194 |
this.actionListeners = toolsSwingManager.createActionListenerSupport(); |
|
195 |
this.changeListeners = toolsSwingManager.createChangeListenerHelper(); |
|
196 |
|
|
197 |
this.btnEntities.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
198 |
|
|
199 |
this.treeEntities.getSelectionModel().setSelectionMode(SINGLE_TREE_SELECTION); |
|
200 |
this.treeEntities.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { |
|
201 |
@Override |
|
202 |
public void valueChanged(TreeSelectionEvent e) { |
|
203 |
fireActionEvent(new ActionEvent(this, 0, ACTION_SELECT)); |
|
204 |
} |
|
205 |
}); |
|
206 |
treeEntities.setModel(new DefaultTreeModel(new DefaultMutableTreeNode())); |
|
207 |
filteredTree = toolsSwingManager.createFilteredTreeController(treeEntities, txtFilter, btnEntities); |
|
208 |
this.treeEntities.setCellRenderer(new EntityCellRenderer()); |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
@Override |
|
213 |
public boolean isProcessing() { |
|
214 |
return this.processing; |
|
215 |
} |
|
216 |
|
|
217 |
@Override |
|
218 |
public VCSGisEntity getSelectedEntity() { |
|
219 |
if (this.workspace == null) { |
|
220 |
return null; |
|
221 |
} |
|
222 |
TreePath path = treeEntities.getSelectionPath(); |
|
223 |
if (path == null) { |
|
224 |
return null; |
|
225 |
} |
|
226 |
LabeledValue selected = (LabeledValue) path.getLastPathComponent(); |
|
227 |
if (selected == null) { |
|
228 |
return null; |
|
229 |
} |
|
230 |
VCSGisEntity entity = (VCSGisEntity) selected.getValue(); |
|
231 |
if (!this.filter.test(entity)) { |
|
232 |
return null; |
|
233 |
} |
|
234 |
return entity; |
|
235 |
} |
|
236 |
|
|
237 |
@Override |
|
238 |
public List<VCSGisEntity> getCheckedEntities() { |
|
239 |
List<VCSGisEntity> checkedEntities = new ArrayList<>(); |
|
240 |
for (String entityCode : this.checkedEntityCodes) { |
|
241 |
checkedEntities.add(this.entities.get(entityCode)); |
|
242 |
} |
|
243 |
return checkedEntities; |
|
244 |
} |
|
245 |
|
|
246 |
@Override |
|
247 |
public void setWorkspace(VCSGisWorkspace workspace) { |
|
248 |
this.workspace = workspace; |
|
249 |
if (workspace == null) { |
|
250 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
251 |
treeEntities.setModel(new DefaultTreeModel(new DefaultMutableTreeNode())); |
|
252 |
filteredTree = toolsSwingManager.createFilteredTreeController(treeEntities, txtFilter, btnEntities); |
|
253 |
return; |
|
254 |
} |
|
255 |
Thread task = new Thread(() -> { |
|
256 |
reloadEntities(this.workspace); |
|
257 |
}, "VCSGisEntitySelectorReloadEntities"); |
|
258 |
task.start(); |
|
259 |
} |
|
260 |
|
|
261 |
@Override |
|
262 |
public VCSGisWorkspace getWorkspace() { |
|
263 |
return this.workspace; |
|
264 |
} |
|
265 |
|
|
266 |
private void reloadEntities(VCSGisWorkspace workspace) { |
|
267 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
268 |
try { |
|
269 |
this.processing = true; |
|
270 |
this.doUpdateComponents(); |
|
271 |
workspace.reloadRepositoryEntities(null); |
|
272 |
List<VCSGisEntity> repoEntities = workspace.getRepositoryEntities(); |
|
273 |
|
|
274 |
this.entityNodes = new TreeMap<>(); |
|
275 |
this.entities = new HashMap<>(); |
|
276 |
|
|
277 |
for (VCSGisEntity rentity : repoEntities) { |
|
278 |
VCSGisEntity entity = rentity; |
|
279 |
VCSGisWorkspaceEntity lentity = workspace.getWorkspaceEntityByCode(rentity.getEntityCode()); |
|
280 |
LabeledValue entry; |
|
281 |
String s = VCSGisSwingCommons.getHTMLColorTag( |
|
282 |
lentity == null ? STATE_REPOSITORY_NEW : lentity.getState(), |
|
283 |
rentity.getEntityName() |
|
284 |
); |
|
285 |
if (lentity != null) { |
|
286 |
entity = lentity; |
|
287 |
} |
|
288 |
if (this.viewFilter.test(entity)) { |
|
289 |
this.entities.put(entity.getEntityCode(), entity); |
|
290 |
entry = new LabeledValueImpl(s, entity); |
|
291 |
String category = StringUtils.trimToEmpty(entity.getCategory()); |
|
292 |
DefaultMutableTreeNode branch = entityNodes.get(category); |
|
293 |
if (branch == null) { |
|
294 |
branch = new DefaultMutableTreeNode(category, true); |
|
295 |
entityNodes.put(category, branch); |
|
296 |
} |
|
297 |
branch.add(new DefaultMutableTreeNode(entry, false)); |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
List<VCSGisWorkspaceEntity> localEntities = workspace.getWorkspaceEntities(); |
|
302 |
for (VCSGisWorkspaceEntity localEntity : localEntities) { |
|
303 |
if (StringUtils.isBlank(localEntity.getRepositoryRevisionCode())) { |
|
304 |
if (!this.viewFilter.test(localEntity)) { |
|
305 |
continue; |
|
306 |
} |
|
307 |
LabeledValue entry; |
|
308 |
String s = VCSGisSwingCommons.getHTMLColorTag( |
|
309 |
localEntity.getState(), |
|
310 |
localEntity.getEntityName() |
|
311 |
); |
|
312 |
this.entities.put(localEntity.getEntityCode(), localEntity); |
|
313 |
entry = new LabeledValueImpl(s, localEntity); |
|
314 |
String category = StringUtils.trimToEmpty(localEntity.getCategory()); |
|
315 |
DefaultMutableTreeNode branch = entityNodes.get(category); |
|
316 |
if (branch == null) { |
|
317 |
branch = new DefaultMutableTreeNode(category, true); |
|
318 |
entityNodes.put(category, branch); |
|
319 |
} |
|
320 |
branch.add(new DefaultMutableTreeNode(entry, false)); |
|
321 |
} |
|
322 |
} |
|
323 |
|
|
324 |
DefaultMutableTreeNode root = new DefaultMutableTreeNode(); |
|
325 |
for (DefaultMutableTreeNode node : entityNodes.values()) { |
|
326 |
root.add(node); |
|
327 |
} |
|
328 |
postReloadEntities(root); |
|
329 |
|
|
330 |
} catch (Exception e) { |
|
331 |
LOGGER.warn("_Cant_retrieve_entities_from_repository", e); |
|
332 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
333 |
dialogs.messageDialog( |
|
334 |
i18n.getTranslation("_Cant_retrieve_entities_from_repository") + "\n" + e.getMessage(), |
|
335 |
i18n.getTranslation("_Checkout"), |
|
336 |
JOptionPane.WARNING_MESSAGE |
|
337 |
); |
|
338 |
} finally { |
|
339 |
this.processing = false; |
|
340 |
this.doUpdateComponents(); |
|
341 |
} |
|
342 |
|
|
343 |
} |
|
344 |
|
|
345 |
private void postReloadEntities(DefaultMutableTreeNode entities) { |
|
346 |
if (notInSwingThreadInvokeLater(() -> { |
|
347 |
postReloadEntities(entities); |
|
348 |
})) { |
|
349 |
return; |
|
350 |
} |
|
351 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
Also available in: Unified diff