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