svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.newlayer / org.gvsig.newlayer.lib / org.gvsig.newlayer.lib.impl / src / main / java / org / gvsig / newlayer / impl / panels / FeatureTypePanel.java @ 45739
History | View | Annotate | Download (4.34 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 |
*
|
19 |
* For any additional information, do not hesitate to contact us
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
21 |
*/
|
22 |
|
23 |
package org.gvsig.newlayer.impl.panels; |
24 |
|
25 |
import javax.swing.JComponent; |
26 |
import javax.swing.JOptionPane; |
27 |
import org.gvsig.fmap.dal.DALLocator; |
28 |
import org.gvsig.fmap.dal.DataManager; |
29 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
30 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
31 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
32 |
import static org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel.MODE_EDIT_ALL; |
33 |
import org.gvsig.newlayer.NewLayerProvider; |
34 |
import org.gvsig.newlayer.NewLayerProviderPanel; |
35 |
import org.gvsig.newlayer.NewLayerWizard; |
36 |
import org.gvsig.newlayer.spi.NewLayerPanelValidationException; |
37 |
import org.gvsig.tools.ToolsLocator; |
38 |
import org.gvsig.tools.i18n.I18nManager; |
39 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
40 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
41 |
|
42 |
/**
|
43 |
*
|
44 |
* @author gvSIG Team
|
45 |
*/
|
46 |
public class FeatureTypePanel implements NewLayerProviderPanel { |
47 |
|
48 |
private final NewLayerProvider provider; |
49 |
private final NewLayerWizard wizard; |
50 |
private org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel featureTypeEditor;
|
51 |
|
52 |
public FeatureTypePanel(NewLayerWizard wizard, NewLayerProvider provider) {
|
53 |
this.provider = provider;
|
54 |
this.wizard = wizard;
|
55 |
initComponents(); |
56 |
} |
57 |
|
58 |
private void initComponents() { |
59 |
DataManager dataManager = DALLocator.getDataManager(); |
60 |
DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager(); |
61 |
EditableFeatureType ft = dataManager.createFeatureType(); |
62 |
this.featureTypeEditor = dataSwingManager.createFeatureTypePanel();
|
63 |
this.featureTypeEditor.setMode(MODE_EDIT_ALL);
|
64 |
this.featureTypeEditor.put(ft);
|
65 |
} |
66 |
|
67 |
@Override
|
68 |
public void previousPanel() { |
69 |
EditableFeatureType ft = this.provider.getFeatureType();
|
70 |
this.featureTypeEditor.fetch(ft);
|
71 |
} |
72 |
|
73 |
@Override
|
74 |
public void enterPanel() { |
75 |
EditableFeatureType ft = this.provider.getFeatureType();
|
76 |
if (ft!= null) { |
77 |
this.featureTypeEditor.put(ft);
|
78 |
} |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public String getIdPanel() { |
83 |
return this.getClass().getCanonicalName(); |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public String getTitlePanel() { |
88 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
89 |
return i18n.getTranslation("Columns definition"); |
90 |
} |
91 |
|
92 |
@Override
|
93 |
public void nextPanel() { |
94 |
EditableFeatureType ft = this.provider.getFeatureType();
|
95 |
this.featureTypeEditor.fetch(ft);
|
96 |
} |
97 |
|
98 |
@Override
|
99 |
public boolean validatePanel() throws NewLayerPanelValidationException { |
100 |
try {
|
101 |
if( this.featureTypeEditor.isEditing()) { |
102 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
103 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
104 |
dialogs.messageDialog( |
105 |
i18n.getTranslation("_Accept_o_discard_the_attribute_changes_to_continue"),
|
106 |
i18n.getTranslation("Columns definition"),
|
107 |
JOptionPane.INFORMATION_MESSAGE
|
108 |
); |
109 |
return false; |
110 |
} |
111 |
EditableFeatureType ft = this.provider.getFeatureType();
|
112 |
this.featureTypeEditor.fetch(ft);
|
113 |
if( ft.size()==0 ) { |
114 |
return false; |
115 |
} |
116 |
return true; |
117 |
} catch (Exception ex) { |
118 |
return false; |
119 |
} |
120 |
} |
121 |
|
122 |
@Override
|
123 |
public JComponent asJComponent() { |
124 |
return this.featureTypeEditor.asJComponent(); |
125 |
} |
126 |
|
127 |
} |