Revision 43354
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/FeatureTableConfigurationPanel.java | ||
---|---|---|
87 | 87 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
88 | 88 |
add(scrollPane); |
89 | 89 |
} |
90 |
|
|
90 |
|
|
91 |
public String getFormattingPattern(String columnName) { |
|
92 |
String pattern = this.tableModel.getFormattingPattern(columnName); |
|
93 |
return pattern; |
|
94 |
} |
|
95 |
|
|
96 |
public void setFormattingPattern(String columnName, String pattern) { |
|
97 |
tableModel.setFormattingPattern(columnName, pattern); |
|
98 |
} |
|
99 |
|
|
91 | 100 |
/** |
92 | 101 |
* Make current changes in configuration (visible columns and aliases) |
93 | 102 |
* as definitive. |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/dal/feature/swing/table/ConfigurationTableModel.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
private static final long serialVersionUID = -825156698327593853L; |
46 | 46 |
|
47 |
private static final int VISIBILITY_COLUMN = 0;
|
|
48 |
private static final int NAME_COLUMN = 1;
|
|
49 |
private static final int ALIAS_COLUMN = 2;
|
|
50 |
private static final int TYPE_COLUMN = 3;
|
|
51 |
private static final int SIZE_COLUMN = 4;
|
|
52 |
private static final int PRECISION_COLUMN = 5;
|
|
53 |
private static final int PATTERN_COLUMN = 6;
|
|
47 |
public static final int VISIBILITY_COLUMN = 0;
|
|
48 |
public static final int NAME_COLUMN = 1;
|
|
49 |
public static final int ALIAS_COLUMN = 2;
|
|
50 |
public static final int TYPE_COLUMN = 3;
|
|
51 |
public static final int SIZE_COLUMN = 4;
|
|
52 |
public static final int PRECISION_COLUMN = 5;
|
|
53 |
public static final int PATTERN_COLUMN = 6;
|
|
54 | 54 |
|
55 | 55 |
private static final int COLUMN_COUNT = 7; |
56 | 56 |
|
... | ... | |
200 | 200 |
public void cancelChanges() { |
201 | 201 |
configurable.cancelChanges(); |
202 | 202 |
} |
203 |
|
|
204 |
public String getFormattingPattern(String columnName) { |
|
205 |
return configurable.getFormattingPattern(columnName); |
|
206 |
} |
|
207 |
|
|
208 |
public void setFormattingPattern(String columnName, String pattern) { |
|
209 |
configurable.setFormattingPattern(columnName, pattern); |
|
210 |
} |
|
203 | 211 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java | ||
---|---|---|
181 | 181 |
.setClassOfValue(FeatureQueryOrder.class).setMandatory(false); |
182 | 182 |
factory.persistenceDefinition.addDynFieldList("linkTable") |
183 | 183 |
.setClassOfItems(TableLink.class).setMandatory(false); |
184 |
factory.persistenceDefinition.addDynFieldMap("patterns") |
|
185 |
.setClassOfItems(String.class).setMandatory(false); |
|
184 | 186 |
} |
185 | 187 |
|
186 | 188 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/FeatureTableDocumentPanel.java | ||
---|---|---|
43 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
44 | 44 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
45 | 45 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
46 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
46 | 47 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.FeatureTypesTablePanel; |
47 | 48 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.notification.ColumnHeaderSelectionChangeNotification; |
48 | 49 |
import org.gvsig.tools.observer.Observable; |
... | ... | |
81 | 82 |
super(((TableDocument) document).getFeatureStoreModel()); |
82 | 83 |
this.model = (TableDocument) document; |
83 | 84 |
initialize(); |
85 |
try { |
|
86 |
FeatureType featureType = model.getFeatureStore().getDefaultFeatureType(); |
|
87 |
for( FeatureAttributeDescriptor descriptor : featureType) { |
|
88 |
this.getTableModel().setFormattingPattern( |
|
89 |
descriptor.getName(), |
|
90 |
model.getFormattingPattern(descriptor.getName()) |
|
91 |
); |
|
92 |
} |
|
93 |
} catch (DataException ex) { |
|
94 |
LOG.warn("Can't initialize columns formating patters",ex); |
|
95 |
} |
|
96 |
|
|
84 | 97 |
} |
85 | 98 |
|
86 | 99 |
public JComponent asJComponent() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/gui/GeneralTablePropertiesPage.java | ||
---|---|---|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.util.Locale; |
5 | 5 |
import java.util.Set; |
6 |
import javax.swing.ComboBoxModel; |
|
7 | 6 |
import javax.swing.JComponent; |
8 | 7 |
import org.gvsig.andami.LocaleManager; |
9 | 8 |
import org.gvsig.andami.PluginsLocator; |
10 | 9 |
import org.gvsig.app.project.documents.table.TableDocument; |
10 |
import org.gvsig.fmap.dal.exception.DataException; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
12 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
11 | 13 |
import org.gvsig.fmap.mapcontrol.dal.feature.swing.table.FeatureTableConfigurationPanel; |
12 | 14 |
import org.gvsig.propertypage.PropertiesPage; |
13 | 15 |
import org.gvsig.tools.ToolsLocator; |
14 | 16 |
import org.gvsig.tools.i18n.I18nManager; |
17 |
import org.slf4j.Logger; |
|
18 |
import org.slf4j.LoggerFactory; |
|
15 | 19 |
|
16 | 20 |
public class GeneralTablePropertiesPage extends GeneralTablePropertiesPageLayout implements PropertiesPage { |
17 | 21 |
|
22 |
private static final Logger logger = LoggerFactory.getLogger(GeneralTablePropertiesPage.class); |
|
23 |
|
|
18 | 24 |
private static final long serialVersionUID = -8639908797829738997L; |
19 | 25 |
private final TableDocument tableDocument; |
20 | 26 |
private FeatureTableConfigurationPanel columnsConfigurationPanel = null; |
... | ... | |
24 | 30 |
this.tableDocument = tableDocument; |
25 | 31 |
this.localeManager = PluginsLocator.getLocaleManager(); |
26 | 32 |
this.initComponents(); |
33 |
try { |
|
34 |
FeatureType featureType = tableDocument.getFeatureStore().getDefaultFeatureType(); |
|
35 |
for( FeatureAttributeDescriptor descriptor : featureType) { |
|
36 |
this.columnsConfigurationPanel.setFormattingPattern( |
|
37 |
descriptor.getName(), |
|
38 |
tableDocument.getFormattingPattern(descriptor.getName()) |
|
39 |
); |
|
40 |
} |
|
41 |
} catch (DataException ex) { |
|
42 |
logger.warn("Can't initialize columns formating patters",ex); |
|
43 |
} |
|
27 | 44 |
} |
28 | 45 |
|
29 | 46 |
private void initComponents() { |
... | ... | |
97 | 114 |
return whenApply(); |
98 | 115 |
} |
99 | 116 |
|
117 |
@Override |
|
100 | 118 |
public boolean whenApply() { |
101 | 119 |
tableDocument.setName(txtName.getText()); |
102 | 120 |
tableDocument.setCreationDate(txtDate.getText()); |
... | ... | |
105 | 123 |
tableDocument.getFeatureStoreModel().getCurrentFeatureTableModel() |
106 | 124 |
.setLocaleOfData(getLocaleOfData()); |
107 | 125 |
getColumnsConfigurationPanel().accept(); |
126 |
try { |
|
127 |
FeatureType featureType = tableDocument.getFeatureStore().getDefaultFeatureType(); |
|
128 |
for( FeatureAttributeDescriptor descriptor : featureType) { |
|
129 |
tableDocument.setFormattingPattern( |
|
130 |
descriptor.getName(), |
|
131 |
this.columnsConfigurationPanel.getFormattingPattern(descriptor.getName()) |
|
132 |
); |
|
133 |
} |
|
134 |
} catch (DataException ex) { |
|
135 |
logger.warn("Can't set columns formating patters in the table document",ex); |
|
136 |
} |
|
137 |
|
|
108 | 138 |
return true; |
109 | 139 |
} |
110 | 140 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableDocument.java | ||
---|---|---|
28 | 28 |
package org.gvsig.app.project.documents.table; |
29 | 29 |
|
30 | 30 |
import java.text.MessageFormat; |
31 |
import java.text.SimpleDateFormat; |
|
31 | 32 |
import java.util.ArrayList; |
33 |
import java.util.HashMap; |
|
32 | 34 |
import java.util.Iterator; |
33 | 35 |
import java.util.List; |
36 |
import java.util.Map; |
|
34 | 37 |
|
35 | 38 |
import org.gvsig.andami.messages.NotificationManager; |
36 | 39 |
import org.gvsig.app.project.ProjectManager; |
37 | 40 |
import org.gvsig.app.project.documents.AbstractDocument; |
38 | 41 |
import org.gvsig.app.project.documents.DocumentManager; |
42 |
import org.gvsig.fmap.dal.DataTypes; |
|
39 | 43 |
import org.gvsig.fmap.dal.exception.DataException; |
40 | 44 |
import org.gvsig.fmap.dal.feature.Feature; |
41 | 45 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
... | ... | |
91 | 95 |
|
92 | 96 |
private FeatureStoreModel featureStoreModel; |
93 | 97 |
|
94 |
private Object lock = new Object(); |
|
98 |
// private final Object lock = new Object(); |
|
99 |
|
|
100 |
private Map<String,String> patterns = null; |
|
95 | 101 |
|
96 | 102 |
public TableDocument(DocumentManager factory) { |
97 | 103 |
super(factory); |
... | ... | |
100 | 106 |
this.featureTypeId = null; |
101 | 107 |
this.baseFilter = null; |
102 | 108 |
this.baseOrder = null; |
109 |
this.patterns = null; |
|
103 | 110 |
} |
104 | 111 |
|
105 | 112 |
public TableDocument() { |
... | ... | |
111 | 118 |
setStore(store); |
112 | 119 |
} |
113 | 120 |
|
114 |
public FeatureStoreModel getFeatureStoreModel() { |
|
115 |
synchronized (lock) { |
|
116 |
if (this.featureStoreModel == null) { |
|
117 |
try { |
|
118 |
this.featureStoreModel = |
|
119 |
new FeatureStoreModel(getStore(), getQuery()); |
|
120 |
} catch (BaseException e) { |
|
121 |
NotificationManager.addError(e); |
|
122 |
} |
|
121 |
public synchronized FeatureStoreModel getFeatureStoreModel() { |
|
122 |
if (this.featureStoreModel == null) { |
|
123 |
try { |
|
124 |
this.featureStoreModel = |
|
125 |
new FeatureStoreModel(getStore(), getQuery()); |
|
126 |
} catch (BaseException e) { |
|
127 |
NotificationManager.addError(e); |
|
123 | 128 |
} |
124 | 129 |
} |
125 | 130 |
return this.featureStoreModel; |
... | ... | |
133 | 138 |
this.store = store; |
134 | 139 |
this.store.addObserver(this); |
135 | 140 |
this.query = null; // setQuery(store.createFeatureQuery()); |
141 |
initializeFormattingPatterns(); |
|
136 | 142 |
} |
137 | 143 |
|
144 |
private void initializeFormattingPatterns() { |
|
145 |
FeatureType featureType; |
|
146 |
try { |
|
147 |
featureType = this.store.getDefaultFeatureType(); |
|
148 |
} catch (DataException ex) { |
|
149 |
logger.warn("Can't initialize formating patterns", ex); |
|
150 |
return; |
|
151 |
} |
|
152 |
this.patterns = new HashMap<>(); |
|
153 |
for( FeatureAttributeDescriptor descriptor : featureType ) { |
|
154 |
String pattern = null; |
|
155 |
switch( descriptor.getDataType().getType() ) { |
|
156 |
case DataTypes.BYTE: |
|
157 |
case DataTypes.INT: |
|
158 |
case DataTypes.LONG: |
|
159 |
pattern = "#,##0"; |
|
160 |
break; |
|
161 |
case DataTypes.DOUBLE: |
|
162 |
pattern = "#,##0.0000000000"; |
|
163 |
break; |
|
164 |
case DataTypes.FLOAT: |
|
165 |
pattern = "#,##0.0000"; |
|
166 |
break; |
|
167 |
case DataTypes.DATE: |
|
168 |
pattern = new SimpleDateFormat().toPattern(); |
|
169 |
break; |
|
170 |
} |
|
171 |
this.patterns.put(descriptor.getName(), pattern); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
public String getFormattingPattern(String columnName) { |
|
176 |
if( this.patterns==null ) { |
|
177 |
return null; |
|
178 |
} |
|
179 |
String pattern = this.patterns.get(columnName); |
|
180 |
return pattern; |
|
181 |
} |
|
182 |
|
|
183 |
public void setFormattingPattern(String columnName, String pattern) { |
|
184 |
if( this.patterns==null ) { |
|
185 |
return; |
|
186 |
} |
|
187 |
this.patterns.put(columnName,pattern); |
|
188 |
} |
|
189 |
|
|
138 | 190 |
@SuppressWarnings("unchecked") |
139 | 191 |
public FeatureQuery getQuery() { |
140 | 192 |
if (this.query == null) { |
... | ... | |
161 | 213 |
} |
162 | 214 |
|
163 | 215 |
if (this.attributeNames != null) { |
164 |
ArrayList<String> newNames = new ArrayList<String>();
|
|
216 |
ArrayList<String> newNames = new ArrayList<>(); |
|
165 | 217 |
for (String name : this.attributeNames) { |
166 | 218 |
if (fType.getIndex(name) > -1) { |
167 | 219 |
newNames.add(name); |
... | ... | |
259 | 311 |
/** |
260 | 312 |
* Enlaza la seleccion de esta tabla con la de la tabla indicada |
261 | 313 |
* |
314 |
* @param targetTable |
|
315 |
* @param fieldSource |
|
316 |
* @param fieldTarget |
|
262 | 317 |
* @deprecated see {@link #addLinkTable(String, String, String)} |
263 | 318 |
*/ |
264 | 319 |
public void setLinkTable(String targetTable, String fieldSource, |
... | ... | |
281 | 336 |
TableLink link = new TableLink(this, target, fieldSource, fieldTarget); |
282 | 337 |
link.setEnabled(true); |
283 | 338 |
if (this.linkTable == null) { |
284 |
this.linkTable = new ArrayList<TableLink>();
|
|
339 |
this.linkTable = new ArrayList<>(); |
|
285 | 340 |
} |
286 | 341 |
this.linkTable.add(link); |
287 | 342 |
} |
... | ... | |
322 | 377 |
this.associatedLayer = associatedLayer; |
323 | 378 |
} |
324 | 379 |
|
380 |
@Override |
|
325 | 381 |
public void update(Observable arg0, Object arg1) { |
326 | 382 |
if (this.store.equals(arg0)) { |
327 | 383 |
if (arg1 instanceof FeatureStoreNotification) { |
328 | 384 |
FeatureStoreNotification event = |
329 | 385 |
(FeatureStoreNotification) arg1; |
330 |
if (event.getType() == FeatureStoreNotification.TRANSFORM_CHANGE
|
|
331 |
|| event.getType() == FeatureStoreNotification.RESOURCE_CHANGED) {
|
|
386 |
if ( FeatureStoreNotification.TRANSFORM_CHANGE.equals(event.getType())
|
|
387 |
|| FeatureStoreNotification.RESOURCE_CHANGED.equals(event.getType()) ) {
|
|
332 | 388 |
this.query = null; |
333 | 389 |
} |
334 | 390 |
} |
... | ... | |
338 | 394 |
} |
339 | 395 |
|
340 | 396 |
@SuppressWarnings("unchecked") |
397 |
@Override |
|
341 | 398 |
public void loadFromState(PersistentState state) |
342 | 399 |
throws PersistenceException { |
343 | 400 |
try { |
... | ... | |
352 | 409 |
this.query = (FeatureQuery) state.get("query"); |
353 | 410 |
this.baseFilter = (Evaluator) state.get("baseFilter"); |
354 | 411 |
this.baseOrder = (FeatureQueryOrder) state.get("baseOrder"); |
412 |
this.patterns = new HashMap<>(state.getMap("patterns")); |
|
355 | 413 |
} catch (Throwable e) { |
356 | 414 |
String storeName = (store == null) ? "unknow" : store.getFullName(); |
357 | 415 |
logger.warn("can't load table '" + this.getName() + "' (store=" |
358 | 416 |
+ storeName + ") from persisted state.", e); |
359 |
// this.setAvailable(false); |
|
360 |
return; |
|
361 | 417 |
} |
362 | 418 |
} |
363 | 419 |
|
420 |
@Override |
|
364 | 421 |
public void saveToState(PersistentState state) throws PersistenceException { |
365 | 422 |
super.saveToState(state); |
366 | 423 |
|
... | ... | |
372 | 429 |
state.set("query", query); |
373 | 430 |
// state.set("baseFilter", baseFilter); |
374 | 431 |
state.set("baseOrder", baseOrder); |
432 |
state.set("patterns",patterns); |
|
375 | 433 |
} |
376 | 434 |
|
377 | 435 |
public static class TableLink implements Observer, Persistent { |
... | ... | |
461 | 519 |
} |
462 | 520 |
} |
463 | 521 |
|
522 |
@Override |
|
464 | 523 |
public void update(Observable arg0, Object arg1) { |
465 | 524 |
try { |
466 | 525 |
FeatureSet fCollection1 = |
467 | 526 |
(FeatureSet) storeSource.getSelection(); |
468 | 527 |
FeatureSelection fCollection2 = |
469 | 528 |
(FeatureSelection) storeTarget.createSelection(); |
470 |
List<Object> idx = new ArrayList<Object>();
|
|
529 |
List<Object> idx = new ArrayList<>(); |
|
471 | 530 |
|
472 | 531 |
// Construimos el ?ndice |
473 | 532 |
DisposableIterator iterator1 = null; |
... | ... | |
515 | 574 |
storeTarget.setSelection(fCollection2); |
516 | 575 |
} |
517 | 576 |
} catch (DataException e2) { |
518 |
NotificationManager.addError(e2); |
|
519 |
return; |
|
577 |
logger.warn(e2.getMessage(),e2); |
|
520 | 578 |
} |
521 | 579 |
} |
522 | 580 |
|
581 |
@Override |
|
523 | 582 |
public void loadFromState(PersistentState state) |
524 | 583 |
throws PersistenceException { |
525 | 584 |
this.initialize((TableDocument) state.get("source"), |
... | ... | |
528 | 587 |
this.setEnabled(state.getBoolean("enabled")); |
529 | 588 |
} |
530 | 589 |
|
590 |
@Override |
|
531 | 591 |
public void saveToState(PersistentState state) |
532 | 592 |
throws PersistenceException { |
533 | 593 |
state.set("source", this.source); |
... | ... | |
547 | 607 |
return false; |
548 | 608 |
} |
549 | 609 |
|
610 |
@Override |
|
550 | 611 |
public boolean isAvailable() { |
551 | 612 |
if(this.store == null){ |
552 | 613 |
return false; |
Also available in: Unified diff