Revision 44716
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretype/DefaultFeatureTypePanel.java | ||
---|---|---|
58 | 58 |
"Precision", |
59 | 59 |
"Scale", |
60 | 60 |
"Default value", |
61 |
"Calculated" |
|
61 |
"Calculated", |
|
62 |
"Fk" |
|
62 | 63 |
}; |
63 | 64 |
private final Class[] columnClasses = new Class[] { |
64 | 65 |
String.class, |
... | ... | |
67 | 68 |
Integer.class, |
68 | 69 |
Integer.class, |
69 | 70 |
String.class, |
71 |
Boolean.class, |
|
70 | 72 |
Boolean.class |
71 | 73 |
}; |
72 | 74 |
|
... | ... | |
149 | 151 |
return Objects.toString(descriptor.getDefaultValue(),""); |
150 | 152 |
case 6: |
151 | 153 |
return descriptor.isComputed(); |
154 |
case 7: |
|
155 |
return descriptor.isForeingKey(); |
|
152 | 156 |
default: |
153 | 157 |
return ""; |
154 | 158 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureType.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package org.gvsig.fmap.dal.feature; |
3 | 3 |
|
4 |
import java.io.File; |
|
4 | 5 |
import java.util.Iterator; |
5 | 6 |
import java.util.List; |
6 | 7 |
import java.util.function.Predicate; |
... | ... | |
481 | 482 |
return null; |
482 | 483 |
} |
483 | 484 |
|
485 |
@Override |
|
486 |
public void writeAsDALFile(File file) { |
|
487 |
|
|
488 |
} |
|
489 |
|
|
484 | 490 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureType.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.feature; |
25 | 25 |
|
26 |
import java.io.File; |
|
26 | 27 |
import java.util.Iterator; |
27 | 28 |
import java.util.List; |
28 | 29 |
import java.util.function.Predicate; |
... | ... | |
354 | 355 |
|
355 | 356 |
public boolean hasOnlyMetadataChanges(FeatureType other); |
356 | 357 |
|
358 |
public void writeAsDALFile(File file); |
|
357 | 359 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DALFile.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package org.gvsig.fmap.dal.feature.impl; |
3 | 3 |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileOutputStream; |
|
4 | 6 |
import java.io.InputStream; |
5 | 7 |
import java.io.OutputStream; |
6 | 8 |
import java.util.ArrayList; |
7 | 9 |
import java.util.List; |
8 | 10 |
import org.apache.commons.collections4.CollectionUtils; |
11 |
import org.apache.commons.io.IOUtils; |
|
9 | 12 |
import org.apache.commons.lang3.StringUtils; |
10 | 13 |
import org.gvsig.fmap.dal.exception.DataException; |
11 | 14 |
import org.gvsig.fmap.dal.feature.FeatureType; |
... | ... | |
17 | 20 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
18 | 21 |
import org.slf4j.Logger; |
19 | 22 |
import org.slf4j.LoggerFactory; |
23 |
import sun.nio.ch.IOUtil; |
|
20 | 24 |
|
21 | 25 |
|
22 | 26 |
@SuppressWarnings("UseSpecificCatch") |
... | ... | |
71 | 75 |
|
72 | 76 |
public void write(org.gvsig.tools.resourcesstorage.ResourcesStorage.Resource resource) { |
73 | 77 |
try { |
78 |
OutputStream out = resource.asOutputStream(); |
|
79 |
this.write(out); |
|
80 |
// Don't close the output stream |
|
81 |
} catch(Throwable ex) { |
|
82 |
throw new RuntimeException("Can't write DAL resource.",ex); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
public void write(File outfile) { |
|
87 |
OutputStream out = null; |
|
88 |
try { |
|
89 |
out = new FileOutputStream(outfile); |
|
90 |
this.write(out); |
|
91 |
} catch(Throwable ex) { |
|
92 |
throw new RuntimeException("Can't write DAL file.",ex); |
|
93 |
} finally { |
|
94 |
IOUtils.closeQuietly(out); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public void write(OutputStream out) { |
|
99 |
try { |
|
74 | 100 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
75 | 101 |
PersistentState state = manager.getState(this); |
76 |
OutputStream out = resource.asOutputStream(); |
|
77 | 102 |
manager.saveState(state, out); |
78 | 103 |
} catch(Throwable ex) { |
79 | 104 |
throw new RuntimeException("Can't write DAL resource.",ex); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureType.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.fmap.dal.feature.impl; |
25 | 25 |
|
26 |
import java.io.File; |
|
26 | 27 |
import java.lang.ref.WeakReference; |
27 | 28 |
import java.util.ArrayList; |
28 | 29 |
import java.util.Arrays; |
... | ... | |
32 | 33 |
import java.util.Iterator; |
33 | 34 |
import java.util.LinkedHashSet; |
34 | 35 |
import java.util.List; |
36 |
import java.util.Objects; |
|
35 | 37 |
import java.util.Set; |
36 | 38 |
import java.util.function.Predicate; |
37 | 39 |
import java.util.zip.CRC32; |
38 |
import org.apache.commons.collections4.ListUtils; |
|
39 | 40 |
import org.apache.commons.lang3.ArrayUtils; |
40 | 41 |
import org.apache.commons.lang3.StringUtils; |
41 | 42 |
|
... | ... | |
68 | 69 |
import org.gvsig.tools.persistence.PersistentState; |
69 | 70 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
70 | 71 |
|
72 |
@SuppressWarnings("UseSpecificCatch") |
|
71 | 73 |
public class DefaultFeatureType |
72 | 74 |
extends ArrayList<FeatureAttributeDescriptor> |
73 | 75 |
implements |
... | ... | |
1240 | 1242 |
} |
1241 | 1243 |
return true; |
1242 | 1244 |
} |
1245 |
|
|
1246 |
public void writeAsDALFile(File file) { |
|
1247 |
try { |
|
1248 |
DALFile dalFile = DALFile.getDALFile(); |
|
1249 |
dalFile.setFeatureType(this); |
|
1250 |
if( !dalFile.isEmpty() ) { |
|
1251 |
dalFile.write(file); |
|
1252 |
} |
|
1253 |
} catch (Exception ex) { |
|
1254 |
throw new RuntimeException("Can't write as DAL file ("+Objects.toString(file)+").", ex); |
|
1255 |
} |
|
1256 |
} |
|
1243 | 1257 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
61 | 61 |
_Select_all_duplicates_in_the_table=Seleccionar todos los duplicados de la tabla |
62 | 62 |
_Project_tables=Tablas del proyecto |
63 | 63 |
_Show_as_table=Mostrar como tabla |
64 |
_Save_as_DAL_file=Guardar como fichero DAL |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
61 | 61 |
_Select_all_duplicates_in_the_table=Select all duplicates in the table |
62 | 62 |
_Project_tables=Project tables |
63 | 63 |
_Show_as_table=Show as table |
64 |
_Save_as_DAL_file=Save as DAL file |
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/extension/TableEditAttributes.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.awt.event.ActionEvent; |
27 | 27 |
import java.awt.event.ActionListener; |
28 |
import java.io.File; |
|
28 | 29 |
import javax.swing.AbstractAction; |
29 | 30 |
import javax.swing.Action; |
30 | 31 |
import static javax.swing.Action.ACTION_COMMAND_KEY; |
... | ... | |
53 | 54 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
54 | 55 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
55 | 56 |
import org.gvsig.tools.ToolsLocator; |
57 |
import org.gvsig.tools.folders.FoldersManager; |
|
56 | 58 |
import org.gvsig.tools.i18n.I18nManager; |
57 | 59 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
58 | 60 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
... | ... | |
78 | 80 |
public void postInitialize() { |
79 | 81 |
ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
80 | 82 |
cfgActionsManager.addConfigurableAction(FeatureTypePanel.CONFIGURABLE_PANEL_ID, new ShowAsTableAction()); |
83 |
cfgActionsManager.addConfigurableAction(FeatureTypePanel.CONFIGURABLE_PANEL_ID, new WriteToDALFileAction()); |
|
81 | 84 |
} |
82 | 85 |
|
83 | 86 |
@Override |
... | ... | |
198 | 201 |
|
199 | 202 |
} |
200 | 203 |
} |
204 |
public static class WriteToDALFileAction extends AbstractAction { |
|
201 | 205 |
|
206 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
|
207 |
public WriteToDALFileAction() { |
|
208 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
209 |
|
|
210 |
this.putValue(NAME, i18n.getTranslation("_Save_as_DAL_file")); |
|
211 |
this.putValue(ACTION_COMMAND_KEY, "WriteToDALFile"); |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public void actionPerformed(ActionEvent ae) { |
|
216 |
FeatureTypePanel panel = (FeatureTypePanel) ae.getSource(); |
|
217 |
EditableFeatureType featureType = panel.fetch(null); |
|
218 |
|
|
219 |
ApplicationManager application = ApplicationLocator.getApplicationManager(); |
|
220 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
221 |
FoldersManager foldersManager = ToolsLocator.getFoldersManager(); |
|
222 |
File[] f = application.showSaveFileDialog( |
|
223 |
i18n.getTranslation("_Save_as_DAL_file"), |
|
224 |
foldersManager.getLastPath("SaveAsDALFile", null) |
|
225 |
); |
|
226 |
if( f==null || f.length==0 ) { |
|
227 |
return; |
|
228 |
} |
|
229 |
foldersManager.setLastPath("SaveAsDALFile", f[0].getParentFile()); |
|
230 |
featureType.writeAsDALFile(f[0]); |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
|
|
202 | 235 |
public static class ShowAsTableAction extends AbstractAction { |
203 | 236 |
|
204 | 237 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
Also available in: Unified diff