Statistics
| Revision:

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 / StoreParamsPanel.java @ 40560

History | View | Annotate | Download (3 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 org.gvsig.i18n.Messages;
29
import org.gvsig.newlayer.NewLayerProvider;
30
import org.gvsig.newlayer.prov.generic.NewLayerGenericProviderPanel;
31
import org.gvsig.tools.dynobject.DynObject;
32
import org.gvsig.tools.dynobject.exception.DynObjectValidateException;
33
import org.gvsig.tools.service.ServiceException;
34
import org.gvsig.tools.swing.api.ToolsSwingLocator;
35
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager;
36
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent;
37

    
38
public class StoreParamsPanel extends NewLayerGenericProviderPanel{
39

    
40
    /**
41
         * 
42
         */
43
        private static final long serialVersionUID = -3700558197138685488L;
44

    
45
        private static final DynObjectSwingManager  DYN_OBJECT_SWING_MANAGER = 
46
        ToolsSwingLocator.getDynObjectSwingManager();
47

    
48
        private JDynObjectComponent dynObjectComponent = null;
49

    
50
        private String storeName;
51

    
52
        public StoreParamsPanel(NewLayerProvider provider) {
53
                super(provider);
54
        }
55

    
56
        private void initializeComponents() {
57
                this.setLayout(new BorderLayout());
58
                this.storeName = this.getProvider().getStoreName();
59
                
60
                try {
61
                        this.removeAll();
62
                        dynObjectComponent = DYN_OBJECT_SWING_MANAGER
63
                                        .createJDynObjectComponent(getProvider()
64
                                                        .getNewStoreParameters(), true);
65
                } catch (ServiceException e) {
66
                        // TODO Auto-generated catch block
67
                        e.printStackTrace();
68
                }
69

    
70
                this.add(dynObjectComponent.asJComponent(), BorderLayout.CENTER);
71

    
72
        }
73

    
74
        @Override
75
        public String getTitle() {
76
                return Messages.getText("select_datastore_parameters");
77
        }
78

    
79
        @Override
80
        public boolean isValidPanel() {
81
                if (dynObjectComponent == null){
82
                        return false;
83
                }
84
        dynObjectComponent.saveStatus();
85
                DynObject dynObject = this.dynObjectComponent.getDynObject();
86
                try {
87
                        dynObject.getDynClass().validate(dynObject);
88
                } catch (DynObjectValidateException e) {
89
                        return false;
90
                }
91
                return true;
92
        }
93

    
94
        @Override
95
        public void updatePanel() {
96
                if (storeName != null && storeName.equalsIgnoreCase(this.getProvider().getStoreName())){
97
                        return;
98
                }
99
                initializeComponents();
100
        }
101

    
102
}