Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.algorithm / org.gvsig.geoprocess.algorithm.convexhull / src / main / java / org / gvsig / geoprocess / algorithm / convexhull / ConvexHullParametersPanel.java @ 245

History | View | Annotate | Download (5 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2012 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 2
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.geoprocess.algorithm.convexhull;
25

    
26
import java.awt.Dimension;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionListener;
32
import java.util.ArrayList;
33
import java.util.Iterator;
34
import java.util.List;
35

    
36
import javax.swing.JButton;
37
import javax.swing.JComboBox;
38

    
39
import es.unex.sextante.core.GeoAlgorithm;
40
import es.unex.sextante.core.Sextante;
41
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
42

    
43
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
45

    
46
import org.gvsig.fmap.dal.DALLocator;
47
import org.gvsig.fmap.dal.DataManager;
48
import org.gvsig.fmap.dal.DataStoreParameters;
49
import org.gvsig.fmap.dal.exception.InitializeException;
50
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
51
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor;
52
import org.gvsig.tools.service.ServiceException;
53

    
54
/**
55
 * @deprecated
56
 * @author Nacho Brodin (nachobrodin@gmail.com)
57
 */
58
public class ConvexHullParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener {
59

    
60
    private static final long serialVersionUID = 3260891769310434508L;
61

    
62
    private static final Logger LOG =
63
        LoggerFactory.getLogger(ConvexHullParametersPanel.class);
64
    
65
        private JComboBox                        combo               = null;
66
        private JButton                          button              = null;
67
        private ArrayList<DataStoreParameters>   paramList           = new ArrayList<DataStoreParameters>();
68
        
69
        public ConvexHullParametersPanel() {
70
                super();
71
        }
72

    
73
    public void init(GeoAlgorithm algorithm) {
74
            initGUI();
75
    }
76

    
77
        private void initGUI() {
78
                GridBagLayout gbl = new GridBagLayout();
79
                this.setLayout(gbl);
80
                
81
                GridBagConstraints gbc = new GridBagConstraints();
82
                gbc.fill = GridBagConstraints.HORIZONTAL;
83
                gbc.weightx = 1.0;
84
                gbc.gridx = 0;
85
                gbc.gridy = 0;
86
                gbc.insets = new Insets(0, 2, 0, 0);
87
                this.add(getCombo(), gbc);
88
                
89
                gbc.fill = GridBagConstraints.NONE;
90
                gbc.weightx = 0;
91
                gbc.gridx = 1;
92
                gbc.insets = new Insets(0, 5, 0, 2);
93
                this.add(getButton(), gbc);
94
        }
95

    
96
        /**
97
         * Gets a ComboBox
98
         * @return
99
         */
100
        public JComboBox getCombo() {
101
                if(combo == null) {
102
                        combo = new JComboBox();
103
                        loadProviderList(combo, paramList);
104
                        combo.addActionListener(this);
105
                        combo.setPreferredSize(new Dimension(0, 18));
106
                }
107
                return combo;
108
        }
109
        
110
        /**
111
         * Gets a JButton
112
         * @return
113
         */
114
        public JButton getButton() {
115
                if(button == null) {
116
                        button = new JButton("...");
117
                        button.setPreferredSize(new Dimension(60, 18));
118
                        button.addActionListener(this);
119
                }
120
                return button;
121
        }
122
        
123
        @Override
124
    public void assignParameters() {
125
        // Nothing to do
126
        }
127

    
128
        @Override
129
        public void setOutputValue(String arg0, String arg1) {
130
                
131
        }
132

    
133
        @Override
134
        public void setParameterValue(String arg0, String arg1) {
135
                
136
        }
137
        
138
        @SuppressWarnings("unchecked")
139
        private void loadProviderList(JComboBox c, ArrayList<DataStoreParameters> paramList) {
140
                try {
141
                DataManager manager = DALLocator.getDataManager();
142
                List list = manager.getStoreProviders();
143
                Iterator it = list.iterator();
144
                c.removeAllItems();
145
                paramList.clear();
146
                while(it.hasNext()) {
147
                        try {
148
                                String provider = it.next().toString();
149
                                DataStoreParameters param = manager.createStoreParameters(provider);
150
                                c.addItem(provider);
151
                                paramList.add(param);
152
                        } catch (InitializeException e1) {
153
                                Sextante.addErrorToLog(e1);
154
                        } catch (ProviderNotRegisteredException e1) {
155
                                Sextante.addErrorToLog(e1);
156
                        }
157
                }
158
                }catch(Exception e){}
159
        }
160

    
161
        public void actionPerformed(ActionEvent e) {
162
                if(e.getSource() == getButton()) {
163
                        int index = getCombo().getSelectedIndex();
164
                        
165
            try {
166
                DynObjectEditor editor = new DynObjectEditor(paramList.get(index));
167
                editor.editObject(true);
168
            } catch (ServiceException ex) {
169
                LOG.error(
170
                    "Error creating a Swing component for the DynObject: "
171
                        + paramList.get(index), ex);
172
                Sextante.addErrorToLog(ex);
173
            }
174

    
175
                }
176
                
177
                if(e.getSource() == getCombo()) {
178
                        
179
                }
180
        }
181
}