svn-gvsig-desktop / 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 / DefaultFeatureAttributePanel.java @ 47426
History | View | Annotate | Download (102 KB)
1 | 44077 | jjdelcerro | package org.gvsig.fmap.dal.swing.impl.featuretype; |
---|---|---|---|
2 | |||
3 | 44740 | jjdelcerro | import java.awt.Component; |
4 | 44202 | jjdelcerro | import java.awt.event.ActionEvent; |
5 | 44085 | jjdelcerro | import java.awt.event.ItemEvent; |
6 | 44077 | jjdelcerro | import java.util.ArrayList; |
7 | 45154 | jjdelcerro | import java.util.Collections; |
8 | 44077 | jjdelcerro | import java.util.List; |
9 | 46878 | jjdelcerro | import java.util.Locale; |
10 | 44202 | jjdelcerro | import java.util.Objects; |
11 | 44077 | jjdelcerro | import javax.swing.DefaultComboBoxModel; |
12 | 44740 | jjdelcerro | import javax.swing.DefaultListCellRenderer; |
13 | 44719 | jjdelcerro | import javax.swing.DefaultListModel; |
14 | 44740 | jjdelcerro | import javax.swing.ImageIcon; |
15 | 44202 | jjdelcerro | import javax.swing.JButton; |
16 | 44262 | jjdelcerro | import javax.swing.JCheckBox; |
17 | 44202 | jjdelcerro | import javax.swing.JComboBox; |
18 | 44077 | jjdelcerro | import javax.swing.JComponent; |
19 | 44740 | jjdelcerro | import javax.swing.JLabel; |
20 | 44719 | jjdelcerro | import javax.swing.JList; |
21 | 44085 | jjdelcerro | import javax.swing.JOptionPane; |
22 | 44740 | jjdelcerro | import javax.swing.JScrollPane; |
23 | 46850 | jjdelcerro | import javax.swing.JSplitPane; |
24 | 44262 | jjdelcerro | import javax.swing.JTextField; |
25 | 44719 | jjdelcerro | import javax.swing.ListModel; |
26 | 44085 | jjdelcerro | import javax.swing.SwingUtilities; |
27 | 46893 | fdiaz | import javax.swing.UIManager; |
28 | 44085 | jjdelcerro | import javax.swing.event.ChangeEvent; |
29 | 44719 | jjdelcerro | import javax.swing.event.ListSelectionEvent; |
30 | 44202 | jjdelcerro | import javax.swing.text.JTextComponent; |
31 | 46876 | jjdelcerro | import org.apache.commons.lang3.ArrayUtils; |
32 | 44128 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
33 | 46850 | jjdelcerro | import org.apache.commons.lang3.tuple.ImmutablePair; |
34 | import org.apache.commons.lang3.tuple.Pair; |
||
35 | 44077 | jjdelcerro | import org.cresques.cts.IProjection; |
36 | 46850 | jjdelcerro | import org.gvsig.expressionevaluator.Code; |
37 | import org.gvsig.expressionevaluator.Code.Callable; |
||
38 | import org.gvsig.expressionevaluator.Code.Constant; |
||
39 | import org.gvsig.expressionevaluator.Code.Identifier; |
||
40 | import org.gvsig.expressionevaluator.Codes; |
||
41 | 44077 | jjdelcerro | import org.gvsig.expressionevaluator.Expression; |
42 | 46850 | jjdelcerro | import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_GETATTR; |
43 | import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_EQ; |
||
44 | 44262 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionUtils; |
45 | 44077 | jjdelcerro | import org.gvsig.expressionevaluator.swing.CalculatorController; |
46 | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
||
47 | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
||
48 | import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
||
49 | 44085 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
50 | import org.gvsig.fmap.dal.DataManager; |
||
51 | 46850 | jjdelcerro | import static org.gvsig.fmap.dal.DataManager.FUNCTION_SELECT; |
52 | 44262 | jjdelcerro | import org.gvsig.fmap.dal.DataStore; |
53 | 46721 | fdiaz | import org.gvsig.fmap.dal.DataStoreProviderFactory; |
54 | 44077 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
55 | 46850 | jjdelcerro | import org.gvsig.fmap.dal.SQLBuilder; |
56 | 44262 | jjdelcerro | import org.gvsig.fmap.dal.StoresRepository; |
57 | 46876 | jjdelcerro | import static org.gvsig.fmap.dal.complements.RelatedFeatures.DAL_RELATED_TABLE; |
58 | import static org.gvsig.fmap.dal.complements.RelatedFeatures.DAL_RELATED_UNIQUE_FIELD_NAME; |
||
59 | 44100 | jjdelcerro | import org.gvsig.fmap.dal.exception.DataException; |
60 | 46850 | jjdelcerro | import org.gvsig.fmap.dal.expressionevaluator.DALExpressionBuilder; |
61 | 44077 | jjdelcerro | import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
62 | 44100 | jjdelcerro | import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
63 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.feature.DataProfile; |
64 | 44077 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
65 | 44498 | omartinez | import org.gvsig.fmap.dal.feature.EditableFeatureType; |
66 | 44262 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableForeingKey; |
67 | 44100 | jjdelcerro | import org.gvsig.fmap.dal.feature.Feature; |
68 | 44077 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
69 | import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
||
70 | 44100 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
71 | 46721 | fdiaz | import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
72 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureType; |
73 | 44262 | jjdelcerro | import org.gvsig.fmap.dal.feature.ForeingKey; |
74 | 44077 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
75 | 44085 | jjdelcerro | import org.gvsig.fmap.dal.swing.DataSwingManager; |
76 | 44149 | jjdelcerro | import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement; |
77 | 46850 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorAndExpressionPickerController; |
78 | import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
||
79 | 47281 | fdiaz | import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
80 | 44505 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
81 | 46863 | jjdelcerro | import static org.gvsig.fmap.dal.swing.impl.DefaultDALSwingLibrary.LIBRARY_NAME; |
82 | 45873 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.tags.Tag; |
83 | import org.gvsig.fmap.dal.swing.impl.featuretype.tags.TagController; |
||
84 | import org.gvsig.fmap.dal.swing.impl.featuretype.tags.TagsModel; |
||
85 | 44077 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
86 | 44085 | jjdelcerro | import org.gvsig.fmap.geom.GeometryLocator; |
87 | import org.gvsig.fmap.geom.GeometryManager; |
||
88 | import org.gvsig.fmap.geom.type.GeometryType; |
||
89 | 44077 | jjdelcerro | import org.gvsig.timesupport.RelativeInterval; |
90 | import org.gvsig.tools.ToolsLocator; |
||
91 | 44472 | jjdelcerro | import org.gvsig.tools.dataTypes.DataType; |
92 | 44673 | jjdelcerro | import org.gvsig.tools.dataTypes.DataType.NumberPrecisionAndScale; |
93 | 44077 | jjdelcerro | import org.gvsig.tools.dataTypes.DataTypesManager; |
94 | 44740 | jjdelcerro | import org.gvsig.tools.dynobject.DynField; |
95 | 44202 | jjdelcerro | import org.gvsig.tools.dynobject.DynObjectValueItem; |
96 | 46876 | jjdelcerro | import org.gvsig.tools.dynobject.Tags; |
97 | 44152 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
98 | 44077 | jjdelcerro | import org.gvsig.tools.swing.api.ListElement; |
99 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
100 | import org.gvsig.tools.swing.api.ToolsSwingManager; |
||
101 | 46850 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingUtils; |
102 | 44077 | jjdelcerro | import org.gvsig.tools.swing.api.pickercontroller.DatePickerController; |
103 | import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
||
104 | 44085 | jjdelcerro | import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
105 | 44740 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.Dialog; |
106 | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
||
107 | import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
||
108 | import org.gvsig.tools.swing.icontheme.IconTheme; |
||
109 | 46850 | jjdelcerro | import org.gvsig.tools.util.LabeledValue; |
110 | import org.gvsig.tools.util.LabeledValueImpl; |
||
111 | 44128 | jjdelcerro | import org.slf4j.Logger; |
112 | import org.slf4j.LoggerFactory; |
||
113 | 44077 | jjdelcerro | |
114 | /**
|
||
115 | *
|
||
116 | * @author jjdelcerro
|
||
117 | */
|
||
118 | 44713 | jjdelcerro | @SuppressWarnings({"UseSpecificCatch"}) |
119 | public class DefaultFeatureAttributePanel |
||
120 | extends DefaultFeatureAttributePanelView
|
||
121 | 44085 | jjdelcerro | implements FeatureTypeAttributePanel {
|
122 | 44077 | jjdelcerro | |
123 | 44713 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureAttributePanel.class); |
124 | 45154 | jjdelcerro | |
125 | // ----
|
||
126 | // Los he eliminado del GUI pero los mantengo aqui por si decido rescatarlos
|
||
127 | private final JTextComponent txtMaxValue = new JTextField(); |
||
128 | private final JTextComponent txtMinValue = new JTextField(); |
||
129 | private final JComponent lblMinValue = new JLabel(); |
||
130 | private final JComponent lblMaxValue = new JLabel(); |
||
131 | // ----
|
||
132 | 46104 | omartinez | private Feature sampleFeature;
|
133 | 46795 | jjdelcerro | private String previousDefaultValue; |
134 | 46850 | jjdelcerro | private ToManyController toManyController;
|
135 | private JSplitPane splAttrTags; |
||
136 | 47403 | fdiaz | private FeatureType featureType;
|
137 | 44202 | jjdelcerro | |
138 | 46850 | jjdelcerro | private static class ToOneController { |
139 | 44262 | jjdelcerro | |
140 | 46850 | jjdelcerro | private final JTextComponent txtMyFieldName; |
141 | private final JComboBox cboRelationType; |
||
142 | 44338 | jjdelcerro | private final JCheckBox chkIsClosedList; |
143 | 44262 | jjdelcerro | private final JComboBox cboTable; |
144 | 46850 | jjdelcerro | private final JComboBox cboForeignField; |
145 | private final JComboBox cboFormula; |
||
146 | 44262 | jjdelcerro | private final JButton btnFormula; |
147 | 45154 | jjdelcerro | private final JButton btnFormulaHistory; |
148 | private final JButton btnFormulaBokkmarks; |
||
149 | 46850 | jjdelcerro | private AttributeDescriptorAndExpressionPickerController pickerFormula;
|
150 | private AttributeDescriptorPickerController pickerCode;
|
||
151 | 44262 | jjdelcerro | private boolean editable; |
152 | 44412 | omartinez | private ForeingKey foreingKey;
|
153 | 44262 | jjdelcerro | |
154 | 46850 | jjdelcerro | public ToOneController(
|
155 | JTextComponent txtMyFieldName,
|
||
156 | JComboBox cboRelationType,
|
||
157 | 44338 | jjdelcerro | JCheckBox chkIsClosedList,
|
158 | 44262 | jjdelcerro | JComboBox cboTable,
|
159 | JComboBox cboCode,
|
||
160 | 46850 | jjdelcerro | JComboBox cboFormula,
|
161 | 45154 | jjdelcerro | JButton btnFormula,
|
162 | JButton btnFormulaBokkmarks,
|
||
163 | JButton btnFormulaHistory
|
||
164 | 44262 | jjdelcerro | ) { |
165 | 46850 | jjdelcerro | this.txtMyFieldName = txtMyFieldName;
|
166 | this.cboRelationType = cboRelationType;
|
||
167 | 44338 | jjdelcerro | this.chkIsClosedList = chkIsClosedList;
|
168 | 44262 | jjdelcerro | this.cboTable = cboTable;
|
169 | 46850 | jjdelcerro | this.cboForeignField = cboCode;
|
170 | this.cboFormula = cboFormula;
|
||
171 | 44262 | jjdelcerro | this.btnFormula = btnFormula;
|
172 | 45154 | jjdelcerro | this.btnFormulaHistory = btnFormulaHistory;
|
173 | this.btnFormulaBokkmarks = btnFormulaBokkmarks;
|
||
174 | 44262 | jjdelcerro | this.initComponents();
|
175 | } |
||
176 | |||
177 | private void initComponents() { |
||
178 | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
||
179 | 46850 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
180 | 44262 | jjdelcerro | |
181 | this.editable = true; |
||
182 | 46850 | jjdelcerro | DefaultComboBoxModel<ListElement<Integer>> relationTypeModel = new DefaultComboBoxModel<>(); |
183 | // relationTypeModel.addElement(new ListElement<>(i18n.getTranslation("_None"),DynField.RELATION_TYPE_NONE));
|
||
184 | 47144 | jjdelcerro | relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_IDENTITY + " - "+i18n.getTranslation("_Identity_1_1"),DynField.RELATION_TYPE_IDENTITY)); |
185 | relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_COLLABORATION + " - "+i18n.getTranslation("_Collaboration_1_1_without_composition"),DynField.RELATION_TYPE_COLLABORATION)); |
||
186 | relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_COLLABORATION_WITH_COMPOSITION + " - "+i18n.getTranslation("_Collaboration_1_1_with_composition"),DynField.RELATION_TYPE_COLLABORATION_WITH_COMPOSITION)); |
||
187 | // relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_AGGREGATE_WITH_COMPOSITION + " - "+i18n.getTranslation("_Aggregate_1_N_without_composition"),DynField.RELATION_TYPE_AGGREGATE_WITH_COMPOSITION));
|
||
188 | // relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_AGGREGATE + " - "+i18n.getTranslation("_Aggregate_1_N_with_composition"),DynField.RELATION_TYPE_AGGREGATE));
|
||
189 | 46850 | jjdelcerro | this.cboRelationType.setModel(relationTypeModel);
|
190 | 47281 | fdiaz | this.cboRelationType.addActionListener((ActionEvent e) -> { |
191 | updateEnabledState(); |
||
192 | }); |
||
193 | 46850 | jjdelcerro | |
194 | 44262 | jjdelcerro | DefaultComboBoxModel<String> model = new DefaultComboBoxModel(); |
195 | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
||
196 | 45154 | jjdelcerro | List<String> tableNames = new ArrayList<>(); |
197 | 44262 | jjdelcerro | for (String tableName : repository.keySet()) { |
198 | 45154 | jjdelcerro | tableNames.add(tableName); |
199 | } |
||
200 | Collections.sort(tableNames);
|
||
201 | for (String tableName : tableNames) { |
||
202 | 44262 | jjdelcerro | model.addElement(tableName); |
203 | } |
||
204 | 46850 | jjdelcerro | this.cboTable.setEditable(false); |
205 | 44262 | jjdelcerro | this.cboTable.setModel(model);
|
206 | 44719 | jjdelcerro | this.cboTable.addItemListener((ItemEvent e) -> { |
207 | 47281 | fdiaz | updateEnabledState(); |
208 | 44719 | jjdelcerro | if (e.getStateChange() != ItemEvent.SELECTED) { |
209 | return;
|
||
210 | } |
||
211 | Thread th = new Thread(() -> { |
||
212 | 46850 | jjdelcerro | doTableChanged(); |
213 | }, "FeatureTypePanelToOneChangeTable");
|
||
214 | 44719 | jjdelcerro | th.start(); |
215 | 44262 | jjdelcerro | }); |
216 | 46850 | jjdelcerro | this.pickerCode = dataSwingManager.createAttributeDescriptorPickerController(cboForeignField);
|
217 | 47281 | fdiaz | this.pickerCode.addChangeListener((ChangeEvent e) -> { |
218 | updateEnabledState(); |
||
219 | }); |
||
220 | 46850 | jjdelcerro | |
221 | 44262 | jjdelcerro | this.btnFormula.setText(""); |
222 | 45154 | jjdelcerro | this.btnFormulaBokkmarks.setText(""); |
223 | this.btnFormulaHistory.setText(""); |
||
224 | 46850 | jjdelcerro | this.pickerFormula = dataSwingManager.createExpressionPickerController(
|
225 | null,
|
||
226 | cboFormula, |
||
227 | btnFormula, |
||
228 | btnFormulaBokkmarks, |
||
229 | btnFormulaHistory |
||
230 | ); |
||
231 | this.pickerFormula.setAllowNull(true); |
||
232 | 44262 | jjdelcerro | } |
233 | |||
234 | 46850 | jjdelcerro | private void doTableChanged() { |
235 | 44262 | jjdelcerro | String tableName = (String) this.cboTable.getSelectedItem(); |
236 | if( StringUtils.isBlank(tableName) ) {
|
||
237 | return;
|
||
238 | } |
||
239 | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
||
240 | 44304 | jjdelcerro | DataStore store = repository.getStore(tableName); |
241 | 44262 | jjdelcerro | if( !(store instanceof FeatureStore) ) { |
242 | return;
|
||
243 | } |
||
244 | FeatureType featureType; |
||
245 | try {
|
||
246 | featureType = ((FeatureStore)store).getDefaultFeatureType(); |
||
247 | } catch (DataException ex) {
|
||
248 | return;
|
||
249 | } |
||
250 | 46737 | jjdelcerro | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
251 | |||
252 | 46850 | jjdelcerro | this.pickerCode.setAllowNull(true); |
253 | this.pickerCode.setFeatureType(featureType);
|
||
254 | if (featureType == null) { |
||
255 | return;
|
||
256 | 44262 | jjdelcerro | } |
257 | 46850 | jjdelcerro | dataSwingManager.configureExpressionBuilder(this.pickerFormula.getConfig(), ((FeatureStore)store));
|
258 | 44719 | jjdelcerro | SwingUtilities.invokeLater(() -> {
|
259 | 46850 | jjdelcerro | cboForeignField.setSelectedItem(foreingKey.getCodeName()); |
260 | 44262 | jjdelcerro | }); |
261 | } |
||
262 | 47281 | fdiaz | |
263 | public void updateEnabledState(){ |
||
264 | if(this.editable){ |
||
265 | if(this.cboRelationType.getSelectedItem() == null) { |
||
266 | this.cboRelationType.setBackground(ToolsSwingLocator.getToolsSwingManager().getWarningBackgroundColor());
|
||
267 | } else {
|
||
268 | this.cboRelationType.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_BACKGROUND)); |
||
269 | } |
||
270 | if(this.cboTable.getSelectedItem() == null) { |
||
271 | this.cboTable.setBackground(ToolsSwingLocator.getToolsSwingManager().getWarningBackgroundColor());
|
||
272 | } else {
|
||
273 | this.cboTable.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_BACKGROUND)); |
||
274 | } |
||
275 | if(this.cboForeignField.getSelectedItem() == null) { |
||
276 | this.cboForeignField.setBackground(ToolsSwingLocator.getToolsSwingManager().getWarningBackgroundColor());
|
||
277 | } else {
|
||
278 | this.cboForeignField.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_BACKGROUND)); |
||
279 | } |
||
280 | } else {
|
||
281 | this.cboRelationType.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_DISABLEDBACKGROUND)); |
||
282 | this.cboTable.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_DISABLEDBACKGROUND)); |
||
283 | this.cboForeignField.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_COMBOBOX_DISABLEDBACKGROUND)); |
||
284 | } |
||
285 | } |
||
286 | 44262 | jjdelcerro | |
287 | public void setEditable(boolean editable) { |
||
288 | 46850 | jjdelcerro | this.cboRelationType.setEnabled(editable);
|
289 | 44338 | jjdelcerro | this.chkIsClosedList.setEnabled(editable);
|
290 | 44262 | jjdelcerro | this.cboTable.setEnabled(editable);
|
291 | 46850 | jjdelcerro | this.cboForeignField.setEnabled(editable);
|
292 | 45873 | jjdelcerro | this.pickerFormula.setEditable(editable);
|
293 | 44262 | jjdelcerro | this.editable = editable;
|
294 | } |
||
295 | |||
296 | public void setEnabled(boolean enabled) { |
||
297 | if( !editable ) {
|
||
298 | enabled = false;
|
||
299 | } |
||
300 | 46850 | jjdelcerro | this.cboRelationType.setEnabled(enabled);
|
301 | 44338 | jjdelcerro | this.chkIsClosedList.setEnabled(enabled);
|
302 | 44262 | jjdelcerro | this.cboTable.setEnabled(enabled);
|
303 | 46850 | jjdelcerro | this.cboForeignField.setEnabled(enabled);
|
304 | this.pickerFormula.setEditable(enabled);
|
||
305 | 44262 | jjdelcerro | } |
306 | |||
307 | public void clean() { |
||
308 | 46850 | jjdelcerro | this.txtMyFieldName.setText(""); |
309 | this.cboRelationType.setSelectedIndex(-1); |
||
310 | 44338 | jjdelcerro | this.chkIsClosedList.setSelected(false); |
311 | 44262 | jjdelcerro | this.cboTable.setSelectedItem(""); |
312 | 46850 | jjdelcerro | this.cboForeignField.setSelectedItem(""); |
313 | 44262 | jjdelcerro | this.pickerFormula.set(null); |
314 | } |
||
315 | |||
316 | 46850 | jjdelcerro | public void put(FeatureAttributeDescriptor descriptor) { |
317 | if( descriptor == null ) { |
||
318 | this.clean();
|
||
319 | return;
|
||
320 | } |
||
321 | 46985 | jjdelcerro | ForeingKey theForeingKey = descriptor.getForeingKey(); |
322 | if( theForeingKey==null ) { |
||
323 | 44262 | jjdelcerro | this.clean();
|
324 | return;
|
||
325 | } |
||
326 | 46850 | jjdelcerro | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
327 | 46985 | jjdelcerro | this.pickerFormula.setFeatureType(repository.getFeatureType(theForeingKey.getTableName()));
|
328 | this.foreingKey = theForeingKey;
|
||
329 | 46850 | jjdelcerro | ListElement.setSelected(this.cboRelationType,descriptor.getRelationType());
|
330 | 46985 | jjdelcerro | this.chkIsClosedList.setSelected(theForeingKey.isClosedList());
|
331 | this.cboTable.setSelectedItem(theForeingKey.getTableName());
|
||
332 | 46850 | jjdelcerro | doTableChanged(); |
333 | 46985 | jjdelcerro | this.pickerCode.set(theForeingKey.getCodeName());
|
334 | this.pickerFormula.set(theForeingKey.getLabelExpression(null)); |
||
335 | 46850 | jjdelcerro | this.txtMyFieldName.setText(descriptor.getName());
|
336 | 44262 | jjdelcerro | } |
337 | |||
338 | 46850 | jjdelcerro | public void fetch(EditableFeatureAttributeDescriptor descriptor) { |
339 | if( descriptor == null ) { |
||
340 | this.clean();
|
||
341 | return;
|
||
342 | } |
||
343 | 46985 | jjdelcerro | EditableForeingKey theForeingKey = descriptor.getForeingKey(); |
344 | if( theForeingKey==null ) { |
||
345 | 44262 | jjdelcerro | return;
|
346 | } |
||
347 | 46850 | jjdelcerro | // foreingKey.setForeingKey(this.chkIsForeingKey.isSelected());
|
348 | 46985 | jjdelcerro | theForeingKey.setClosedList(this.chkIsClosedList.isSelected());
|
349 | theForeingKey.setTableName((String) this.cboTable.getSelectedItem()); |
||
350 | theForeingKey.setCodeName(this.pickerCode.getName());
|
||
351 | 44262 | jjdelcerro | Expression exp = this.pickerFormula.get(); |
352 | if( ExpressionUtils.isPhraseEmpty(exp) ) {
|
||
353 | 46985 | jjdelcerro | theForeingKey.setLabelFormula("");
|
354 | 44262 | jjdelcerro | } else {
|
355 | 46985 | jjdelcerro | theForeingKey.setLabelFormula(exp.getPhrase()); |
356 | 44262 | jjdelcerro | } |
357 | } |
||
358 | 46850 | jjdelcerro | |
359 | public int getRelationType() { |
||
360 | Object n = this.cboRelationType.getSelectedItem(); |
||
361 | if( n == null ) { |
||
362 | return DynField.RELATION_TYPE_NONE;
|
||
363 | } |
||
364 | return ((LabeledValue<Integer>)n).getValue(); |
||
365 | } |
||
366 | 44262 | jjdelcerro | } |
367 | |||
368 | 46850 | jjdelcerro | private static class ToManyController { |
369 | 44262 | jjdelcerro | |
370 | 46850 | jjdelcerro | private final JComboBox cboRelationType; |
371 | private final JComboBox cboMyField; |
||
372 | private final JComboBox cboTable; |
||
373 | private final JComboBox cboForeignField; |
||
374 | private final JTextField txtExpression; |
||
375 | private final JButton btnExpression; |
||
376 | private final JButton btnExpressionHistory; |
||
377 | private final JButton btnExpressionBokkmarks; |
||
378 | private ExpressionPickerController pickerExpression;
|
||
379 | private AttributeDescriptorPickerController pickerForeignField;
|
||
380 | private AttributeDescriptorPickerController pickerMyField;
|
||
381 | private boolean editable; |
||
382 | private boolean disableEvents; |
||
383 | 47403 | fdiaz | private FeatureType featureType;
|
384 | 46850 | jjdelcerro | |
385 | public ToManyController(
|
||
386 | JComboBox cboRelationType,
|
||
387 | JComboBox cboMyField,
|
||
388 | JComboBox cboTable,
|
||
389 | JComboBox cboForeignField,
|
||
390 | JTextField txtExpression,
|
||
391 | JButton btnExpression,
|
||
392 | JButton btnExpressionBokkmarks,
|
||
393 | JButton btnExpressionHistory
|
||
394 | ) { |
||
395 | this.disableEvents = false; |
||
396 | this.cboRelationType = cboRelationType;
|
||
397 | this.cboMyField = cboMyField;
|
||
398 | this.cboTable = cboTable;
|
||
399 | this.cboForeignField = cboForeignField;
|
||
400 | this.txtExpression = txtExpression;
|
||
401 | this.btnExpression = btnExpression;
|
||
402 | this.btnExpressionHistory = btnExpressionHistory;
|
||
403 | this.btnExpressionBokkmarks = btnExpressionBokkmarks;
|
||
404 | this.initComponents();
|
||
405 | } |
||
406 | |||
407 | private void initComponents() { |
||
408 | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
||
409 | I18nManager i18n = ToolsLocator.getI18nManager(); |
||
410 | |||
411 | this.editable = true; |
||
412 | DefaultComboBoxModel<LabeledValueImpl<Integer>> relationTypeModel = new DefaultComboBoxModel<>(); |
||
413 | 47144 | jjdelcerro | // relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_IDENTITY + " - "+i18n.getTranslation("_Identity_1_1"),DynField.RELATION_TYPE_IDENTITY));
|
414 | // relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_COLLABORATION + " - "+i18n.getTranslation("_Collaboration_1_1_without_composition"),DynField.RELATION_TYPE_COLLABORATION));
|
||
415 | // relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_COLLABORATION_WITH_COMPOSITION + " - "+i18n.getTranslation("_Collaboration_1_1_with_composition"),DynField.RELATION_TYPE_COLLABORATION_WITH_COMPOSITION));
|
||
416 | relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_AGGREGATE_WITH_COMPOSITION + " - "+i18n.getTranslation("_Aggregate_1_N_with_composition"),DynField.RELATION_TYPE_AGGREGATE_WITH_COMPOSITION)); |
||
417 | relationTypeModel.addElement(new ListElement<>(DynField.RELATION_TYPE_AGGREGATE + " - "+i18n.getTranslation("_Aggregate_1_N_without_composition"),DynField.RELATION_TYPE_AGGREGATE)); |
||
418 | 46850 | jjdelcerro | this.cboRelationType.setModel(relationTypeModel);
|
419 | |||
420 | this.pickerMyField = dataSwingManager.createAttributeDescriptorPickerController(cboMyField);
|
||
421 | this.pickerMyField.setAllowNull(true); |
||
422 | this.pickerMyField.addChangeListener((ChangeEvent e) -> { |
||
423 | if( disableEvents ) {
|
||
424 | return;
|
||
425 | } |
||
426 | doUpdateExpression(); |
||
427 | }); |
||
428 | DefaultComboBoxModel<String> model = new DefaultComboBoxModel(); |
||
429 | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
||
430 | List<String> tableNames = new ArrayList<>(); |
||
431 | for (String tableName : repository.keySet()) { |
||
432 | tableNames.add(tableName); |
||
433 | } |
||
434 | Collections.sort(tableNames);
|
||
435 | for (String tableName : tableNames) { |
||
436 | model.addElement(tableName); |
||
437 | } |
||
438 | this.cboTable.setEditable(false); |
||
439 | this.cboTable.setModel(model);
|
||
440 | this.cboTable.addItemListener((ItemEvent e) -> { |
||
441 | if( disableEvents ) {
|
||
442 | return;
|
||
443 | } |
||
444 | if (e.getStateChange() != ItemEvent.SELECTED) { |
||
445 | return;
|
||
446 | } |
||
447 | Thread th = new Thread(() -> |
||
448 | { doTableChanged(); }, |
||
449 | "FeatureTypePanelToManyTableChanged"
|
||
450 | ); |
||
451 | th.start(); |
||
452 | }); |
||
453 | this.pickerForeignField = dataSwingManager.createAttributeDescriptorPickerController(cboForeignField);
|
||
454 | this.pickerForeignField.setAllowNull(true); |
||
455 | this.pickerForeignField.addChangeListener((ChangeEvent e) -> { |
||
456 | if( disableEvents ) {
|
||
457 | return;
|
||
458 | } |
||
459 | doUpdateExpression(); |
||
460 | }); |
||
461 | |||
462 | this.pickerExpression = ExpressionEvaluatorSwingLocator.getManager().createExpressionPickerController(
|
||
463 | txtExpression, |
||
464 | btnExpression, |
||
465 | btnExpressionBokkmarks, |
||
466 | btnExpressionHistory |
||
467 | ); |
||
468 | } |
||
469 | |||
470 | private void doTableChanged() { |
||
471 | String tableName = (String) this.cboTable.getSelectedItem(); |
||
472 | if( StringUtils.isBlank(tableName) ) {
|
||
473 | return;
|
||
474 | } |
||
475 | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
||
476 | DataStore store = repository.getStore(tableName); |
||
477 | if( !(store instanceof FeatureStore) ) { |
||
478 | return;
|
||
479 | } |
||
480 | FeatureStore featureStore = (FeatureStore) store; |
||
481 | FeatureType featureType; |
||
482 | try {
|
||
483 | featureType = featureStore.getDefaultFeatureType(); |
||
484 | } catch (DataException ex) {
|
||
485 | return;
|
||
486 | } |
||
487 | DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
||
488 | |||
489 | this.pickerForeignField.setFeatureType(featureType);
|
||
490 | if (featureType == null) { |
||
491 | return;
|
||
492 | } |
||
493 | dataSwingManager.configureExpressionBuilder(this.pickerExpression.getConfig(), featureStore);
|
||
494 | } |
||
495 | |||
496 | private void doUpdateExpression() { |
||
497 | String myField = this.pickerMyField.getName(); |
||
498 | if( StringUtils.isBlank(myField) ) {
|
||
499 | this.pickerExpression.set(null); |
||
500 | return;
|
||
501 | } |
||
502 | String foreignField = this.pickerForeignField.getName(); |
||
503 | if( StringUtils.isBlank(foreignField) ) {
|
||
504 | this.pickerExpression.set(null); |
||
505 | return;
|
||
506 | } |
||
507 | String tableName = this.getTableName(); |
||
508 | if( StringUtils.isBlank(tableName) ) {
|
||
509 | this.pickerExpression.set(null); |
||
510 | return;
|
||
511 | } |
||
512 | DataManager dataManager = DALLocator.getDataManager(); |
||
513 | DALExpressionBuilder builder = dataManager.createDALExpressionBuilder(); |
||
514 | SQLBuilder.SelectBuilder select = builder.select(); |
||
515 | select.from().table().name(tableName); |
||
516 | select.column().all(); |
||
517 | select.where().set(builder.expression().eq( |
||
518 | builder.expression().column(myField), |
||
519 | builder.expression().getattr(tableName, foreignField) |
||
520 | ) |
||
521 | ); |
||
522 | this.pickerExpression.set(ExpressionUtils.createExpression(select.toString()));
|
||
523 | } |
||
524 | |||
525 | private String[] getFieldsAndTable(Expression expression) { |
||
526 | if (ExpressionUtils.isEmpty(expression)) {
|
||
527 | return null; |
||
528 | } |
||
529 | try {
|
||
530 | Code code = expression.getCode(); |
||
531 | if( !StringUtils.equalsIgnoreCase(Callable.name(code),FUNCTION_SELECT) ) { |
||
532 | return null; |
||
533 | } |
||
534 | Code.Callable callable = (Code.Callable) code; |
||
535 | String tableName;
|
||
536 | Codes args = callable.parameters(); |
||
537 | Code storeName_code = (Code) args.get(1);
|
||
538 | if (storeName_code instanceof Code.Identifier) { |
||
539 | tableName = ((Code.Identifier) storeName_code).name(); |
||
540 | } else if (storeName_code instanceof Code.Constant) { |
||
541 | Code.Constant storeName_const = (Code.Constant) storeName_code; |
||
542 | if (storeName_const.value() instanceof CharSequence) { |
||
543 | tableName = storeName_const.value().toString(); |
||
544 | } else {
|
||
545 | return null; |
||
546 | } |
||
547 | } else {
|
||
548 | return null; |
||
549 | } |
||
550 | if (StringUtils.isBlank(tableName)) {
|
||
551 | return null; |
||
552 | } |
||
553 | String foreignColumnName = null; |
||
554 | String myColumnName = null; |
||
555 | Code where = callable.parameters().get(2); // WHERE |
||
556 | Code myFieldCode = getCode( |
||
557 | where, |
||
558 | new ImmutablePair<>(OPERATOR_EQ, 0) |
||
559 | ); |
||
560 | if( myFieldCode != null ) { |
||
561 | myColumnName = Objects.toString(Identifier.name(myFieldCode), null);
|
||
562 | } |
||
563 | Code foreingFieldCode = getCode( |
||
564 | where, |
||
565 | new ImmutablePair<>(OPERATOR_EQ, 1), |
||
566 | new ImmutablePair<>(FUNCTION_GETATTR, 1) |
||
567 | ); |
||
568 | if( foreingFieldCode != null ) { |
||
569 | foreignColumnName = Objects.toString(Constant.value(foreingFieldCode), null);
|
||
570 | } |
||
571 | return new String[] { myColumnName, tableName,foreignColumnName }; |
||
572 | } catch(Throwable t) { |
||
573 | LOGGER.warn("Can't get table and code from expression '"+expression.getPhrase()+"' in toMany controller",t); |
||
574 | return null; |
||
575 | } |
||
576 | } |
||
577 | |||
578 | private Code getCode(Code code, Pair<String,Integer>... args) { |
||
579 | for (Pair<String, Integer> arg : args) { |
||
580 | if( !StringUtils.equalsIgnoreCase(Callable.name(code),arg.getLeft()) ) { |
||
581 | return null; |
||
582 | } |
||
583 | code = Callable.parameters(code).get(arg.getRight());
|
||
584 | } |
||
585 | return code;
|
||
586 | } |
||
587 | |||
588 | private String getTableName() { |
||
589 | String s = (String) this.cboTable.getSelectedItem(); |
||
590 | if( StringUtils.isBlank(s) ) {
|
||
591 | return null; |
||
592 | } |
||
593 | return s;
|
||
594 | } |
||
595 | |||
596 | public void setEditable(boolean editable) { |
||
597 | this.cboRelationType.setEnabled(editable);
|
||
598 | this.pickerMyField.setEditable(editable);
|
||
599 | this.cboTable.setEnabled(editable);
|
||
600 | this.pickerForeignField.setEditable(editable);
|
||
601 | this.pickerExpression.setEditable(editable);
|
||
602 | this.editable = editable;
|
||
603 | } |
||
604 | |||
605 | public void setEnabled(boolean enabled) { |
||
606 | if( !editable ) {
|
||
607 | enabled = false;
|
||
608 | } |
||
609 | this.cboRelationType.setEnabled(enabled);
|
||
610 | this.pickerMyField.setEnabled(enabled);
|
||
611 | this.cboTable.setEnabled(enabled);
|
||
612 | this.pickerForeignField.setEnabled(enabled);
|
||
613 | this.pickerExpression.setEditable(enabled);
|
||
614 | } |
||
615 | |||
616 | public void clean() { |
||
617 | this.cboRelationType.setSelectedIndex(-1); |
||
618 | this.pickerMyField.clean();
|
||
619 | this.cboTable.setSelectedIndex(-1); |
||
620 | this.pickerForeignField.clean();
|
||
621 | this.pickerExpression.set(null); |
||
622 | } |
||
623 | |||
624 | public void put(FeatureAttributeDescriptor descriptor) { |
||
625 | if (descriptor == null) { |
||
626 | this.clean();
|
||
627 | return;
|
||
628 | } |
||
629 | boolean prevDisableEvents = this.disableEvents; |
||
630 | try {
|
||
631 | this.disableEvents = true; |
||
632 | 47403 | fdiaz | this.pickerMyField.setFeatureType(getFeatureType(descriptor));
|
633 | 46850 | jjdelcerro | ListElement.setSelected(this.cboRelationType, descriptor.getRelationType());
|
634 | FeatureAttributeEmulator attrEmulator = descriptor.getFeatureAttributeEmulator(); |
||
635 | if (attrEmulator instanceof FeatureAttributeEmulatorExpression) { |
||
636 | Expression expression = ((FeatureAttributeEmulatorExpression) attrEmulator).getExpression();
|
||
637 | String[] fieldsAndTable = this.getFieldsAndTable(expression); |
||
638 | if (fieldsAndTable == null) { |
||
639 | this.cboTable.setSelectedIndex(-1); |
||
640 | this.pickerForeignField.clean();
|
||
641 | return;
|
||
642 | } |
||
643 | this.pickerMyField.set(fieldsAndTable[0]); |
||
644 | this.cboTable.setSelectedItem(fieldsAndTable[1]); |
||
645 | doTableChanged(); |
||
646 | this.pickerForeignField.set(fieldsAndTable[2]); |
||
647 | this.pickerExpression.set(expression);
|
||
648 | 46876 | jjdelcerro | } else {
|
649 | this.clean();
|
||
650 | 46850 | jjdelcerro | } |
651 | } catch (Throwable t) { |
||
652 | LOGGER.warn("Can't set attribute descriptor in toMany controller",t);
|
||
653 | } finally {
|
||
654 | this.disableEvents = prevDisableEvents;
|
||
655 | } |
||
656 | } |
||
657 | |||
658 | 47403 | fdiaz | public void setFeatureType(FeatureType featureType){ |
659 | this.featureType = featureType;
|
||
660 | } |
||
661 | |||
662 | private FeatureType getFeatureType(FeatureAttributeDescriptor descriptor) {
|
||
663 | if(descriptor == null || descriptor.getFeatureType() == null){ |
||
664 | return this.featureType; |
||
665 | } |
||
666 | return descriptor.getFeatureType();
|
||
667 | } |
||
668 | |||
669 | 46850 | jjdelcerro | public void fetch(EditableFeatureAttributeDescriptor descriptor) { |
670 | if( descriptor == null ) { |
||
671 | this.clean();
|
||
672 | return;
|
||
673 | } |
||
674 | 46978 | fdiaz | // Expression exp = this.pickerExpression.get();
|
675 | // if( ExpressionUtils.isPhraseEmpty(exp) ) {
|
||
676 | // descriptor.setFeatureAttributeEmulator((Expression)null);
|
||
677 | // } else {
|
||
678 | // descriptor.setFeatureAttributeEmulator(exp);
|
||
679 | // }
|
||
680 | 46876 | jjdelcerro | Tags tags = descriptor.getTags(); |
681 | if( !tags.has(DAL_RELATED_TABLE) ) {
|
||
682 | String tableName = this.getTableName(); |
||
683 | if( StringUtils.isNotBlank(tableName) ) {
|
||
684 | tags.set(DAL_RELATED_TABLE, tableName); |
||
685 | } |
||
686 | } |
||
687 | if( !tags.has(DAL_RELATED_UNIQUE_FIELD_NAME) ) {
|
||
688 | String tableName = tags.getString(DAL_RELATED_TABLE, null); |
||
689 | if( StringUtils.isNotBlank(tableName) ) {
|
||
690 | try {
|
||
691 | StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
||
692 | FeatureType ft = repository.getFeatureType(tableName); |
||
693 | FeatureAttributeDescriptor[] pk = ft.getPrimaryKey();
|
||
694 | if( !ArrayUtils.isEmpty(pk) && pk.length==1 ) { |
||
695 | tags.set(DAL_RELATED_UNIQUE_FIELD_NAME, pk[0].getName());
|
||
696 | } |
||
697 | } catch(Throwable t) { |
||
698 | LOGGER.warn("Can't get primary key of table '"+tableName+"'.",t); |
||
699 | } |
||
700 | } |
||
701 | } |
||
702 | 46850 | jjdelcerro | } |
703 | |||
704 | 46978 | fdiaz | public Expression getExpression() { |
705 | Expression exp = this.pickerExpression.get(); |
||
706 | if( ExpressionUtils.isPhraseEmpty(exp) ) {
|
||
707 | return null; |
||
708 | } else {
|
||
709 | return exp;
|
||
710 | } |
||
711 | } |
||
712 | |||
713 | 46850 | jjdelcerro | public int getRelationType() { |
714 | Object n = this.cboRelationType.getSelectedItem(); |
||
715 | if( n == null ) { |
||
716 | return DynField.RELATION_TYPE_NONE;
|
||
717 | } |
||
718 | return ((LabeledValue<Integer>)n).getValue(); |
||
719 | } |
||
720 | } |
||
721 | |||
722 | |||
723 | 44202 | jjdelcerro | private static class AvailableValuesController { |
724 | 44262 | jjdelcerro | |
725 | 44719 | jjdelcerro | private final JList lstValues; |
726 | 44202 | jjdelcerro | private final JTextComponent txtLabel; |
727 | private final JTextComponent txtValue; |
||
728 | private final JButton btnAdd; |
||
729 | private final JButton btnUpdate; |
||
730 | private final JButton btnRemove; |
||
731 | 44719 | jjdelcerro | private final JButton btnRemoveAll; |
732 | 44262 | jjdelcerro | |
733 | public AvailableValuesController(
|
||
734 | 44719 | jjdelcerro | JList lstValues,
|
735 | 44202 | jjdelcerro | JTextComponent txtLabel,
|
736 | JTextComponent txtValue,
|
||
737 | JButton btnAdd,
|
||
738 | JButton btnUpdate,
|
||
739 | 44719 | jjdelcerro | JButton btnRemove,
|
740 | JButton btnRemoveAll
|
||
741 | 44262 | jjdelcerro | ) { |
742 | 44719 | jjdelcerro | this.lstValues = lstValues;
|
743 | 44202 | jjdelcerro | this.txtLabel = txtLabel;
|
744 | this.txtValue = txtValue;
|
||
745 | this.btnAdd = btnAdd;
|
||
746 | this.btnUpdate = btnUpdate;
|
||
747 | this.btnRemove = btnRemove;
|
||
748 | 44719 | jjdelcerro | this.btnRemoveAll = btnRemoveAll;
|
749 | 44262 | jjdelcerro | |
750 | 44719 | jjdelcerro | this.lstValues.addListSelectionListener((ListSelectionEvent e) -> { |
751 | doValuesChanged(); |
||
752 | 44202 | jjdelcerro | }); |
753 | 44719 | jjdelcerro | this.btnAdd.addActionListener((ActionEvent e) -> { |
754 | doAdd(); |
||
755 | 44202 | jjdelcerro | }); |
756 | 44719 | jjdelcerro | this.btnUpdate.addActionListener((ActionEvent e) -> { |
757 | doUpdate(); |
||
758 | 44202 | jjdelcerro | }); |
759 | 44719 | jjdelcerro | this.btnRemove.addActionListener((ActionEvent e) -> { |
760 | doRemove(); |
||
761 | 44202 | jjdelcerro | }); |
762 | 44719 | jjdelcerro | this.btnRemoveAll.addActionListener((ActionEvent e) -> { |
763 | doRemoveAll(); |
||
764 | }); |
||
765 | 44202 | jjdelcerro | } |
766 | |||
767 | public void clean() { |
||
768 | 44719 | jjdelcerro | this.lstValues.setModel(new DefaultListModel()); |
769 | 44202 | jjdelcerro | this.txtLabel.setText(""); |
770 | this.txtValue.setText(""); |
||
771 | 44719 | jjdelcerro | this.lstValues.setSelectedIndex(-1); |
772 | 44202 | jjdelcerro | } |
773 | |||
774 | public DynObjectValueItem[] get() { |
||
775 | 44719 | jjdelcerro | ListModel<DynObjectValueItem> model = this.lstValues.getModel(); |
776 | if( model.getSize()==0 ) { |
||
777 | return null; |
||
778 | } |
||
779 | 44202 | jjdelcerro | DynObjectValueItem[] values = new DynObjectValueItem[model.getSize()]; |
780 | for (int i = 0; i < model.getSize(); i++) { |
||
781 | values[i] = model.getElementAt(i); |
||
782 | } |
||
783 | 44262 | jjdelcerro | return values;
|
784 | 44202 | jjdelcerro | } |
785 | |||
786 | public void set(DynObjectValueItem[] availableValues) { |
||
787 | 44719 | jjdelcerro | DefaultListModel model = new DefaultListModel(); |
788 | 44262 | jjdelcerro | if (availableValues != null) { |
789 | 44202 | jjdelcerro | for (DynObjectValueItem availableValue : availableValues) {
|
790 | model.addElement(availableValue); |
||
791 | } |
||
792 | } |
||
793 | 44719 | jjdelcerro | this.lstValues.setModel(model);
|
794 | 44262 | jjdelcerro | if (model.getSize() > 0) { |
795 | 44719 | jjdelcerro | this.lstValues.setSelectedIndex(0); |
796 | 44202 | jjdelcerro | } else {
|
797 | 44719 | jjdelcerro | this.lstValues.setSelectedIndex(-1); |
798 | 44202 | jjdelcerro | } |
799 | } |
||
800 | 44262 | jjdelcerro | |
801 | 44202 | jjdelcerro | public void setEditable(boolean editable) { |
802 | 44719 | jjdelcerro | this.lstValues.setEnabled(editable);
|
803 | 44202 | jjdelcerro | this.txtLabel.setEditable(editable);
|
804 | this.txtValue.setEditable(editable);
|
||
805 | this.btnAdd.setEnabled(editable);
|
||
806 | this.btnUpdate.setEnabled(editable);
|
||
807 | this.btnRemove.setEnabled(editable);
|
||
808 | 44719 | jjdelcerro | this.btnRemoveAll.setEnabled(editable);
|
809 | 44202 | jjdelcerro | } |
810 | |||
811 | private void doValuesChanged() { |
||
812 | 44719 | jjdelcerro | DynObjectValueItem value = (DynObjectValueItem) this.lstValues.getSelectedValue();
|
813 | 44262 | jjdelcerro | if (value == null) { |
814 | 44202 | jjdelcerro | this.txtLabel.setText(""); |
815 | this.txtValue.setText(""); |
||
816 | this.btnAdd.setEnabled(true); |
||
817 | this.btnUpdate.setEnabled(false); |
||
818 | this.btnRemove.setEnabled(false); |
||
819 | return;
|
||
820 | } |
||
821 | this.txtLabel.setText(value.getLabel());
|
||
822 | 44262 | jjdelcerro | this.txtValue.setText(Objects.toString(value.getValue(), "")); |
823 | 44202 | jjdelcerro | this.btnAdd.setEnabled(true); |
824 | this.btnUpdate.setEnabled(true); |
||
825 | this.btnRemove.setEnabled(true); |
||
826 | } |
||
827 | 44262 | jjdelcerro | |
828 | 44202 | jjdelcerro | private void doAdd() { |
829 | DynObjectValueItem value = new DynObjectValueItem("Value", "Label"); |
||
830 | 44719 | jjdelcerro | DefaultListModel model = (DefaultListModel) this.lstValues.getModel(); |
831 | 44202 | jjdelcerro | model.addElement(value); |
832 | 44719 | jjdelcerro | this.lstValues.setSelectedIndex(model.getSize() - 1); |
833 | 44202 | jjdelcerro | } |
834 | 44262 | jjdelcerro | |
835 | 44202 | jjdelcerro | private void doUpdate() { |
836 | 44719 | jjdelcerro | DynObjectValueItem value = (DynObjectValueItem) this.lstValues.getSelectedValue();
|
837 | 44262 | jjdelcerro | if (value == null) { |
838 | 44202 | jjdelcerro | return; // EEhh?? esto no deberia pasar |
839 | } |
||
840 | value.setLabel(this.txtLabel.getText());
|
||
841 | value.setValue(this.txtValue.getText());
|
||
842 | } |
||
843 | 44262 | jjdelcerro | |
844 | 44202 | jjdelcerro | private void doRemove() { |
845 | 44719 | jjdelcerro | int n = this.lstValues.getSelectedIndex(); |
846 | 44262 | jjdelcerro | if (n < 0) { |
847 | 44202 | jjdelcerro | return; // EEhh?? esto no deberia pasar |
848 | } |
||
849 | 44719 | jjdelcerro | DefaultListModel model = (DefaultListModel) this.lstValues.getModel(); |
850 | 44202 | jjdelcerro | model.removeElementAt(n); |
851 | 44262 | jjdelcerro | if (--n < 0) { |
852 | 44202 | jjdelcerro | n = 0;
|
853 | } |
||
854 | 44719 | jjdelcerro | this.lstValues.setSelectedIndex(n);
|
855 | 44202 | jjdelcerro | } |
856 | |||
857 | 44719 | jjdelcerro | private void doRemoveAll() { |
858 | DefaultListModel model = new DefaultListModel(); |
||
859 | this.lstValues.setModel(model);
|
||
860 | this.lstValues.setSelectedIndex(-1); |
||
861 | } |
||
862 | |||
863 | 44202 | jjdelcerro | } |
864 | |||
865 | 44077 | jjdelcerro | private final List<ListElement<Integer>> fieldTypes; |
866 | private final List<ListElement<Integer>> geometryTypes; |
||
867 | private final List<ListElement<Integer>> geometrySubtypes; |
||
868 | 44085 | jjdelcerro | |
869 | 44077 | jjdelcerro | private DatePickerController pickerIntervalEnd;
|
870 | private DatePickerController pickerIntervalStart;
|
||
871 | private CalculatorController<Integer> pickerSize; |
||
872 | 44947 | jjdelcerro | private CalculatorController<Integer> pickerDisplaySize; |
873 | 44673 | jjdelcerro | private CalculatorController<Integer> pickerPrecision; |
874 | 44669 | jjdelcerro | private CalculatorController<Integer> pickerScale; |
875 | 46878 | jjdelcerro | private PickerController<Locale> pickerLocale; |
876 | 44077 | jjdelcerro | private PickerController<IProjection> pickerCRS;
|
877 | 46737 | jjdelcerro | private ExpressionPickerController pickerVirtualFieldGetter;
|
878 | private ExpressionPickerController pickerVirtualFieldSetter;
|
||
879 | 45994 | omartinez | private ExpressionPickerController pickerDefaultFormat;
|
880 | 44202 | jjdelcerro | private CalculatorController<Integer> pickerOrder; |
881 | private AvailableValuesController availableValuesController;
|
||
882 | 45873 | jjdelcerro | private AggregateController<Tag> tagsController;
|
883 | 46850 | jjdelcerro | private ToOneController toOneController;
|
884 | 45739 | jjdelcerro | private ExpressionPickerController pickerValuesFilter;
|
885 | 44077 | jjdelcerro | |
886 | 44505 | jjdelcerro | private int mode; |
887 | 44149 | jjdelcerro | private FeatureStoreElement featureStoreElement;
|
888 | 44077 | jjdelcerro | |
889 | 44713 | jjdelcerro | public DefaultFeatureAttributePanel() {
|
890 | 44505 | jjdelcerro | this.mode = FeatureTypePanel.MODE_SHOW_ONLY;
|
891 | 44077 | jjdelcerro | DataTypesManager dataManager = ToolsLocator.getDataTypesManager(); |
892 | 45072 | omartinez | // se deber?a de utilizar el datatypepicker
|
893 | 44077 | jjdelcerro | this.fieldTypes = new ArrayList<>(); |
894 | 44740 | jjdelcerro | fieldTypes.add( new ListElement<>("Decimal", DataTypes.DECIMAL) ); |
895 | fieldTypes.add( new ListElement<>("Integer", DataTypes.INTEGER) ); |
||
896 | 46751 | jjdelcerro | fieldTypes.add( new ListElement<>("Long", DataTypes.LONG) ); |
897 | 44740 | jjdelcerro | fieldTypes.add( new ListElement<>("String", DataTypes.STRING) ); |
898 | fieldTypes.add( new ListElement<>("Boolean", DataTypes.BOOLEAN) ); |
||
899 | 45072 | omartinez | fieldTypes.add( new ListElement<>("Date", DataTypes.DATE) ); |
900 | 45565 | jjdelcerro | fieldTypes.add( new ListElement<>("Date/Time (Timestamp)", DataTypes.TIMESTAMP) ); |
901 | 44740 | jjdelcerro | // for (DataType dataType : dataManager) {
|
902 | // fieldTypes.add( new ListElement<>(dataType.getName(), dataType.getType()) );
|
||
903 | // }
|
||
904 | 44719 | jjdelcerro | fieldTypes.sort((ListElement<Integer> o1, ListElement<Integer> o2) -> |
905 | o1.toString().compareTo(o2.toString()) |
||
906 | ); |
||
907 | 44077 | jjdelcerro | |
908 | this.geometryTypes = new ArrayList<>(); |
||
909 | this.geometryTypes.add(new ListElement("Point", Geometry.TYPES.POINT)); |
||
910 | this.geometryTypes.add(new ListElement("Line", Geometry.TYPES.LINE)); |
||
911 | this.geometryTypes.add(new ListElement("Polygon", Geometry.TYPES.POLYGON)); |
||
912 | this.geometryTypes.add(new ListElement("MultiPoint", Geometry.TYPES.MULTIPOINT)); |
||
913 | this.geometryTypes.add(new ListElement("MultiLine", Geometry.TYPES.MULTILINE)); |
||
914 | this.geometryTypes.add(new ListElement("MultiPolygon", Geometry.TYPES.MULTIPOLYGON)); |
||
915 | 44719 | jjdelcerro | this.geometryTypes.sort((ListElement<Integer> o1, ListElement<Integer> o2) -> |
916 | o1.toString().compareTo(o2.toString()) |
||
917 | ); |
||
918 | 44085 | jjdelcerro | |
919 | 44077 | jjdelcerro | this.geometrySubtypes = new ArrayList<>(); |
920 | this.geometrySubtypes.add(new ListElement("2D", Geometry.SUBTYPES.GEOM2D)); |
||
921 | 46925 | fdiaz | this.geometrySubtypes.add(new ListElement("2DM", Geometry.SUBTYPES.GEOM2DM)); |
922 | this.geometrySubtypes.add(new ListElement("3D", Geometry.SUBTYPES.GEOM3D)); |
||
923 | 44077 | jjdelcerro | this.geometrySubtypes.add(new ListElement("3DM", Geometry.SUBTYPES.GEOM3DM)); |
924 | 44719 | jjdelcerro | this.geometrySubtypes.sort((ListElement<Integer> o1, ListElement<Integer> o2) -> |
925 | o1.toString().compareTo(o2.toString()) |
||
926 | ); |
||
927 | 44085 | jjdelcerro | |
928 | 44077 | jjdelcerro | this.initComponents();
|
929 | } |
||
930 | 44085 | jjdelcerro | |
931 | 44077 | jjdelcerro | private void initComponents() { |
932 | 44740 | jjdelcerro | final ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager();
|
933 | 45739 | jjdelcerro | final ExpressionEvaluatorSwingManager evaluatorSwingManager = ExpressionEvaluatorSwingLocator.getManager();
|
934 | 44740 | jjdelcerro | final DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager();
|
935 | final DataTypesManager dataTypeManager = ToolsLocator.getDataTypesManager();
|
||
936 | 44262 | jjdelcerro | |
937 | 46878 | jjdelcerro | this.translate();
|
938 | |||
939 | 46850 | jjdelcerro | ToolsSwingUtils.ensureMaxRows(this.gridAttrTagsTable, 10); |
940 | this.splAttrTags = ToolsSwingUtils.createVerticalSplit(
|
||
941 | this.grdAttrTags,
|
||
942 | this.gridAttrTagsTable, false, |
||
943 | this.gridAttrTagsItem, true |
||
944 | ); |
||
945 | |||
946 | 44077 | jjdelcerro | DefaultComboBoxModel<ListElement<Integer>> modelTypes = new DefaultComboBoxModel<>(); |
947 | for (ListElement<Integer> element : fieldTypes) { |
||
948 | modelTypes.addElement(element); |
||
949 | } |
||
950 | this.cboFieldType.setModel(modelTypes);
|
||
951 | 44740 | jjdelcerro | this.cboFieldType.setRenderer(new DefaultListCellRenderer() { |
952 | @Override
|
||
953 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||
954 | JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||
955 | label.setIcon(null);
|
||
956 | try {
|
||
957 | DataType dataType = dataTypeManager.get((int) value);
|
||
958 | IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
||
959 | if (theme.exists(dataType.getIconName())) {
|
||
960 | label.setIcon(theme.get(dataType.getIconName())); |
||
961 | } |
||
962 | } catch(Exception ex) { |
||
963 | // Do nothing, ignore
|
||
964 | } |
||
965 | return label;
|
||
966 | } |
||
967 | }); |
||
968 | 44077 | jjdelcerro | |
969 | DefaultComboBoxModel<ListElement<Integer>> modelGeomTypes = new DefaultComboBoxModel<>(); |
||
970 | for (ListElement<Integer> element : this.geometryTypes) { |
||
971 | modelGeomTypes.addElement(element); |
||
972 | } |
||
973 | this.cboGeometryType.setModel(modelGeomTypes);
|
||
974 | |||
975 | DefaultComboBoxModel<ListElement<Integer>> modelGeomSubtypes = new DefaultComboBoxModel<>(); |
||
976 | for (ListElement<Integer> element : this.geometrySubtypes) { |
||
977 | modelGeomSubtypes.addElement(element); |
||
978 | } |
||
979 | 44085 | jjdelcerro | |
980 | this.cboGeometrySubtype.setModel(modelGeomSubtypes);
|
||
981 | |||
982 | 44253 | jjdelcerro | |
983 | 44077 | jjdelcerro | swingManager.addClearButton(this.txtDefaultValue);
|
984 | 45994 | omartinez | swingManager.addClearButton(this.txtDefaultFormat);
|
985 | 44077 | jjdelcerro | swingManager.addClearButton(this.txtFieldName);
|
986 | swingManager.addClearButton(this.txtIntervalEnd);
|
||
987 | swingManager.addClearButton(this.txtIntervalStart);
|
||
988 | 44669 | jjdelcerro | swingManager.addClearButton(this.txtScale);
|
989 | 44077 | jjdelcerro | swingManager.addClearButton(this.txtSize);
|
990 | 44947 | jjdelcerro | swingManager.addClearButton(this.txtDisplaySize);
|
991 | 44202 | jjdelcerro | swingManager.addClearButton(this.txtLabel);
|
992 | swingManager.addClearButton(this.txtDescription);
|
||
993 | swingManager.addClearButton(this.cboGroup);
|
||
994 | swingManager.addClearButton(this.txtMaxValue);
|
||
995 | swingManager.addClearButton(this.txtMinValue);
|
||
996 | swingManager.addClearButton(this.txtAvailableValuesLabel);
|
||
997 | 44262 | jjdelcerro | swingManager.addClearButton(this.txtAvailableValuesValue);
|
998 | |||
999 | 44077 | jjdelcerro | swingManager.setDefaultPopupMenu(this.txtDefaultValue);
|
1000 | 45994 | omartinez | swingManager.setDefaultPopupMenu(this.txtDefaultFormat);
|
1001 | 44077 | jjdelcerro | swingManager.setDefaultPopupMenu(this.txtFieldName);
|
1002 | swingManager.setDefaultPopupMenu(this.txtIntervalEnd);
|
||
1003 | swingManager.setDefaultPopupMenu(this.txtIntervalStart);
|
||
1004 | 44669 | jjdelcerro | swingManager.setDefaultPopupMenu(this.txtScale);
|
1005 | 44077 | jjdelcerro | swingManager.setDefaultPopupMenu(this.txtSize);
|
1006 | 44947 | jjdelcerro | swingManager.setDefaultPopupMenu(this.txtDisplaySize);
|
1007 | 44077 | jjdelcerro | swingManager.setDefaultPopupMenu(this.cboDateFormat);
|
1008 | swingManager.setDefaultPopupMenu(this.cboFieldType);
|
||
1009 | swingManager.setDefaultPopupMenu(this.cboGeometrySubtype);
|
||
1010 | swingManager.setDefaultPopupMenu(this.cboGeometryType);
|
||
1011 | 44128 | jjdelcerro | swingManager.setDefaultPopupMenu(this.cboDataProfile);
|
1012 | 44085 | jjdelcerro | |
1013 | 46850 | jjdelcerro | // swingManager.setDefaultPopupMenu(this.cboRelationToOneCodeName);
|
1014 | // swingManager.setDefaultPopupMenu(this.cboRelationToOneTableName);
|
||
1015 | 44262 | jjdelcerro | |
1016 | 46850 | jjdelcerro | // swingManager.setDefaultPopupMenu(this.cboRelationToManyForeignFieldName);
|
1017 | // swingManager.setDefaultPopupMenu(this.cboRelationToManyTableName);
|
||
1018 | |||
1019 | 44202 | jjdelcerro | swingManager.setDefaultPopupMenu(this.cboGroup);
|
1020 | swingManager.setDefaultPopupMenu(this.txtOrder);
|
||
1021 | swingManager.setDefaultPopupMenu(this.txtLabel);
|
||
1022 | swingManager.setDefaultPopupMenu(this.txtDescription);
|
||
1023 | swingManager.setDefaultPopupMenu(this.txtMinValue);
|
||
1024 | swingManager.setDefaultPopupMenu(this.txtMaxValue);
|
||
1025 | swingManager.setDefaultPopupMenu(this.txtAvailableValuesLabel);
|
||
1026 | swingManager.setDefaultPopupMenu(this.txtAvailableValuesValue);
|
||
1027 | 44262 | jjdelcerro | |
1028 | 46850 | jjdelcerro | this.toOneController = new ToOneController( |
1029 | txtRelationToOneMyFieldName, |
||
1030 | cboRelationToOneType, |
||
1031 | chkRelationToOneIsClosedList, |
||
1032 | cboRelationToOneTableName, |
||
1033 | cboRelationToOneCodeName, |
||
1034 | cboRelationToOneFormula, |
||
1035 | btnRelationToOneFormula, |
||
1036 | btnRelationToOneFormulaBookmarks, |
||
1037 | btnRelationToOneFormulaHistory |
||
1038 | 44262 | jjdelcerro | ); |
1039 | 46850 | jjdelcerro | this.toManyController = new ToManyController( |
1040 | cboRelationToManyType, |
||
1041 | cboRelationToManyMyFieldName, |
||
1042 | cboRelationToManyTableName, |
||
1043 | cboRelationToManyForeignFieldName, |
||
1044 | |||
1045 | txtRelationToManyExpression, |
||
1046 | |||
1047 | btnRelationToManyExpression, |
||
1048 | btnRelationToManyExpressionHistory, |
||
1049 | btnRelationToManyExpressionBookmarks |
||
1050 | ); |
||
1051 | 44077 | jjdelcerro | this.pickerIntervalEnd = swingManager.createDatePickerController(
|
1052 | 44085 | jjdelcerro | this.txtIntervalEnd,
|
1053 | 44077 | jjdelcerro | this.btnIntervalEnd
|
1054 | ); |
||
1055 | this.pickerIntervalStart = swingManager.createDatePickerController(
|
||
1056 | 44085 | jjdelcerro | this.txtIntervalStart,
|
1057 | 44077 | jjdelcerro | this.btnIntervalStart
|
1058 | ); |
||
1059 | 45739 | jjdelcerro | this.pickerSize = evaluatorSwingManager.createCalculatorController(
|
1060 | 44085 | jjdelcerro | this.txtSize, DataTypes.INT
|
1061 | 44077 | jjdelcerro | ); |
1062 | 45739 | jjdelcerro | this.pickerDisplaySize = evaluatorSwingManager.createCalculatorController(this.txtDisplaySize, DataTypes.INT |
1063 | 44844 | jjdelcerro | ); |
1064 | 45739 | jjdelcerro | this.pickerPrecision = evaluatorSwingManager.createCalculatorController(
|
1065 | 44673 | jjdelcerro | this.txtPrecision, DataTypes.INT
|
1066 | ); |
||
1067 | 45739 | jjdelcerro | this.pickerScale = evaluatorSwingManager.createCalculatorController(
|
1068 | 44669 | jjdelcerro | this.txtScale, DataTypes.INT
|
1069 | 44077 | jjdelcerro | ); |
1070 | 46878 | jjdelcerro | this.pickerLocale = swingManager.createLocalePickerController(this.cboLocale); |
1071 | |||
1072 | 45739 | jjdelcerro | this.txtDefaultValue.getComponentPopupMenu().add(evaluatorSwingManager.createJExpressionBuilderAction(txtDefaultValue));
|
1073 | this.pickerOrder = evaluatorSwingManager.createCalculatorController(
|
||
1074 | 44202 | jjdelcerro | this.txtOrder, DataTypes.INT
|
1075 | ); |
||
1076 | 44085 | jjdelcerro | |
1077 | 44202 | jjdelcerro | this.availableValuesController = new AvailableValuesController( |
1078 | 44719 | jjdelcerro | lstAvailableValues, |
1079 | 44262 | jjdelcerro | txtAvailableValuesLabel, |
1080 | txtAvailableValuesValue, |
||
1081 | btnAvailableValuesAdd, |
||
1082 | btnAvailableValuesUpdate, |
||
1083 | 44719 | jjdelcerro | btnAvailableValuesRemove, |
1084 | btnAvailableValuesRemoveAll |
||
1085 | 44202 | jjdelcerro | ); |
1086 | 45873 | jjdelcerro | |
1087 | this.tagsController = new DefaultAggregateController<>( |
||
1088 | this.tblAttrTagsItems,
|
||
1089 | this.btnAttrTagsModify,
|
||
1090 | this.btnAttrTagsDiscard,
|
||
1091 | this.btnAttrTagsAccept,
|
||
1092 | this.btnAttrTagsNew,
|
||
1093 | this.btnAttrTagsDelete,
|
||
1094 | new TagController(
|
||
1095 | this.cboAttrTagsItemName,
|
||
1096 | this.cboAttrTagsItemValue,
|
||
1097 | this.lblAttrTagsItemNotesValue
|
||
1098 | ) |
||
1099 | ); |
||
1100 | 44202 | jjdelcerro | this.txtMinValue.setEnabled(false); |
1101 | this.txtMaxValue.setEnabled(false); |
||
1102 | 44262 | jjdelcerro | |
1103 | 46737 | jjdelcerro | this.btnVirtualFieldGetter.setText(""); |
1104 | 44259 | jjdelcerro | this.featureStoreElement = dataSwingManager.createFeatureStoreElement();
|
1105 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter = evaluatorSwingManager.createExpressionPickerController(
|
1106 | txtVirtualFieldGetter, btnVirtualFieldGetter, btnVirtualFieldBookmarksGetter, btnVirtualFieldHistoryGetter |
||
1107 | 45739 | jjdelcerro | ); |
1108 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.getConfig().addElement(this.featureStoreElement); |
1109 | this.pickerVirtualFieldSetter = evaluatorSwingManager.createExpressionPickerController(
|
||
1110 | txtVirtualFieldSetter, btnVirtualFieldSetter, btnVirtualFieldBookmarksSetter, btnVirtualFieldHistorySetter |
||
1111 | ); |
||
1112 | this.pickerVirtualFieldSetter.getConfig().addElement(this.featureStoreElement); |
||
1113 | |||
1114 | 44719 | jjdelcerro | this.chkVirtualField.addChangeListener((ChangeEvent e) -> { |
1115 | if (chkVirtualField.isSelected()) {
|
||
1116 | 46978 | fdiaz | pickerVirtualFieldGetter.setEditable(mode==MODE_EDIT_ALL || mode==MODE_EDIT_ONLY_METADATA || mode==MODE_VIRTUAL_FIELD); |
1117 | 46737 | jjdelcerro | pickerVirtualFieldSetter.setEditable(false);
|
1118 | 44719 | jjdelcerro | } else {
|
1119 | 46737 | jjdelcerro | pickerVirtualFieldGetter.setEditable(false);
|
1120 | pickerVirtualFieldSetter.setEditable(false);
|
||
1121 | 44719 | jjdelcerro | } |
1122 | 44149 | jjdelcerro | }); |
1123 | 44077 | jjdelcerro | |
1124 | 44149 | jjdelcerro | this.pickerCRS = dataSwingManager.createProjectionPickerController(
|
1125 | this.txtCRS, this.btnCRS |
||
1126 | ); |
||
1127 | |||
1128 | 44719 | jjdelcerro | this.cboFieldType.addItemListener((ItemEvent e) -> { |
1129 | SwingUtilities.invokeLater(() -> {
|
||
1130 | doFieldTypeChanged(); |
||
1131 | }); |
||
1132 | 44085 | jjdelcerro | }); |
1133 | |||
1134 | 44719 | jjdelcerro | this.pickerPrecision.addChangeListener((ChangeEvent e) -> { |
1135 | doCheckPrecisionAndScale(); |
||
1136 | 44100 | jjdelcerro | }); |
1137 | 44719 | jjdelcerro | this.pickerScale.addChangeListener((ChangeEvent e) -> { |
1138 | doCheckPrecisionAndScale(); |
||
1139 | 44100 | jjdelcerro | }); |
1140 | 44262 | jjdelcerro | |
1141 | 44253 | jjdelcerro | DefaultComboBoxModel dataProfilesModel = new DefaultComboBoxModel<>(); |
1142 | 44262 | jjdelcerro | dataProfilesModel.addElement(new ListElement<>("", null)); |
1143 | 44128 | jjdelcerro | for (DataProfile profile : DALLocator.getDataManager().getDataProfiles()) {
|
1144 | 44253 | jjdelcerro | dataProfilesModel.addElement(new ListElement<>(profile.getName(), profile.getID()));
|
1145 | 44128 | jjdelcerro | } |
1146 | this.cboDataProfile.setModel(dataProfilesModel);
|
||
1147 | 44740 | jjdelcerro | |
1148 | this.btnFieldType.addActionListener((ActionEvent e) -> { |
||
1149 | doDataTypeSelection(); |
||
1150 | }); |
||
1151 | |||
1152 | 45739 | jjdelcerro | this.pickerValuesFilter = evaluatorSwingManager.createExpressionPickerController(
|
1153 | txtValuesFilter, btnValuesFilter, btnValuesFilterBookmarks, btnValuesFilterHistory |
||
1154 | ); |
||
1155 | 46586 | fdiaz | this.pickerValuesFilter.getConfig().addElement(this.featureStoreElement); |
1156 | 46751 | jjdelcerro | |
1157 | this.chkIsAutomatic.addActionListener((ActionEvent e) -> { |
||
1158 | doIsAutomaticChanged(); |
||
1159 | }); |
||
1160 | 45739 | jjdelcerro | |
1161 | 46850 | jjdelcerro | this.rdbRelationNone.addItemListener((ItemEvent e) -> { doChangeRelationType(); }); |
1162 | this.rdbRelationToOne.addItemListener((ItemEvent e) -> { doChangeRelationType(); }); |
||
1163 | this.rdbRelationToMany.addItemListener((ItemEvent e) -> { doChangeRelationType(); }); |
||
1164 | |||
1165 | 46950 | jjdelcerro | this.chkDefaultValue.addActionListener((ActionEvent e) -> { |
1166 | txtDefaultValue.setEditable(!chkDefaultValue.isSelected()); |
||
1167 | }); |
||
1168 | |||
1169 | 46850 | jjdelcerro | SwingUtilities.invokeLater( () -> {
|
1170 | splAttrTags.setDividerLocation(0.4);
|
||
1171 | } |
||
1172 | ); |
||
1173 | 46985 | jjdelcerro | ToolsSwingUtils.ensureRowsCols(this, 16,95); |
1174 | 44077 | jjdelcerro | } |
1175 | 46878 | jjdelcerro | |
1176 | private void translate() { |
||
1177 | final ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager();
|
||
1178 | final I18nManager i18n = ToolsLocator.getI18nManager();
|
||
1179 | 46850 | jjdelcerro | |
1180 | 46878 | jjdelcerro | swingManager.translate(this.lblAllowNulls);
|
1181 | swingManager.translate(this.lblCRS);
|
||
1182 | swingManager.translate(this.lblDataProfile);
|
||
1183 | swingManager.translate(this.lblDateFormat);
|
||
1184 | swingManager.translate(this.lblDefaultValue);
|
||
1185 | 46950 | jjdelcerro | swingManager.translate(this.chkDefaultValue);
|
1186 | 46878 | jjdelcerro | swingManager.translate(this.lblDefaultFormat);
|
1187 | swingManager.translate(this.lblFieldName);
|
||
1188 | swingManager.translate(this.lblFieldType);
|
||
1189 | swingManager.translate(this.lblGeometrySubtype);
|
||
1190 | swingManager.translate(this.lblGeometryType);
|
||
1191 | swingManager.translate(this.lblInterval);
|
||
1192 | swingManager.translate(this.lblIntervalEnd);
|
||
1193 | swingManager.translate(this.lblIntervalStart);
|
||
1194 | swingManager.translate(this.lblIsAutomatic);
|
||
1195 | swingManager.translate(this.lblIsIndexed);
|
||
1196 | swingManager.translate(this.lblIsReadOnly);
|
||
1197 | swingManager.translate(this.lblIsPrimaryKey);
|
||
1198 | swingManager.translate(this.lblPrecision);
|
||
1199 | swingManager.translate(this.lblScale);
|
||
1200 | swingManager.translate(this.lblSize);
|
||
1201 | swingManager.translate(this.lblDisplaySize);
|
||
1202 | swingManager.translate(this.chkVirtualField);
|
||
1203 | swingManager.translate(this.lblVirtualField);
|
||
1204 | swingManager.translate(this.lblVirtualFieldSep);
|
||
1205 | swingManager.translate(this.lblVirtualFieldGetter);
|
||
1206 | swingManager.translate(this.lblVirtualFieldSetter);
|
||
1207 | swingManager.translate(this.tabAditionalFields);
|
||
1208 | swingManager.translate(this.tabLayout);
|
||
1209 | swingManager.translate(this.lblGroup);
|
||
1210 | swingManager.translate(this.lblOrder);
|
||
1211 | swingManager.translate(this.lblHidden);
|
||
1212 | swingManager.translate(this.lblLabel);
|
||
1213 | swingManager.translate(this.lblDescription);
|
||
1214 | swingManager.translate(this.lblMinValue);
|
||
1215 | swingManager.translate(this.lblMaxValue);
|
||
1216 | swingManager.translate(this.lblAvailableValues);
|
||
1217 | swingManager.translate(this.lblAvailableValuesLabel);
|
||
1218 | swingManager.translate(this.lblAvailableValuesValue);
|
||
1219 | swingManager.translate(this.btnAvailableValuesAdd);
|
||
1220 | swingManager.translate(this.btnAvailableValuesUpdate);
|
||
1221 | swingManager.translate(this.btnAvailableValuesRemove);
|
||
1222 | swingManager.translate(this.btnAvailableValuesRemoveAll);
|
||
1223 | swingManager.translate(this.lblAttrTagsItemName);
|
||
1224 | swingManager.translate(this.lblAttrTagsItemValue);
|
||
1225 | swingManager.translate(this.lblAttrTagsItemNotes);
|
||
1226 | swingManager.translate(this.lblValuesFilter);
|
||
1227 | |||
1228 | swingManager.translate(this.lblRelationRepository);
|
||
1229 | |||
1230 | swingManager.translate(this.lblRelationNone);
|
||
1231 | swingManager.translate(this.lblRelationToOne);
|
||
1232 | swingManager.translate(this.lblRelationToMany);
|
||
1233 | |||
1234 | swingManager.translate(this.lblRelationToOneType);
|
||
1235 | swingManager.translate(this.lblRelationToOneCondition);
|
||
1236 | swingManager.translate(this.lblRelationToOneLabelFormula);
|
||
1237 | swingManager.translate(this.lblRelationToOneIsClosedList);
|
||
1238 | |||
1239 | swingManager.translate(this.lblRelationToManyType);
|
||
1240 | swingManager.translate(this.lblRelationToManyExpression);
|
||
1241 | swingManager.translate(this.lblRelationToManyCondition);
|
||
1242 | |||
1243 | // swingManager.translate(this.chkIsForeingKey);
|
||
1244 | |||
1245 | swingManager.translate(this.txtDisplaySize);
|
||
1246 | swingManager.translate(this.txtPrecision);
|
||
1247 | swingManager.translate(this.txtScale);
|
||
1248 | swingManager.translate(this.txtScale);
|
||
1249 | swingManager.translate(this.lblLocale);
|
||
1250 | |||
1251 | swingManager.translate(this.rdbRelationToMany);
|
||
1252 | |||
1253 | this.lblRelationToMany.setText( this.lblRelationToMany.getText() + |
||
1254 | " ("+
|
||
1255 | i18n.getTranslation("_Requires_that_it_be_a_calculated_field_of_list_type") +
|
||
1256 | ")"
|
||
1257 | ); |
||
1258 | 47239 | jjdelcerro | swingManager.translate(this.lblRelationVirtual);
|
1259 | swingManager.translate(this.lblRelationReferences1);
|
||
1260 | swingManager.translate(this.lblRelationReferences2);
|
||
1261 | 46878 | jjdelcerro | } |
1262 | |||
1263 | 46850 | jjdelcerro | private int getRelationType() { |
1264 | if( this.rdbRelationNone.isSelected() ) { |
||
1265 | return DynField.RELATION_TYPE_NONE;
|
||
1266 | } |
||
1267 | if( this.rdbRelationToOne.isSelected() ) { |
||
1268 | return this.toOneController.getRelationType(); |
||
1269 | } |
||
1270 | if( this.rdbRelationToMany.isSelected() ) { |
||
1271 | return this.toManyController.getRelationType(); |
||
1272 | } |
||
1273 | return DynField.RELATION_TYPE_NONE;
|
||
1274 | } |
||
1275 | 44085 | jjdelcerro | |
1276 | 46850 | jjdelcerro | private void doChangeRelationType() { |
1277 | boolean enabled;
|
||
1278 | switch(this.getMode() ) { |
||
1279 | case MODE_EDIT_ONLY_METADATA:
|
||
1280 | case MODE_EDIT_ALL:
|
||
1281 | 46978 | fdiaz | case MODE_VIRTUAL_FIELD:
|
1282 | 46850 | jjdelcerro | enabled = true;
|
1283 | break;
|
||
1284 | case MODE_SHOW_ONLY:
|
||
1285 | default:
|
||
1286 | enabled = false;
|
||
1287 | break;
|
||
1288 | } |
||
1289 | |||
1290 | 46876 | jjdelcerro | this.rdbRelationNone.setEnabled(enabled);
|
1291 | 46985 | jjdelcerro | this.rdbRelationToOne.setEnabled(enabled && !(this.getDataType().isObject() || this.getDataType().isContainer())); |
1292 | 46876 | jjdelcerro | this.rdbRelationToMany.setEnabled(enabled && (this.isVirtualField() || this.getDataType().getType()==DataTypes.LIST)); |
1293 | |||
1294 | 46850 | jjdelcerro | if( this.rdbRelationNone.isSelected() ) { |
1295 | this.pickerVirtualFieldGetter.setEnabled(enabled);
|
||
1296 | this.toOneController.setEnabled(false); |
||
1297 | this.toManyController.setEnabled(false); |
||
1298 | } else if( this.rdbRelationToOne.isSelected() ) { |
||
1299 | this.pickerVirtualFieldGetter.setEnabled(enabled);
|
||
1300 | this.toManyController.setEnabled(false); |
||
1301 | 46985 | jjdelcerro | this.toOneController.setEditable(enabled);
|
1302 | this.toOneController.setEnabled(enabled);
|
||
1303 | 46850 | jjdelcerro | } else if( this.rdbRelationToMany.isSelected() ) { |
1304 | if( !this.isVirtualField() || this.getDataType().getType()!=DataTypes.LIST ) { |
||
1305 | this.rdbRelationNone.setSelected(true); |
||
1306 | } else {
|
||
1307 | this.pickerVirtualFieldGetter.setEnabled(false); |
||
1308 | this.toOneController.setEnabled(false); |
||
1309 | 46876 | jjdelcerro | this.toManyController.setEditable(enabled);
|
1310 | 46850 | jjdelcerro | this.toManyController.setEnabled(enabled);
|
1311 | } |
||
1312 | } |
||
1313 | 47281 | fdiaz | this.toOneController.updateEnabledState();
|
1314 | 46850 | jjdelcerro | } |
1315 | |||
1316 | 44077 | jjdelcerro | @Override
|
1317 | public JComponent asJComponent() { |
||
1318 | return this; |
||
1319 | } |
||
1320 | 44740 | jjdelcerro | |
1321 | 46751 | jjdelcerro | private void doIsAutomaticChanged() { |
1322 | if( this.chkIsAutomatic.isSelected() ) { |
||
1323 | DataType type = this.getDataType();
|
||
1324 | 46950 | jjdelcerro | String defaultValue;
|
1325 | if( this.chkDefaultValue.isSelected() ) { |
||
1326 | defaultValue = null;
|
||
1327 | } else {
|
||
1328 | defaultValue = this.txtDefaultValue.getText();
|
||
1329 | } |
||
1330 | 46751 | jjdelcerro | if( type.getType()!=DataTypes.LONG || StringUtils.isNotBlank(defaultValue) ) {
|
1331 | final I18nManager i18n = ToolsLocator.getI18nManager();
|
||
1332 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
1333 | dialogs.messageDialog( |
||
1334 | i18n.getTranslation("_The_automatic_fields_must_be_of_type_long_and_do_not_support_default_values") +
|
||
1335 | "\n" +
|
||
1336 | i18n.getTranslation("_The_type_and_the_default_value_will_be_changed_to_adapt_them_to_these_needs"),
|
||
1337 | (String[])null, |
||
1338 | i18n.getTranslation("_Warning"),
|
||
1339 | JOptionPane.INFORMATION_MESSAGE,
|
||
1340 | "_Automatic_field_flag_force_the_type_to_long_and_an_empty_default_value"
|
||
1341 | ); |
||
1342 | ListElement.setSelected(cboFieldType,DataTypes.LONG); |
||
1343 | this.txtDefaultValue.setText(""); |
||
1344 | } |
||
1345 | } |
||
1346 | updateEditableStates(); |
||
1347 | } |
||
1348 | |||
1349 | 44740 | jjdelcerro | private void doDataTypeSelection() { |
1350 | final DataTypesManager dataManager = ToolsLocator.getDataTypesManager();
|
||
1351 | final I18nManager i18n = ToolsLocator.getI18nManager();
|
||
1352 | List<ListElement<Integer>> types = new ArrayList<>(); |
||
1353 | for (DataType dataType : dataManager) {
|
||
1354 | types.add( new ListElement<>(dataType.getName(), dataType.getType()) );
|
||
1355 | } |
||
1356 | types.sort((ListElement<Integer> o1, ListElement<Integer> o2) -> |
||
1357 | o1.toString().compareTo(o2.toString()) |
||
1358 | ); |
||
1359 | |||
1360 | DefaultListModel<ListElement<Integer>> modelTypes = new DefaultListModel<>(); |
||
1361 | for (ListElement<Integer> element : types) { |
||
1362 | modelTypes.addElement(element); |
||
1363 | } |
||
1364 | final JList list = new JList(); |
||
1365 | list.setCellRenderer(new DefaultListCellRenderer() { |
||
1366 | @Override
|
||
1367 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||
1368 | JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||
1369 | label.setIcon(null);
|
||
1370 | try {
|
||
1371 | DataType dataType = dataManager.get((int) value);
|
||
1372 | IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
||
1373 | if (theme.exists(dataType.getIconName())) {
|
||
1374 | label.setIcon(theme.get(dataType.getIconName())); |
||
1375 | } |
||
1376 | } catch(Exception ex) { |
||
1377 | // Do nothing, ignore
|
||
1378 | } |
||
1379 | return label;
|
||
1380 | } |
||
1381 | }); |
||
1382 | list.setModel(modelTypes); |
||
1383 | final JScrollPane scrollpanel = new JScrollPane(list); |
||
1384 | WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
||
1385 | Dialog dialog = winManager.createDialog(
|
||
1386 | scrollpanel, |
||
1387 | i18n.getTranslation("_Data_type_selection"),
|
||
1388 | i18n.getTranslation("_Select_the_data_type"),
|
||
1389 | WindowManager_v2.BUTTONS_OK_CANCEL |
||
1390 | ); |
||
1391 | dialog.addActionListener((ActionEvent e) -> {
|
||
1392 | if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) {
|
||
1393 | Integer type = (Integer) ListElement.getSelected(list); |
||
1394 | if( type!=null ) { |
||
1395 | ListElement.setSelected(cboFieldType, type); |
||
1396 | if( ListElement.getSelected(cboFieldType)==null ) { |
||
1397 | DataTypesManager dataTypeManager = ToolsLocator.getDataTypesManager(); |
||
1398 | DataType dataType = dataTypeManager.get(type); |
||
1399 | cboFieldType.addItem(new ListElement<>(dataType.getName(), dataType.getType()));
|
||
1400 | ListElement.setSelected(cboFieldType, dataType.getType()); |
||
1401 | } |
||
1402 | } |
||
1403 | } |
||
1404 | }); |
||
1405 | dialog.show(WindowManager.MODE.DIALOG); |
||
1406 | } |
||
1407 | 46721 | fdiaz | |
1408 | private int getMaxAttributeSize(EditableFeatureAttributeDescriptor descriptor) { |
||
1409 | FeatureStore store = descriptor.getStore(); |
||
1410 | if(store == null){ |
||
1411 | return -1; |
||
1412 | } |
||
1413 | DataStoreProviderFactory providerFactory = store.getProviderFactory(); |
||
1414 | if(providerFactory == null){ |
||
1415 | return -1; |
||
1416 | } |
||
1417 | return ((FeatureStoreProviderFactory)providerFactory).getMaxAttributeNameSize();
|
||
1418 | } |
||
1419 | 44077 | jjdelcerro | |
1420 | @Override
|
||
1421 | public EditableFeatureAttributeDescriptor fetch(EditableFeatureAttributeDescriptor descriptor) {
|
||
1422 | 44152 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
1423 | 44085 | jjdelcerro | try {
|
1424 | 46893 | fdiaz | if (this.pickerPrecision.get() != null && this.pickerDisplaySize.get() != null) { |
1425 | if (this.pickerPrecision.get() > this.pickerDisplaySize.get()) { |
||
1426 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
1427 | int n = dialogs.confirmDialog(
|
||
1428 | i18n.getTranslation("_The_precision_is_greater_than_the_display_size") + "\n" |
||
1429 | + i18n.getTranslation("_This_can_cause_problems_with_some_data_providers_like_SHP_or_DBF")+ "\n" |
||
1430 | + i18n.getTranslation("_Do_you_want_to_continue_accepting_the_current_values"),
|
||
1431 | i18n.getTranslation("_Warning"),
|
||
1432 | JOptionPane.YES_NO_OPTION,
|
||
1433 | JOptionPane.WARNING_MESSAGE
|
||
1434 | ); |
||
1435 | if(n != JOptionPane.YES_OPTION){ |
||
1436 | return null; |
||
1437 | } |
||
1438 | } |
||
1439 | } |
||
1440 | 44262 | jjdelcerro | if (!this.chkAllowNulls.isSelected()) { |
1441 | if (descriptor.allowNull()) {
|
||
1442 | 44223 | jjdelcerro | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
1443 | dialogs.messageDialog( |
||
1444 | 44262 | jjdelcerro | i18n.getTranslation("_You_have_marked_not_allow_nulls") + "\n" |
1445 | + i18n.getTranslation("If_you_are_not_fully_aware_of_the_repercussions_of_this_it_is_advisable_to_allow_nulls"),
|
||
1446 | 44223 | jjdelcerro | null,
|
1447 | 44262 | jjdelcerro | i18n.getTranslation("_Warning"),
|
1448 | 44223 | jjdelcerro | JOptionPane.INFORMATION_MESSAGE,
|
1449 | "AllowNullsInFeatureTypeEditing"
|
||
1450 | ); |
||
1451 | } |
||
1452 | } |
||
1453 | 44085 | jjdelcerro | descriptor.setDataType((int) ListElement.getSelected(this.cboFieldType)); |
1454 | 46721 | fdiaz | int maxAttributeNameSize = getMaxAttributeSize(descriptor);
|
1455 | String attrName = this.txtFieldName.getText(); |
||
1456 | if(maxAttributeNameSize > -1 && StringUtils.length(attrName) > maxAttributeNameSize){ |
||
1457 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
1458 | dialogs.messageDialog( |
||
1459 | i18n.getTranslation("_Attribute_name_is_too_long") + "\n" |
||
1460 | + i18n.getTranslation("_max_size_allowed_for_this_table_is_{0}",new String[]{String.valueOf(maxAttributeNameSize)}), |
||
1461 | null,
|
||
1462 | i18n.getTranslation("_Warning"),
|
||
1463 | JOptionPane.WARNING_MESSAGE
|
||
1464 | ); |
||
1465 | return null; |
||
1466 | } |
||
1467 | descriptor.setName(attrName); |
||
1468 | 44085 | jjdelcerro | descriptor.setAllowNull(this.chkAllowNulls.isSelected());
|
1469 | descriptor.setIsPrimaryKey(this.chkIsPrimaryKey.isSelected());
|
||
1470 | descriptor.setIsAutomatic(this.chkIsAutomatic.isSelected());
|
||
1471 | 45920 | jjdelcerro | descriptor.setIsReadOnly(this.chkIsReadOnly.isSelected());
|
1472 | descriptor.setIsIndexed(this.chkIsIndexed.isSelected());
|
||
1473 | 44152 | jjdelcerro | descriptor.setSize(this.pickerSize.get(0)); |
1474 | 44947 | jjdelcerro | descriptor.setDisplaySize(this.pickerDisplaySize.get(0)); |
1475 | 44673 | jjdelcerro | descriptor.setPrecision(this.pickerPrecision.get(0)); |
1476 | 44669 | jjdelcerro | descriptor.setScale(this.pickerScale.get(0)); |
1477 | 46795 | jjdelcerro | |
1478 | 46950 | jjdelcerro | String defaultValue;
|
1479 | if( this.chkDefaultValue.isSelected() ) { |
||
1480 | defaultValue = null;
|
||
1481 | } else {
|
||
1482 | defaultValue = this.txtDefaultValue.getText();
|
||
1483 | } |
||
1484 | 46795 | jjdelcerro | switch(this.mode) { |
1485 | case MODE_EDIT_ONLY_METADATA:
|
||
1486 | if( !ExpressionUtils.isDynamicText(defaultValue) ) {
|
||
1487 | if( !StringUtils.equals(this.previousDefaultValue, defaultValue)) { |
||
1488 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
1489 | dialogs.messageDialog( |
||
1490 | i18n.getTranslation("_In_metadata_editing_only_mode_it_is_only_allowed_to_indicate_default_values_with_dynamic_expressions"),
|
||
1491 | null,
|
||
1492 | i18n.getTranslation("_Warning"),
|
||
1493 | JOptionPane.WARNING_MESSAGE
|
||
1494 | ); |
||
1495 | return null; |
||
1496 | } |
||
1497 | } |
||
1498 | case MODE_EDIT_ALL:
|
||
1499 | case MODE_SHOW_ONLY:
|
||
1500 | 46978 | fdiaz | case MODE_VIRTUAL_FIELD:
|
1501 | 46795 | jjdelcerro | descriptor.setDefaultValue(defaultValue); |
1502 | } |
||
1503 | |||
1504 | 45994 | omartinez | descriptor.setDefaultFormat(this.txtDefaultFormat.getText());
|
1505 | 44253 | jjdelcerro | descriptor.setDataProfileName((String) ListElement.getSelected(this.cboDataProfile)); |
1506 | 44085 | jjdelcerro | switch (descriptor.getType()) {
|
1507 | case DataTypes.GEOMETRY:
|
||
1508 | GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
||
1509 | GeometryType geomType = geomManager.getGeometryType( |
||
1510 | (int) ListElement.getSelected(this.cboGeometryType), |
||
1511 | (int) ListElement.getSelected(this.cboGeometrySubtype) |
||
1512 | ); |
||
1513 | descriptor.setGeometryType(geomType); |
||
1514 | descriptor.setSRS(this.pickerCRS.get());
|
||
1515 | break;
|
||
1516 | case DataTypes.INSTANT:
|
||
1517 | case DataTypes.INTERVAL:
|
||
1518 | case DataTypes.DATE:
|
||
1519 | case DataTypes.TIME:
|
||
1520 | case DataTypes.TIMESTAMP:
|
||
1521 | // FIXME
|
||
1522 | break;
|
||
1523 | default:
|
||
1524 | break;
|
||
1525 | } |
||
1526 | 44154 | jjdelcerro | descriptor.setDataProfileName( |
1527 | 44262 | jjdelcerro | StringUtils.defaultIfBlank((String) ListElement.getSelected(cboDataProfile), null) |
1528 | 44154 | jjdelcerro | ); |
1529 | |||
1530 | 44505 | jjdelcerro | if (this.chkVirtualField.isSelected() ) { //&& this.pickerVirtualField.isEnabled()) { |
1531 | 46737 | jjdelcerro | Expression expression = this.pickerVirtualFieldGetter.get(); |
1532 | 44262 | jjdelcerro | if (expression == null) { |
1533 | descriptor.setFeatureAttributeEmulator((String) null); |
||
1534 | 44085 | jjdelcerro | } else {
|
1535 | DataManager dataManager = DALLocator.getDataManager(); |
||
1536 | FeatureAttributeEmulatorExpression emulator = dataManager.createFeatureAttributeEmulatorExpression( |
||
1537 | 47403 | fdiaz | getFeatureType(descriptor), |
1538 | 44085 | jjdelcerro | expression |
1539 | ); |
||
1540 | 44262 | jjdelcerro | if (!emulator.isValid()) {
|
1541 | 44154 | jjdelcerro | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
1542 | dialogs.messageDialog( |
||
1543 | 44744 | jjdelcerro | i18n.getTranslation("_The_expression_of_virtual_field_is_not_valid")+"\n" |
1544 | 44262 | jjdelcerro | + "\n"
|
1545 | + emulator.getErrorMessage(), |
||
1546 | i18n.getTranslation("_Warning"),
|
||
1547 | 44154 | jjdelcerro | JOptionPane.WARNING_MESSAGE
|
1548 | ); |
||
1549 | return null; |
||
1550 | } |
||
1551 | for (String requiredFieldName : emulator.getRequiredFieldNames()) { |
||
1552 | 44262 | jjdelcerro | if (StringUtils.equalsIgnoreCase(requiredFieldName, descriptor.getName())) {
|
1553 | 44154 | jjdelcerro | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
1554 | dialogs.messageDialog( |
||
1555 | 44262 | jjdelcerro | i18n.getTranslation("_The_expression_of_virtual_field_is_not_valid")
|
1556 | + "\n\n"
|
||
1557 | + i18n.getTranslation("_The_expression_contains_a_reference_to_itself"),
|
||
1558 | i18n.getTranslation("_Warning"),
|
||
1559 | 44154 | jjdelcerro | JOptionPane.WARNING_MESSAGE
|
1560 | ); |
||
1561 | return null; |
||
1562 | } |
||
1563 | } |
||
1564 | 44744 | jjdelcerro | List<String> undefinedSymbols = emulator.getUndefinedSymbols(); |
1565 | if( undefinedSymbols!=null && !undefinedSymbols.isEmpty() ) { |
||
1566 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
1567 | dialogs.messageDialog( |
||
1568 | i18n.getTranslation("_The_expression_has_undefined_symbols_at_this_moment")+"\n" |
||
1569 | + i18n.getTranslation("_This_may_not_be_a_mistake")+"\n" |
||
1570 | + "\n"
|
||
1571 | + "("+StringUtils.join(undefinedSymbols,",")+")", |
||
1572 | i18n.getTranslation("_Warning"),
|
||
1573 | JOptionPane.WARNING_MESSAGE
|
||
1574 | ); |
||
1575 | } |
||
1576 | 44154 | jjdelcerro | //
|
1577 | // No se porque esto de abajo no funciona.
|
||
1578 | // Nunca se lanza la excepcion en el get(Feature) de
|
||
1579 | // DefaultFeatureAttributeEmulatorExpression.
|
||
1580 | //
|
||
1581 | 46104 | omartinez | try {
|
1582 | emulator.setEnableExceptions(true);
|
||
1583 | 44154 | jjdelcerro | // descriptor.setFeatureAttributeEmulator(emulator);
|
1584 | 46104 | omartinez | emulator.get(this.sampleFeature);
|
1585 | } catch(Throwable ex) { |
||
1586 | 44154 | jjdelcerro | // emulator.setEnableExceptions(false);
|
1587 | // descriptor.setFeatureAttributeEmulator(null);
|
||
1588 | 46104 | omartinez | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
1589 | dialogs.messageDialog( |
||
1590 | i18n.getTranslation("_The_expression_can_not_be_evaluated_right_now_It_could_be_valid_when_all_changes_has_been_applied")+
|
||
1591 | "\n"+
|
||
1592 | ex.getMessage(), |
||
1593 | i18n.getTranslation("_Warning"),
|
||
1594 | JOptionPane.WARNING_MESSAGE
|
||
1595 | ); |
||
1596 | 44154 | jjdelcerro | // return null;
|
1597 | 46104 | omartinez | } finally {
|
1598 | emulator.setEnableExceptions(false);
|
||
1599 | } |
||
1600 | descriptor.setFeatureAttributeEmulator(emulator); |
||
1601 | 44085 | jjdelcerro | } |
1602 | } |
||
1603 | } catch (Exception ex) { |
||
1604 | 44262 | jjdelcerro | LOGGER.warn("Can't retrieve information from user form.", ex);
|
1605 | 44085 | jjdelcerro | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
1606 | dialogs.messageDialog( |
||
1607 | 44262 | jjdelcerro | i18n.getTranslation("_Cant_retrieve_information_from_user_form")
|
1608 | + "\n"
|
||
1609 | + i18n.getTranslation("_See_log_for_details"),
|
||
1610 | i18n.getTranslation("_Warning"),
|
||
1611 | 44085 | jjdelcerro | JOptionPane.WARNING_MESSAGE
|
1612 | ); |
||
1613 | 44152 | jjdelcerro | return null; |
1614 | 44085 | jjdelcerro | } |
1615 | 44262 | jjdelcerro | |
1616 | 44202 | jjdelcerro | descriptor.setGroup(StringUtils.defaultIfBlank((String) this.cboGroup.getSelectedItem(), null)); |
1617 | descriptor.setOrder(this.pickerOrder.get(0)); |
||
1618 | descriptor.setHidden(this.chkHidden.isSelected());
|
||
1619 | descriptor.setLabel(StringUtils.defaultIfBlank(this.txtLabel.getText(), null)); |
||
1620 | descriptor.setDescription(StringUtils.defaultIfBlank(this.txtDescription.getText(), null)); |
||
1621 | 44262 | jjdelcerro | |
1622 | 44202 | jjdelcerro | // this.txtMinValue.setText(Objects.toString(descriptor.getMinValue(), ""));
|
1623 | // this.txtMinValue.setText(Objects.toString(descriptor.getMaxValue(), ""));
|
||
1624 | 45739 | jjdelcerro | Expression valuesFilter = this.pickerValuesFilter.get(); |
1625 | |||
1626 | 44262 | jjdelcerro | descriptor.setAvailableValues(this.availableValuesController.get());
|
1627 | 46878 | jjdelcerro | descriptor.setLocale(this.pickerLocale.get());
|
1628 | 44202 | jjdelcerro | |
1629 | 45873 | jjdelcerro | this.tagsController.getModel().fetch(descriptor.getTags());
|
1630 | 46850 | jjdelcerro | |
1631 | this.toOneController.fetch(descriptor);
|
||
1632 | this.toManyController.fetch(descriptor);
|
||
1633 | if( rdbRelationToOne.isSelected() ) {
|
||
1634 | descriptor.setRelationType(this.toOneController.getRelationType());
|
||
1635 | descriptor.getForeingKey().setForeingKey(true);
|
||
1636 | } else if( rdbRelationToMany.isSelected() ) { |
||
1637 | descriptor.setRelationType(this.toManyController.getRelationType());
|
||
1638 | descriptor.getForeingKey().setForeingKey(false);
|
||
1639 | 46978 | fdiaz | descriptor.setFeatureAttributeEmulator(this.toManyController.getExpression());
|
1640 | 46850 | jjdelcerro | } else if( rdbRelationNone.isSelected() ) { |
1641 | descriptor.setRelationType(DynField.RELATION_TYPE_NONE); |
||
1642 | descriptor.getForeingKey().setForeingKey(false);
|
||
1643 | } |
||
1644 | |||
1645 | |||
1646 | 44077 | jjdelcerro | return descriptor;
|
1647 | } |
||
1648 | |||
1649 | 44202 | jjdelcerro | @Override
|
1650 | 44077 | jjdelcerro | public void clean() { |
1651 | 45072 | omartinez | this.txtDefaultValue.setText(""); |
1652 | 46950 | jjdelcerro | this.chkDefaultValue.setEnabled(true); |
1653 | this.txtDefaultValue.setEditable(false); |
||
1654 | 45994 | omartinez | this.txtDefaultFormat.setText(""); |
1655 | 44100 | jjdelcerro | this.txtFieldName.setText(""); |
1656 | // this.pickerFieldName.set(null);
|
||
1657 | 44077 | jjdelcerro | this.pickerIntervalEnd.set(null); |
1658 | this.pickerIntervalStart.set(null); |
||
1659 | 44669 | jjdelcerro | this.pickerScale.set(null); |
1660 | 44077 | jjdelcerro | this.pickerSize.set(null); |
1661 | 44947 | jjdelcerro | this.pickerDisplaySize.set(null); |
1662 | 44077 | jjdelcerro | |
1663 | this.chkAllowNulls.setSelected(false); |
||
1664 | this.chkIsAutomatic.setSelected(false); |
||
1665 | 45920 | jjdelcerro | this.chkIsReadOnly.setSelected(false); |
1666 | this.chkIsIndexed.setSelected(false); |
||
1667 | 44077 | jjdelcerro | this.chkIsPrimaryKey.setSelected(false); |
1668 | 44085 | jjdelcerro | |
1669 | 46978 | fdiaz | switch (this.mode){ |
1670 | case MODE_EDIT_ALL:
|
||
1671 | case MODE_EDIT_ONLY_METADATA:
|
||
1672 | this.chkVirtualField.setSelected(false); |
||
1673 | this.chkVirtualField.setEnabled(true); |
||
1674 | break;
|
||
1675 | case MODE_SHOW_ONLY:
|
||
1676 | this.chkVirtualField.setSelected(false); |
||
1677 | this.chkVirtualField.setEnabled(false); |
||
1678 | break;
|
||
1679 | case MODE_VIRTUAL_FIELD:
|
||
1680 | this.chkVirtualField.setSelected(true); |
||
1681 | this.chkVirtualField.setEnabled(false); |
||
1682 | break;
|
||
1683 | } |
||
1684 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEditable(false); |
1685 | this.pickerVirtualFieldGetter.set(null); |
||
1686 | 44077 | jjdelcerro | |
1687 | ListElement.setSelected(cboGeometryType, null);
|
||
1688 | ListElement.setSelected(cboGeometrySubtype, null);
|
||
1689 | 44085 | jjdelcerro | |
1690 | ListElement.setSelected(cboFieldType, DataTypes.STRING); |
||
1691 | 44262 | jjdelcerro | |
1692 | 44128 | jjdelcerro | this.cboDataProfile.setSelectedIndex(-1); |
1693 | 44262 | jjdelcerro | |
1694 | 44202 | jjdelcerro | this.cboGroup.setSelectedIndex(-1); |
1695 | this.pickerOrder.set(null); |
||
1696 | this.chkHidden.setSelected(false); |
||
1697 | this.txtLabel.setText(""); |
||
1698 | this.txtDescription.setText(""); |
||
1699 | this.txtMinValue.setText(""); |
||
1700 | this.txtMaxValue.setText(""); |
||
1701 | this.availableValuesController.clean();
|
||
1702 | 44262 | jjdelcerro | this.tagsController.clean();
|
1703 | 46850 | jjdelcerro | this.toOneController.clean();
|
1704 | 44077 | jjdelcerro | } |
1705 | 44085 | jjdelcerro | |
1706 | 44077 | jjdelcerro | @Override
|
1707 | public void put(FeatureAttributeDescriptor descriptor) { |
||
1708 | 44085 | jjdelcerro | if (descriptor == null) { |
1709 | 44077 | jjdelcerro | this.clean();
|
1710 | return;
|
||
1711 | } |
||
1712 | 44678 | jjdelcerro | DataType dataType = descriptor.getDataType(); |
1713 | 44202 | jjdelcerro | FeatureType featureType = descriptor.getFeatureType(); |
1714 | DefaultComboBoxModel groupModel = new DefaultComboBoxModel(); |
||
1715 | 44262 | jjdelcerro | |
1716 | if (featureType != null) { |
||
1717 | 44100 | jjdelcerro | FeatureStore store = descriptor.getFeatureType().getStore(); |
1718 | 44149 | jjdelcerro | this.featureStoreElement.setFeatureStore(store);
|
1719 | 44262 | jjdelcerro | if (store != null) { |
1720 | 46722 | fdiaz | this.sampleFeature = store.getSampleFeature();
|
1721 | 44262 | jjdelcerro | if (sampleFeature != null) { |
1722 | 44100 | jjdelcerro | FeatureSymbolTable featureSymbolTable = DALLocator.getDataManager().createFeatureSymbolTable(); |
1723 | featureSymbolTable.setFeature(sampleFeature); |
||
1724 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.getConfig().setPreviewSymbolTable(featureSymbolTable.createParent());
|
1725 | 46586 | fdiaz | this.pickerValuesFilter.getConfig().setPreviewSymbolTable(featureSymbolTable.createParent());
|
1726 | 44100 | jjdelcerro | } |
1727 | } |
||
1728 | 44202 | jjdelcerro | List<String> groups = new ArrayList<>(); |
1729 | for (FeatureAttributeDescriptor otherdesc : featureType) {
|
||
1730 | String group = otherdesc.getGroup();
|
||
1731 | 44262 | jjdelcerro | if (!StringUtils.isBlank(group) && !groups.contains(group)) {
|
1732 | 44202 | jjdelcerro | groups.add(group); |
1733 | } |
||
1734 | } |
||
1735 | for (String group : groups) { |
||
1736 | groupModel.addElement(group); |
||
1737 | } |
||
1738 | 44085 | jjdelcerro | } |
1739 | 44262 | jjdelcerro | |
1740 | 46950 | jjdelcerro | this.previousDefaultValue = Objects.toString(descriptor.getDefaultValue(),null); |
1741 | if( this.previousDefaultValue == null ) { |
||
1742 | this.txtDefaultValue.setText(""); |
||
1743 | this.chkDefaultValue.setSelected(true); |
||
1744 | this.txtDefaultValue.setEditable(false); |
||
1745 | } else {
|
||
1746 | this.txtDefaultValue.setText(this.previousDefaultValue); |
||
1747 | this.chkDefaultValue.setSelected(false); |
||
1748 | this.txtDefaultValue.setEditable(true); |
||
1749 | } |
||
1750 | |||
1751 | 45994 | omartinez | this.txtDefaultFormat.setText(Objects.toString(descriptor.getDefaultFormat(),"")); |
1752 | 44100 | jjdelcerro | this.txtFieldName.setText(descriptor.getName());
|
1753 | 44077 | jjdelcerro | RelativeInterval interval = (RelativeInterval) descriptor.getInterval(); |
1754 | 44085 | jjdelcerro | if (interval == null) { |
1755 | this.pickerIntervalEnd.set(null); |
||
1756 | this.pickerIntervalStart.set(null); |
||
1757 | 44077 | jjdelcerro | } else {
|
1758 | this.pickerIntervalEnd.set(interval.getEnd().toDate());
|
||
1759 | this.pickerIntervalStart.set(interval.getStart().toDate());
|
||
1760 | } |
||
1761 | 44678 | jjdelcerro | if( dataType.supportSize() ) {
|
1762 | this.pickerSize.set(descriptor.getSize());
|
||
1763 | } else {
|
||
1764 | this.pickerSize.set(null); |
||
1765 | } |
||
1766 | 44947 | jjdelcerro | this.pickerDisplaySize.set(descriptor.getDisplaySize());
|
1767 | 44678 | jjdelcerro | if( dataType.supportPrecision() ) {
|
1768 | this.pickerPrecision.set(descriptor.getPrecision());
|
||
1769 | } else {
|
||
1770 | this.pickerPrecision.set(null); |
||
1771 | } |
||
1772 | if( dataType.supportScale()) {
|
||
1773 | this.pickerScale.set(descriptor.getScale());
|
||
1774 | } else {
|
||
1775 | this.pickerScale.set(null); |
||
1776 | } |
||
1777 | 44077 | jjdelcerro | this.chkAllowNulls.setSelected(descriptor.allowNull());
|
1778 | this.chkIsAutomatic.setSelected(descriptor.isAutomatic());
|
||
1779 | 45920 | jjdelcerro | this.chkIsReadOnly.setSelected(descriptor.isReadOnly());
|
1780 | this.chkIsIndexed.setSelected(descriptor.isIndexed());
|
||
1781 | 44077 | jjdelcerro | this.chkIsPrimaryKey.setSelected(descriptor.isPrimaryKey());
|
1782 | 44085 | jjdelcerro | |
1783 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEnabled(true); |
1784 | 44077 | jjdelcerro | FeatureAttributeEmulator attrEmulator = descriptor.getFeatureAttributeEmulator(); |
1785 | 44085 | jjdelcerro | if (attrEmulator instanceof FeatureAttributeEmulatorExpression) { |
1786 | 44077 | jjdelcerro | Expression expression = ((FeatureAttributeEmulatorExpression) attrEmulator).getExpression();
|
1787 | 44505 | jjdelcerro | this.chkVirtualField.setEnabled(this.mode==MODE_EDIT_ALL); |
1788 | 44077 | jjdelcerro | this.chkVirtualField.setSelected(true); |
1789 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.set(expression);
|
1790 | 44085 | jjdelcerro | } else if (descriptor.isComputed()) { |
1791 | this.chkVirtualField.setEnabled(false); |
||
1792 | 44077 | jjdelcerro | this.chkVirtualField.setSelected(true); |
1793 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.set(null); |
1794 | 44077 | jjdelcerro | } else {
|
1795 | 44505 | jjdelcerro | this.chkVirtualField.setEnabled(this.mode==MODE_EDIT_ALL); |
1796 | 44077 | jjdelcerro | this.chkVirtualField.setSelected(false); |
1797 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.set(null); |
1798 | 44077 | jjdelcerro | } |
1799 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEnabled(true); |
1800 | 44085 | jjdelcerro | |
1801 | 45739 | jjdelcerro | Expression expression = descriptor.getAvailableValuesFilter();
|
1802 | this.pickerValuesFilter.set(expression);
|
||
1803 | |||
1804 | 44077 | jjdelcerro | this.pickerCRS.set(descriptor.getSRS());
|
1805 | 44085 | jjdelcerro | |
1806 | if (descriptor.getGeomType() != null) { |
||
1807 | 44079 | jjdelcerro | ListElement.setSelected(cboGeometryType, descriptor.getGeomType().getType()); |
1808 | ListElement.setSelected(cboGeometrySubtype, descriptor.getGeomType().getSubType()); |
||
1809 | } |
||
1810 | 44740 | jjdelcerro | ListElement.setSelected(cboFieldType, dataType.getType()); |
1811 | if( ListElement.getSelected(cboFieldType)==null ) { |
||
1812 | cboFieldType.addItem(new ListElement<>(dataType.getName(), dataType.getType()));
|
||
1813 | ListElement.setSelected(cboFieldType, dataType.getType()); |
||
1814 | } |
||
1815 | |||
1816 | 44128 | jjdelcerro | String profile = descriptor.getDataProfileName();
|
1817 | 44262 | jjdelcerro | if (StringUtils.isBlank(profile)) {
|
1818 | this.cboDataProfile.setSelectedIndex(-1); |
||
1819 | 44128 | jjdelcerro | } else {
|
1820 | 44262 | jjdelcerro | ListElement.setSelected(this.cboDataProfile, profile);
|
1821 | 44128 | jjdelcerro | } |
1822 | 44202 | jjdelcerro | |
1823 | this.cboGroup.setModel(groupModel);
|
||
1824 | 44262 | jjdelcerro | this.cboGroup.setSelectedItem(StringUtils.defaultIfBlank(descriptor.getGroup(), "")); |
1825 | 44202 | jjdelcerro | this.pickerOrder.set(descriptor.getOder());
|
1826 | this.chkHidden.setSelected(descriptor.isHidden());
|
||
1827 | 44578 | omartinez | if (descriptor.hasLabel()) {
|
1828 | this.txtLabel.setText(StringUtils.defaultIfBlank(descriptor.getLabel(), "")); |
||
1829 | } else {
|
||
1830 | this.txtLabel.setText(""); |
||
1831 | } |
||
1832 | if (descriptor.hasDescription()) {
|
||
1833 | this.txtDescription.setText(StringUtils.defaultIfBlank(descriptor.getDescription(), "")); |
||
1834 | } else {
|
||
1835 | this.txtDescription.setText(""); |
||
1836 | } |
||
1837 | 44202 | jjdelcerro | this.txtMinValue.setText(Objects.toString(descriptor.getMinValue(), "")); |
1838 | this.txtMinValue.setText(Objects.toString(descriptor.getMaxValue(), "")); |
||
1839 | 44719 | jjdelcerro | if( descriptor.hasConstantAvailableValues() ) {
|
1840 | this.availableValuesController.set(descriptor.getAvailableValues());
|
||
1841 | } else {
|
||
1842 | this.availableValuesController.clean();
|
||
1843 | } |
||
1844 | 45873 | jjdelcerro | this.tagsController.setModel(new TagsModel(descriptor.getTags())); |
1845 | 46878 | jjdelcerro | this.pickerLocale.set(descriptor.getLocale());
|
1846 | 44202 | jjdelcerro | |
1847 | 46850 | jjdelcerro | this.toOneController.put(descriptor);
|
1848 | this.toManyController.put(descriptor);
|
||
1849 | switch(descriptor.getRelationType()) {
|
||
1850 | case DynField.RELATION_TYPE_NONE:
|
||
1851 | this.rdbRelationNone.setSelected(true); |
||
1852 | this.rdbRelationToOne.setSelected(false); |
||
1853 | 46876 | jjdelcerro | this.rdbRelationToMany.setSelected(false); |
1854 | // No los borramos, solo quedan deshabilitados, para no peder la informacion que contengan
|
||
1855 | // this.toOneController.clean();
|
||
1856 | // this.toManyController.clean();
|
||
1857 | 46850 | jjdelcerro | break;
|
1858 | case DynField.RELATION_TYPE_IDENTITY:
|
||
1859 | case DynField.RELATION_TYPE_COLLABORATION:
|
||
1860 | 47144 | jjdelcerro | case DynField.RELATION_TYPE_COLLABORATION_WITH_COMPOSITION:
|
1861 | 46850 | jjdelcerro | this.rdbRelationNone.setSelected(false); |
1862 | this.rdbRelationToOne.setSelected(true); |
||
1863 | this.rdbRelationToMany.setSelected(false); |
||
1864 | 46876 | jjdelcerro | // this.toManyController.clean();
|
1865 | 46850 | jjdelcerro | break;
|
1866 | case DynField.RELATION_TYPE_COMPOSITION:
|
||
1867 | case DynField.RELATION_TYPE_AGGREGATE:
|
||
1868 | this.rdbRelationNone.setSelected(false); |
||
1869 | this.rdbRelationToOne.setSelected(false); |
||
1870 | this.rdbRelationToMany.setSelected(true); |
||
1871 | this.pickerVirtualFieldGetter.setEnabled(false); |
||
1872 | // this.pickerVirtualFieldGetter.set(null);
|
||
1873 | 46876 | jjdelcerro | // this.toOneController.clean();
|
1874 | 46850 | jjdelcerro | break;
|
1875 | |||
1876 | } |
||
1877 | 44505 | jjdelcerro | |
1878 | if (!(descriptor instanceof EditableFeatureAttributeDescriptor)) { |
||
1879 | this.setMode(FeatureTypePanel.MODE_SHOW_ONLY);
|
||
1880 | } |
||
1881 | this.updateEditableStates();
|
||
1882 | 44077 | jjdelcerro | } |
1883 | 47403 | fdiaz | |
1884 | public void setFeatureType(FeatureType featureType){ |
||
1885 | this.featureType = featureType;
|
||
1886 | this.toManyController.setFeatureType(featureType);
|
||
1887 | } |
||
1888 | |||
1889 | private FeatureType getFeatureType(FeatureAttributeDescriptor descriptor) {
|
||
1890 | if(descriptor == null || descriptor.getFeatureType() == null){ |
||
1891 | return this.featureType; |
||
1892 | } |
||
1893 | return descriptor.getFeatureType();
|
||
1894 | } |
||
1895 | 44077 | jjdelcerro | |
1896 | 44673 | jjdelcerro | private DataType getDataType() {
|
1897 | Integer fieldType = (Integer) ListElement.getSelected(this.cboFieldType); |
||
1898 | if (fieldType == null) { |
||
1899 | return null; |
||
1900 | } |
||
1901 | DataType dataType = ToolsLocator.getDataTypesManager().get(fieldType); |
||
1902 | return dataType;
|
||
1903 | } |
||
1904 | |||
1905 | 44085 | jjdelcerro | private void doFieldTypeChanged() { |
1906 | 44673 | jjdelcerro | try {
|
1907 | DataType dataType = this.getDataType();
|
||
1908 | 44262 | jjdelcerro | |
1909 | 44673 | jjdelcerro | if( dataType.supportSize() ) {
|
1910 | 46978 | fdiaz | this.pickerSize.setEditable(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
1911 | 44673 | jjdelcerro | } else {
|
1912 | this.pickerSize.setEditable(false); |
||
1913 | this.pickerSize.set(null); |
||
1914 | } |
||
1915 | 46978 | fdiaz | this.pickerDisplaySize.setEditable(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
1916 | 44678 | jjdelcerro | if( dataType.supportPrecision() ) {
|
1917 | if( dataType.isPredefinedPrecision() ) {
|
||
1918 | this.pickerPrecision.setEditable(false); |
||
1919 | } else {
|
||
1920 | 46978 | fdiaz | this.pickerPrecision.setEditable(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
1921 | 44678 | jjdelcerro | } |
1922 | 44673 | jjdelcerro | } else {
|
1923 | this.pickerPrecision.setEditable(false); |
||
1924 | this.pickerPrecision.set(null); |
||
1925 | } |
||
1926 | if( dataType.supportScale()) {
|
||
1927 | 46978 | fdiaz | this.pickerScale.setEditable(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
1928 | 44673 | jjdelcerro | } else {
|
1929 | this.pickerScale.setEditable(false); |
||
1930 | this.pickerScale.set(null); |
||
1931 | } |
||
1932 | switch (dataType.getType()) {
|
||
1933 | case DataTypes.GEOMETRY:
|
||
1934 | 46978 | fdiaz | this.cboGeometryType.setEnabled(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
1935 | this.cboGeometrySubtype.setEnabled(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
||
1936 | this.pickerCRS.setEditable(this.mode == MODE_EDIT_ALL || this.isVirtualField()); |
||
1937 | 44673 | jjdelcerro | this.cboDateFormat.setEnabled(false); |
1938 | this.pickerIntervalStart.setEditable(false); |
||
1939 | this.pickerIntervalEnd.setEditable(false); |
||
1940 | this.tabAditionalFields.setEnabledAt(1, true); |
||
1941 | this.tabAditionalFields.setEnabledAt(2, false); |
||
1942 | break;
|
||
1943 | case DataTypes.INSTANT:
|
||
1944 | case DataTypes.INTERVAL:
|
||
1945 | case DataTypes.DATE:
|
||
1946 | case DataTypes.TIME:
|
||
1947 | case DataTypes.TIMESTAMP:
|
||
1948 | this.cboGeometryType.setEnabled(false); |
||
1949 | this.cboGeometrySubtype.setEnabled(false); |
||
1950 | this.pickerCRS.setEditable(false); |
||
1951 | 46978 | fdiaz | this.cboDateFormat.setEnabled(this.mode == MODE_EDIT_ALL || this.mode == MODE_EDIT_ONLY_METADATA || this.isVirtualField()); |
1952 | this.pickerIntervalStart.setEnabled(this.mode == MODE_EDIT_ALL || this.mode == MODE_EDIT_ONLY_METADATA || this.isVirtualField()); |
||
1953 | this.pickerIntervalEnd.setEnabled(this.mode == MODE_EDIT_ALL || this.mode == MODE_EDIT_ONLY_METADATA || this.isVirtualField()); |
||
1954 | 44673 | jjdelcerro | this.tabAditionalFields.setEnabledAt(1, false); |
1955 | this.tabAditionalFields.setEnabledAt(2, true); |
||
1956 | break;
|
||
1957 | case DataTypes.BYTE:
|
||
1958 | case DataTypes.INT:
|
||
1959 | case DataTypes.LONG:
|
||
1960 | case DataTypes.STRING:
|
||
1961 | case DataTypes.FILE:
|
||
1962 | case DataTypes.URL:
|
||
1963 | case DataTypes.URI:
|
||
1964 | case DataTypes.FLOAT:
|
||
1965 | case DataTypes.DOUBLE:
|
||
1966 | case DataTypes.DECIMAL:
|
||
1967 | this.cboGeometryType.setEnabled(false); |
||
1968 | this.cboGeometrySubtype.setEnabled(false); |
||
1969 | this.pickerCRS.setEditable(false); |
||
1970 | this.cboDateFormat.setEnabled(false); |
||
1971 | this.pickerIntervalStart.setEditable(false); |
||
1972 | this.pickerIntervalEnd.setEditable(false); |
||
1973 | this.tabAditionalFields.setEnabledAt(1, false); |
||
1974 | this.tabAditionalFields.setEnabledAt(2, false); |
||
1975 | break;
|
||
1976 | default:
|
||
1977 | this.cboGeometryType.setEnabled(false); |
||
1978 | this.cboGeometrySubtype.setEnabled(false); |
||
1979 | this.pickerCRS.setEditable(false); |
||
1980 | this.cboDateFormat.setEnabled(false); |
||
1981 | this.pickerIntervalStart.setEditable(false); |
||
1982 | this.pickerIntervalEnd.setEditable(false); |
||
1983 | this.tabAditionalFields.setEnabledAt(1, false); |
||
1984 | this.tabAditionalFields.setEnabledAt(2, false); |
||
1985 | 44085 | jjdelcerro | } |
1986 | 46850 | jjdelcerro | // updateRelationState();
|
1987 | doChangeRelationType(); |
||
1988 | 44673 | jjdelcerro | } catch (Exception ex) { |
1989 | LOGGER.warn("Problems changing field type.", ex);
|
||
1990 | } |
||
1991 | 44262 | jjdelcerro | |
1992 | 44077 | jjdelcerro | } |
1993 | 44673 | jjdelcerro | |
1994 | 44505 | jjdelcerro | boolean isVirtualField() {
|
1995 | return this.chkVirtualField.isSelected(); |
||
1996 | } |
||
1997 | 44085 | jjdelcerro | |
1998 | 44202 | jjdelcerro | @Override
|
1999 | 44505 | jjdelcerro | public int getMode() { |
2000 | return this.mode; |
||
2001 | } |
||
2002 | |||
2003 | @Override
|
||
2004 | public void setMode(int mode) { |
||
2005 | this.mode = mode;
|
||
2006 | updateEditableStates(); |
||
2007 | } |
||
2008 | |||
2009 | private void updateEditableStates() { |
||
2010 | 44673 | jjdelcerro | DataType dataType = this.getDataType();
|
2011 | 44505 | jjdelcerro | switch(this.mode) { |
2012 | case MODE_EDIT_ALL:
|
||
2013 | 46751 | jjdelcerro | this.txtDefaultValue.setEditable(!this.chkIsAutomatic.isSelected()); |
2014 | 46950 | jjdelcerro | this.chkDefaultValue.setEnabled(this.txtDefaultValue.isEditable()); |
2015 | 45994 | omartinez | this.txtDefaultFormat.setEditable(true); |
2016 | 44505 | jjdelcerro | this.txtFieldName.setEditable(true); |
2017 | this.pickerIntervalEnd.setEditable(true); |
||
2018 | this.pickerIntervalStart.setEditable(true); |
||
2019 | 44673 | jjdelcerro | this.pickerSize.setEditable(dataType.supportSize());
|
2020 | 44947 | jjdelcerro | this.pickerDisplaySize.setEditable(true); |
2021 | 44677 | jjdelcerro | if( dataType.isPredefinedPrecision() ) {
|
2022 | 44673 | jjdelcerro | this.pickerPrecision.setEditable(false); |
2023 | this.pickerPrecision.set(dataType.getMaxPrecision());
|
||
2024 | } else {
|
||
2025 | this.pickerPrecision.setEditable(dataType.supportPrecision());
|
||
2026 | } |
||
2027 | this.pickerScale.setEditable(dataType.supportScale());
|
||
2028 | 44505 | jjdelcerro | this.cboDataProfile.setEnabled(true); |
2029 | 44085 | jjdelcerro | |
2030 | 44505 | jjdelcerro | this.chkAllowNulls.setEnabled(true); |
2031 | this.chkIsAutomatic.setEnabled(true); |
||
2032 | 45920 | jjdelcerro | this.chkIsReadOnly.setEnabled(true); |
2033 | this.chkIsIndexed.setEnabled(true); |
||
2034 | 44505 | jjdelcerro | if( this.isVirtualField() ) { |
2035 | 46872 | jjdelcerro | this.chkIsPrimaryKey.setEnabled(false); |
2036 | } else {
|
||
2037 | 46500 | jjdelcerro | this.chkIsPrimaryKey.setEnabled(true); |
2038 | 44505 | jjdelcerro | } |
2039 | 44085 | jjdelcerro | |
2040 | 44505 | jjdelcerro | this.chkVirtualField.setEnabled(true); |
2041 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEditable(true); |
2042 | 44085 | jjdelcerro | |
2043 | 44505 | jjdelcerro | this.cboDateFormat.setEnabled(true); |
2044 | 46751 | jjdelcerro | this.cboFieldType.setEnabled(!this.chkIsAutomatic.isSelected()); |
2045 | this.btnFieldType.setEnabled(!this.chkIsAutomatic.isSelected()); |
||
2046 | 44505 | jjdelcerro | this.cboGeometryType.setEnabled(true); |
2047 | this.cboGeometrySubtype.setEnabled(true); |
||
2048 | this.pickerCRS.setEditable(true); |
||
2049 | 44085 | jjdelcerro | |
2050 | 44505 | jjdelcerro | this.cboGroup.setEnabled(true); |
2051 | this.pickerOrder.setEditable(true); |
||
2052 | this.chkHidden.setEnabled(true); |
||
2053 | this.txtLabel.setEditable(true); |
||
2054 | this.txtDescription.setEditable(true); |
||
2055 | this.txtMinValue.setEditable(false); |
||
2056 | this.txtMaxValue.setEditable(false); |
||
2057 | 45739 | jjdelcerro | this.pickerValuesFilter.setEditable(true); |
2058 | 44505 | jjdelcerro | this.availableValuesController.setEditable(true); |
2059 | 45873 | jjdelcerro | this.tagsController.setEnabled(true); |
2060 | 46878 | jjdelcerro | this.pickerLocale.setEnabled(true); |
2061 | 44505 | jjdelcerro | break;
|
2062 | case MODE_EDIT_ONLY_METADATA:
|
||
2063 | if( this.chkVirtualField.isSelected() ) { |
||
2064 | this.txtFieldName.setEditable(true); |
||
2065 | 44669 | jjdelcerro | this.pickerScale.setEditable(true); |
2066 | 44505 | jjdelcerro | this.pickerSize.setEditable(true); |
2067 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEditable(true); |
2068 | 44505 | jjdelcerro | this.cboFieldType.setEnabled(true); |
2069 | 46676 | jjdelcerro | this.btnFieldType.setEnabled(true); |
2070 | 44505 | jjdelcerro | this.cboGeometryType.setEnabled(true); |
2071 | this.cboGeometrySubtype.setEnabled(true); |
||
2072 | this.pickerCRS.setEditable(true); |
||
2073 | } else {
|
||
2074 | this.txtFieldName.setEditable(false); |
||
2075 | 44673 | jjdelcerro | this.pickerPrecision.setEditable(false); |
2076 | 44669 | jjdelcerro | this.pickerScale.setEditable(false); |
2077 | 44505 | jjdelcerro | this.pickerSize.setEditable(false); |
2078 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEditable(false); |
2079 | 44505 | jjdelcerro | this.cboFieldType.setEnabled(false); |
2080 | 46676 | jjdelcerro | this.btnFieldType.setEnabled(false); |
2081 | 44505 | jjdelcerro | this.cboGeometryType.setEnabled(false); |
2082 | this.cboGeometrySubtype.setEnabled(false); |
||
2083 | this.pickerCRS.setEditable(false); |
||
2084 | } |
||
2085 | |||
2086 | 46878 | jjdelcerro | this.pickerLocale.setEnabled(true); |
2087 | 45072 | omartinez | this.txtDefaultValue.setEditable(true); |
2088 | 46950 | jjdelcerro | this.chkDefaultValue.setEnabled(this.txtDefaultValue.isEditable()); |
2089 | 45994 | omartinez | this.txtDefaultFormat.setEditable(true); |
2090 | 44505 | jjdelcerro | this.pickerIntervalEnd.setEditable(true); |
2091 | this.pickerIntervalStart.setEditable(true); |
||
2092 | |||
2093 | this.cboDataProfile.setEnabled(true); |
||
2094 | |||
2095 | 44947 | jjdelcerro | this.pickerDisplaySize.setEditable(false); |
2096 | 44505 | jjdelcerro | this.chkAllowNulls.setEnabled(false); |
2097 | this.chkIsAutomatic.setEnabled(false); |
||
2098 | 45920 | jjdelcerro | this.chkIsReadOnly.setEnabled(false); |
2099 | this.chkIsIndexed.setEnabled(false); |
||
2100 | 46872 | jjdelcerro | // if( this.isVirtualField() ) {
|
2101 | 44505 | jjdelcerro | this.chkIsPrimaryKey.setEnabled(false); |
2102 | 46872 | jjdelcerro | // } else {
|
2103 | // this.chkIsPrimaryKey.setEnabled(true);
|
||
2104 | // }
|
||
2105 | 44505 | jjdelcerro | |
2106 | this.chkVirtualField.setEnabled(false); |
||
2107 | |||
2108 | this.cboDateFormat.setEnabled(true); |
||
2109 | |||
2110 | this.cboGroup.setEnabled(true); |
||
2111 | this.pickerOrder.setEditable(true); |
||
2112 | this.chkHidden.setEnabled(true); |
||
2113 | this.txtLabel.setEditable(true); |
||
2114 | this.txtDescription.setEditable(true); |
||
2115 | this.txtMinValue.setEditable(false); |
||
2116 | this.txtMaxValue.setEditable(false); |
||
2117 | 45739 | jjdelcerro | this.pickerValuesFilter.setEditable(true); |
2118 | 44505 | jjdelcerro | this.availableValuesController.setEditable(true); |
2119 | 45873 | jjdelcerro | this.tagsController.setEnabled(true); |
2120 | 44505 | jjdelcerro | break;
|
2121 | case MODE_SHOW_ONLY:
|
||
2122 | 45072 | omartinez | this.txtDefaultValue.setEditable(false); |
2123 | 46950 | jjdelcerro | this.chkDefaultValue.setEnabled(this.txtDefaultValue.isEditable()); |
2124 | 45994 | omartinez | this.txtDefaultFormat.setEditable(false); |
2125 | 44505 | jjdelcerro | this.txtFieldName.setEditable(false); |
2126 | this.pickerIntervalEnd.setEditable(false); |
||
2127 | this.pickerIntervalStart.setEditable(false); |
||
2128 | 44673 | jjdelcerro | this.pickerPrecision.setEditable(false); |
2129 | 44669 | jjdelcerro | this.pickerScale.setEditable(false); |
2130 | 44505 | jjdelcerro | this.pickerSize.setEditable(false); |
2131 | 44947 | jjdelcerro | this.pickerDisplaySize.setEditable(false); |
2132 | 44505 | jjdelcerro | this.cboDataProfile.setEnabled(false); |
2133 | 46878 | jjdelcerro | this.pickerLocale.setEnabled(false); |
2134 | 44505 | jjdelcerro | |
2135 | this.chkAllowNulls.setEnabled(false); |
||
2136 | this.chkIsAutomatic.setEnabled(false); |
||
2137 | 45920 | jjdelcerro | this.chkIsReadOnly.setEnabled(false); |
2138 | this.chkIsIndexed.setEnabled(false); |
||
2139 | 44505 | jjdelcerro | this.chkIsPrimaryKey.setEnabled(false); |
2140 | |||
2141 | this.chkVirtualField.setEnabled(false); |
||
2142 | 46737 | jjdelcerro | this.pickerVirtualFieldGetter.setEditable(false); |
2143 | 44505 | jjdelcerro | |
2144 | this.cboDateFormat.setEnabled(false); |
||
2145 | this.cboFieldType.setEnabled(false); |
||
2146 | 46676 | jjdelcerro | this.btnFieldType.setEnabled(false); |
2147 | 44505 | jjdelcerro | this.cboGeometryType.setEnabled(false); |
2148 | this.cboGeometrySubtype.setEnabled(false); |
||
2149 | this.pickerCRS.setEditable(false); |
||
2150 | |||
2151 | this.cboGroup.setEnabled(false); |
||
2152 | this.pickerOrder.setEditable(false); |
||
2153 | this.chkHidden.setEnabled(false); |
||
2154 | this.txtLabel.setEditable(false); |
||
2155 | this.txtDescription.setEditable(false); |
||
2156 | this.txtMinValue.setEditable(false); |
||
2157 | this.txtMaxValue.setEditable(false); |
||
2158 | 45739 | jjdelcerro | this.pickerValuesFilter.setEditable(false); |
2159 | 44505 | jjdelcerro | this.availableValuesController.setEditable(false); |
2160 | 45873 | jjdelcerro | this.tagsController.setEnabled(false); |
2161 | 44505 | jjdelcerro | break;
|
2162 | 46978 | fdiaz | case MODE_VIRTUAL_FIELD:
|
2163 | this.txtDefaultValue.setEditable(!this.chkIsAutomatic.isSelected()); |
||
2164 | this.chkDefaultValue.setEnabled(this.txtDefaultValue.isEditable()); |
||
2165 | this.txtDefaultFormat.setEditable(true); |
||
2166 | this.txtFieldName.setEditable(true); |
||
2167 | this.pickerIntervalEnd.setEditable(true); |
||
2168 | this.pickerIntervalStart.setEditable(true); |
||
2169 | this.pickerSize.setEditable(dataType.supportSize());
|
||
2170 | this.pickerDisplaySize.setEditable(true); |
||
2171 | if( dataType.isPredefinedPrecision() ) {
|
||
2172 | this.pickerPrecision.setEditable(false); |
||
2173 | this.pickerPrecision.set(dataType.getMaxPrecision());
|
||
2174 | } else {
|
||
2175 | this.pickerPrecision.setEditable(dataType.supportPrecision());
|
||
2176 | } |
||
2177 | this.pickerScale.setEditable(dataType.supportScale());
|
||
2178 | this.cboDataProfile.setEnabled(true); |
||
2179 | |||
2180 | this.chkAllowNulls.setEnabled(true); |
||
2181 | this.chkIsAutomatic.setEnabled(true); |
||
2182 | this.chkIsReadOnly.setEnabled(true); |
||
2183 | this.chkIsIndexed.setEnabled(true); |
||
2184 | if( this.isVirtualField() ) { |
||
2185 | this.chkIsPrimaryKey.setEnabled(false); |
||
2186 | } else {
|
||
2187 | this.chkIsPrimaryKey.setEnabled(true); |
||
2188 | } |
||
2189 | |||
2190 | this.chkVirtualField.setEnabled(false); |
||
2191 | this.chkVirtualField.setSelected(true); |
||
2192 | this.pickerVirtualFieldGetter.setEditable(true); |
||
2193 | |||
2194 | this.cboDateFormat.setEnabled(true); |
||
2195 | this.cboFieldType.setEnabled(!this.chkIsAutomatic.isSelected()); |
||
2196 | this.btnFieldType.setEnabled(!this.chkIsAutomatic.isSelected()); |
||
2197 | this.cboGeometryType.setEnabled(true); |
||
2198 | this.cboGeometrySubtype.setEnabled(true); |
||
2199 | this.pickerCRS.setEditable(true); |
||
2200 | |||
2201 | this.cboGroup.setEnabled(true); |
||
2202 | this.pickerOrder.setEditable(true); |
||
2203 | this.chkHidden.setEnabled(true); |
||
2204 | this.txtLabel.setEditable(true); |
||
2205 | this.txtDescription.setEditable(true); |
||
2206 | this.txtMinValue.setEditable(false); |
||
2207 | this.txtMaxValue.setEditable(false); |
||
2208 | this.pickerValuesFilter.setEditable(true); |
||
2209 | this.availableValuesController.setEditable(true); |
||
2210 | this.tagsController.setEnabled(true); |
||
2211 | this.pickerLocale.setEnabled(true); |
||
2212 | break;
|
||
2213 | 44505 | jjdelcerro | } |
2214 | 46893 | fdiaz | this.txtDisplaySize.setBackground(UIManager.getColor(ToolsSwingManager.COLOR_TEXTFIELD_BACKGROUND)); |
2215 | if(this.pickerPrecision.get() != null && this.pickerDisplaySize.get() != null){ |
||
2216 | if(this.pickerPrecision.get() > this.pickerDisplaySize.get()){ |
||
2217 | this.txtDisplaySize.setBackground(ToolsSwingLocator.getToolsSwingManager().getWarningBackgroundColor());
|
||
2218 | } |
||
2219 | } |
||
2220 | 47281 | fdiaz | doChangeRelationType(); |
2221 | 44085 | jjdelcerro | } |
2222 | 46850 | jjdelcerro | |
2223 | 44669 | jjdelcerro | private void doCheckPrecisionAndScale() { |
2224 | 44673 | jjdelcerro | DataType dataType = this.getDataType();
|
2225 | |||
2226 | Integer precision = this.pickerPrecision.get(); |
||
2227 | if( precision==null ) { |
||
2228 | precision = 0;
|
||
2229 | } |
||
2230 | Integer scale = this.pickerScale.get(); |
||
2231 | if( scale == null ) { |
||
2232 | scale = 0;
|
||
2233 | } |
||
2234 | NumberPrecisionAndScale r = dataType.fixPrecisionAndScale(precision, scale); |
||
2235 | if( r.getPrecision()!=precision || r.getScale()!=scale ) {
|
||
2236 | this.pickerPrecision.setWarning(true, "The precision/scale are not valids"); |
||
2237 | this.pickerScale.setWarning(true, "The precision/scale are not valids"); |
||
2238 | } else {
|
||
2239 | this.pickerPrecision.setWarning(false); |
||
2240 | this.pickerScale.setWarning(false); |
||
2241 | } |
||
2242 | 44100 | jjdelcerro | } |
2243 | |||
2244 | 44128 | jjdelcerro | @Override
|
2245 | public void setNameAsNew(FeatureType featureType) { |
||
2246 | 44498 | omartinez | EditableFeatureType cloneFeatureType = featureType.getCopy().getEditable(); |
2247 | EditableFeatureAttributeDescriptor newAttributeDescriptor = cloneFeatureType.add( |
||
2248 | cloneFeatureType.getNewFieldName(), |
||
2249 | 45321 | omartinez | DataTypes.STRING, |
2250 | 50);
|
||
2251 | 44498 | omartinez | this.put(newAttributeDescriptor);
|
2252 | 44128 | jjdelcerro | } |
2253 | |||
2254 | @Override
|
||
2255 | public String getName() { |
||
2256 | return StringUtils.defaultIfBlank(this.txtFieldName.getText(), null); |
||
2257 | } |
||
2258 | 44262 | jjdelcerro | |
2259 | 44740 | jjdelcerro | @Override
|
2260 | public ImageIcon loadImage(String imageName) { |
||
2261 | 46863 | jjdelcerro | return ToolsSwingUtils.loadImage(this, imageName); |
2262 | 44740 | jjdelcerro | } |
2263 | |||
2264 | 44713 | jjdelcerro | public static void selfRegister() { |
2265 | 46863 | jjdelcerro | boolean n = ToolsSwingUtils.registerIcons(
|
2266 | DefaultFeatureAttributeSelectionPanel.class, |
||
2267 | null,
|
||
2268 | LIBRARY_NAME, |
||
2269 | 47426 | jjdelcerro | new String[]{ "picker", "picker-datatype", "picker-datatype"} |
2270 | 46863 | jjdelcerro | ); |
2271 | 44713 | jjdelcerro | } |
2272 | |||
2273 | 44077 | jjdelcerro | } |