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