gvsig-geoprocess / org.gvsig.sextante / trunk / org.gvsig.sextante.app / org.gvsig.sextante.app.algorithm / org.gvsig.sextante.app.algorithm.convexhull / src / main / java / org / gvsig / sextante / app / algorithm / convexhull / ConvexHullParametersPanel.java @ 60
History | View | Annotate | Download (3.6 KB)
1 |
package org.gvsig.sextante.app.algorithm.convexhull; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.Insets; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.util.ArrayList; |
10 |
import java.util.Iterator; |
11 |
import java.util.List; |
12 |
|
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JComboBox; |
15 |
|
16 |
import org.gvsig.fmap.dal.DALLocator; |
17 |
import org.gvsig.fmap.dal.DataManager; |
18 |
import org.gvsig.fmap.dal.DataStoreParameters; |
19 |
import org.gvsig.fmap.dal.exception.InitializeException; |
20 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
21 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor; |
22 |
|
23 |
import es.unex.sextante.core.GeoAlgorithm; |
24 |
import es.unex.sextante.core.Sextante; |
25 |
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel; |
26 |
|
27 |
/**
|
28 |
* @deprecated
|
29 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
30 |
*/
|
31 |
public class ConvexHullParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener { |
32 |
private static final long serialVersionUID = 1L; |
33 |
private JComboBox combo = null; |
34 |
private JButton button = null; |
35 |
private ArrayList<DataStoreParameters> paramList = new ArrayList<DataStoreParameters>(); |
36 |
|
37 |
public ConvexHullParametersPanel() {
|
38 |
super();
|
39 |
} |
40 |
|
41 |
public void init(GeoAlgorithm algorithm) { |
42 |
initGUI(); |
43 |
} |
44 |
|
45 |
private void initGUI() { |
46 |
GridBagLayout gbl = new GridBagLayout(); |
47 |
this.setLayout(gbl);
|
48 |
|
49 |
GridBagConstraints gbc = new GridBagConstraints(); |
50 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
51 |
gbc.weightx = 1.0;
|
52 |
gbc.gridx = 0;
|
53 |
gbc.gridy = 0;
|
54 |
gbc.insets = new Insets(0, 2, 0, 0); |
55 |
this.add(getCombo(), gbc);
|
56 |
|
57 |
gbc.fill = GridBagConstraints.NONE;
|
58 |
gbc.weightx = 0;
|
59 |
gbc.gridx = 1;
|
60 |
gbc.insets = new Insets(0, 5, 0, 2); |
61 |
this.add(getButton(), gbc);
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* Gets a ComboBox
|
66 |
* @return
|
67 |
*/
|
68 |
public JComboBox getCombo() { |
69 |
if(combo == null) { |
70 |
combo = new JComboBox(); |
71 |
loadProviderList(combo, paramList); |
72 |
combo.addActionListener(this);
|
73 |
combo.setPreferredSize(new Dimension(0, 18)); |
74 |
} |
75 |
return combo;
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Gets a JButton
|
80 |
* @return
|
81 |
*/
|
82 |
public JButton getButton() { |
83 |
if(button == null) { |
84 |
button = new JButton("..."); |
85 |
button.setPreferredSize(new Dimension(60, 18)); |
86 |
button.addActionListener(this);
|
87 |
} |
88 |
return button;
|
89 |
} |
90 |
|
91 |
@Override
|
92 |
public boolean assignParameters() { |
93 |
return false; |
94 |
} |
95 |
|
96 |
@Override
|
97 |
public void setOutputValue(String arg0, String arg1) { |
98 |
|
99 |
} |
100 |
|
101 |
@Override
|
102 |
public void setParameterValue(String arg0, String arg1) { |
103 |
|
104 |
} |
105 |
|
106 |
@SuppressWarnings("unchecked") |
107 |
private void loadProviderList(JComboBox c, ArrayList<DataStoreParameters> paramList) { |
108 |
try {
|
109 |
DataManager manager = DALLocator.getDataManager(); |
110 |
List list = manager.getStoreProviders();
|
111 |
Iterator it = list.iterator();
|
112 |
c.removeAllItems(); |
113 |
paramList.clear(); |
114 |
while(it.hasNext()) {
|
115 |
try {
|
116 |
String provider = it.next().toString();
|
117 |
DataStoreParameters param = manager.createStoreParameters(provider); |
118 |
c.addItem(provider); |
119 |
paramList.add(param); |
120 |
} catch (InitializeException e1) {
|
121 |
Sextante.addErrorToLog(e1); |
122 |
} catch (ProviderNotRegisteredException e1) {
|
123 |
Sextante.addErrorToLog(e1); |
124 |
} |
125 |
} |
126 |
}catch(Exception e){} |
127 |
} |
128 |
|
129 |
public void actionPerformed(ActionEvent e) { |
130 |
if(e.getSource() == getButton()) {
|
131 |
int index = getCombo().getSelectedIndex();
|
132 |
|
133 |
DynObjectEditor editor = new DynObjectEditor(paramList.get(index),
|
134 |
DynObjectEditor.SHOW_ALL, null, true, false); |
135 |
editor.editObject(true);
|
136 |
} |
137 |
|
138 |
if(e.getSource() == getCombo()) {
|
139 |
|
140 |
} |
141 |
} |
142 |
} |