svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.newlayer / org.gvsig.newlayer.prov / org.gvsig.newlayer.prov.generic / src / main / java / org / gvsig / newlayer / prov / generic / panels / ExplorerParamsPanel.java @ 40560
History | View | Annotate | Download (3.42 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 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, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.newlayer.prov.generic.panels; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
|
28 |
import javax.swing.JScrollPane; |
29 |
|
30 |
import org.gvsig.fmap.dal.exception.InitializeException; |
31 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
32 |
import org.gvsig.i18n.Messages; |
33 |
import org.gvsig.newlayer.NewLayerProvider; |
34 |
import org.gvsig.newlayer.prov.generic.NewLayerGenericProviderPanel; |
35 |
import org.gvsig.tools.dynobject.DynObject; |
36 |
import org.gvsig.tools.dynobject.exception.DynObjectValidateException; |
37 |
import org.gvsig.tools.service.ServiceException; |
38 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
39 |
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager; |
40 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
41 |
|
42 |
public class ExplorerParamsPanel extends NewLayerGenericProviderPanel { |
43 |
|
44 |
/**
|
45 |
*
|
46 |
*/
|
47 |
private static final long serialVersionUID = 4479935798588252685L; |
48 |
|
49 |
private static final DynObjectSwingManager DYN_OBJECT_SWING_MANAGER = ToolsSwingLocator |
50 |
.getDynObjectSwingManager(); |
51 |
|
52 |
private JDynObjectComponent dynObjectComponent = null; |
53 |
private String explorerName = null; |
54 |
|
55 |
public ExplorerParamsPanel(NewLayerProvider provider) {
|
56 |
super(provider);
|
57 |
} |
58 |
|
59 |
private void initializeComponents() { |
60 |
explorerName = this.getProvider().getExplorerName();
|
61 |
this.setLayout(new BorderLayout()); |
62 |
try {
|
63 |
this.removeAll();
|
64 |
dynObjectComponent = DYN_OBJECT_SWING_MANAGER |
65 |
.createJDynObjectComponent( |
66 |
getProvider().getExplorerParameters(), |
67 |
true);
|
68 |
} catch (ServiceException e) {
|
69 |
// TODO Auto-generated catch block
|
70 |
e.printStackTrace(); |
71 |
} catch (InitializeException e) {
|
72 |
// TODO Auto-generated catch block
|
73 |
e.printStackTrace(); |
74 |
} catch (ProviderNotRegisteredException e) {
|
75 |
// TODO Auto-generated catch block
|
76 |
e.printStackTrace(); |
77 |
} |
78 |
|
79 |
this.add(dynObjectComponent.asJComponent(), BorderLayout.CENTER); |
80 |
|
81 |
} |
82 |
|
83 |
@Override
|
84 |
public String getTitle() { |
85 |
return Messages.getText("select_dataexplorer_parameters"); |
86 |
} |
87 |
|
88 |
@Override
|
89 |
public boolean isValidPanel() { |
90 |
if (dynObjectComponent == null){ |
91 |
return false; |
92 |
} |
93 |
dynObjectComponent.saveStatus(); |
94 |
DynObject dynObject = this.dynObjectComponent.getDynObject();
|
95 |
try {
|
96 |
dynObject.getDynClass().validate(dynObject); |
97 |
} catch (DynObjectValidateException e) {
|
98 |
return false; |
99 |
} |
100 |
this.getProvider().createExplorer();
|
101 |
return true; |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public void updatePanel() { |
106 |
if (explorerName != null && this.getProvider().getExplorerName().equalsIgnoreCase(explorerName)){ |
107 |
return;
|
108 |
} |
109 |
initializeComponents(); |
110 |
repaint(); |
111 |
} |
112 |
|
113 |
} |