Revision 35 org.gvsig.sextante/trunk/org.gvsig.sextante.app/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.base/src/main/java/org/gvsig/sextante/app/algorithm/base/panel/AlgorithmOutputPanel.java
AlgorithmOutputPanel.java | ||
---|---|---|
16 | 16 |
|
17 | 17 |
import org.gvsig.fmap.dal.DALLocator; |
18 | 18 |
import org.gvsig.fmap.dal.DataManager; |
19 |
import org.gvsig.fmap.dal.DataParameters; |
|
19 | 20 |
import org.gvsig.fmap.dal.DataServerExplorer; |
20 | 21 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
21 | 22 |
import org.gvsig.fmap.dal.DataStoreParameters; |
23 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
24 |
import org.gvsig.fmap.dal.exception.DataException; |
|
22 | 25 |
import org.gvsig.fmap.dal.exception.InitializeException; |
23 | 26 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
24 | 27 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
28 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
25 | 29 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor; |
26 | 30 |
import org.gvsig.sextante.app.extension.core.OutputParameters; |
27 |
import org.gvsig.tools.dynobject.DynObject; |
|
28 | 31 |
|
29 | 32 |
import es.unex.sextante.core.GeoAlgorithm; |
30 | 33 |
import es.unex.sextante.core.Sextante; |
... | ... | |
40 | 43 |
private JComboBox cProvider = null; |
41 | 44 |
private JComboBox cExplorer = null; |
42 | 45 |
private JButton button = null; |
43 |
private ArrayList<DataStoreParameters> listProvider = new ArrayList<DataStoreParameters>(); |
|
44 | 46 |
private ArrayList<DataServerExplorer> listExplorer = new ArrayList<DataServerExplorer>(); |
45 | 47 |
private DynObjectEditor editor = null; |
46 | 48 |
|
47 | 49 |
public AlgorithmOutputPanel() { |
48 | 50 |
super(); |
49 | 51 |
initGUI(); |
50 |
loadProviderList(getCProvider(), listProvider);
|
|
51 |
loadExplorerList(getCExplorer(), listExplorer);
|
|
52 |
loadProviderList(getCProvider()); |
|
53 |
loadExplorerList(getCExplorer()); |
|
52 | 54 |
} |
53 | 55 |
|
54 | 56 |
public void init(GeoAlgorithm algorithm) { |
... | ... | |
66 | 68 |
gbc.gridx = 0; |
67 | 69 |
gbc.gridy = 0; |
68 | 70 |
gbc.insets = new Insets(0, 2, 0, 0); |
69 |
this.add(getCProvider(), gbc);
|
|
71 |
this.add(getCExplorer(), gbc);
|
|
70 | 72 |
|
71 | 73 |
gbc.gridx = 1; |
72 |
this.add(getCExplorer(), gbc);
|
|
74 |
this.add(getCProvider(), gbc);
|
|
73 | 75 |
|
74 | 76 |
gbc.fill = GridBagConstraints.NONE; |
75 | 77 |
gbc.weightx = 0; |
... | ... | |
117 | 119 |
return button; |
118 | 120 |
} |
119 | 121 |
|
122 |
/** |
|
123 |
* Loads the list of providers |
|
124 |
* @param cProvider |
|
125 |
* @param listDSParam |
|
126 |
*/ |
|
120 | 127 |
@SuppressWarnings("unchecked") |
121 |
private void loadProviderList(JComboBox cProvider, ArrayList<DataStoreParameters> listDSParam) {
|
|
128 |
private void loadProviderList(JComboBox cProvider) { |
|
122 | 129 |
DataManager manager = DALLocator.getDataManager(); |
123 | 130 |
|
124 | 131 |
List lProvider = manager.getStoreProviders(); |
125 | 132 |
Iterator it = lProvider.iterator(); |
126 | 133 |
cProvider.removeAllItems(); |
127 |
listDSParam.clear(); |
|
128 | 134 |
while(it.hasNext()) { |
129 |
try { |
|
130 |
String provider = it.next().toString(); |
|
131 |
cProvider.addItem(provider); |
|
132 |
DataStoreParameters param = manager.createStoreParameters(provider); |
|
133 |
listDSParam.add(param); |
|
134 |
} catch (InitializeException e1) { |
|
135 |
Sextante.addErrorToLog(e1); |
|
136 |
} catch (ProviderNotRegisteredException e1) { |
|
137 |
Sextante.addErrorToLog(e1); |
|
138 |
} |
|
135 |
String provider = it.next().toString(); |
|
136 |
cProvider.addItem(provider); |
|
139 | 137 |
} |
140 | 138 |
} |
141 |
|
|
142 |
private void loadExplorerList(JComboBox cExplorer, ArrayList<DataServerExplorer> listDSExplorer) { |
|
143 |
loadDataServerExplorerListFromProvider((String)getCProvider().getSelectedItem()); |
|
144 |
|
|
145 |
getCExplorer().removeAllItems(); |
|
146 |
for (int i = 0; i < listExplorer.size(); i++) |
|
147 |
getCExplorer().addItem(listExplorer.get(i).getName()); |
|
148 |
} |
|
149 | 139 |
|
150 | 140 |
@SuppressWarnings("unchecked") |
151 |
private void loadDataServerExplorerListFromProvider(String provLabel) {
|
|
141 |
private void loadExplorerList(JComboBox cExplorer) {
|
|
152 | 142 |
DataManager manager = DALLocator.getDataManager(); |
153 | 143 |
List lExplorer = manager.getExplorerProviders(); |
154 | 144 |
|
155 | 145 |
Iterator it = lExplorer.iterator(); |
156 | 146 |
listExplorer.clear(); |
157 |
|
|
147 |
cExplorer.removeAllItems(); |
|
148 |
|
|
158 | 149 |
while(it.hasNext()) { |
159 | 150 |
String explorer = (String)it.next(); |
160 |
|
|
161 |
DataServerExplorerParameters param; |
|
162 | 151 |
try { |
163 |
param = manager.createServerExplorerParameters(explorer); |
|
164 |
DataServerExplorer dsExplorer = manager.createServerExplorer(param); |
|
165 |
if(dsExplorer.getAddParameters(provLabel) != null) { |
|
166 |
listExplorer.add(dsExplorer); |
|
167 |
} |
|
168 |
} catch (Exception e) { |
|
169 |
continue; |
|
170 |
} |
|
152 |
DataServerExplorerParameters params = manager.createServerExplorerParameters(explorer); |
|
153 |
listExplorer.add(manager.createServerExplorer(params)); |
|
154 |
cExplorer.addItem(explorer); |
|
155 |
} catch (ValidateDataParametersException e) { |
|
156 |
Sextante.addErrorToLog(e); |
|
157 |
} catch (InitializeException e) { |
|
158 |
Sextante.addErrorToLog(e); |
|
159 |
} catch (ProviderNotRegisteredException e) { |
|
160 |
Sextante.addErrorToLog(e); |
|
161 |
} |
|
171 | 162 |
} |
172 | 163 |
} |
173 | 164 |
|
174 | 165 |
public void actionPerformed(ActionEvent e) { |
175 | 166 |
if(e.getSource() == getButton()) { |
176 |
int index = getCProvider().getSelectedIndex();
|
|
167 |
int indexExplorer = getCExplorer().getSelectedIndex();
|
|
177 | 168 |
|
178 |
editor = new DynObjectEditor(listProvider.get(index), |
|
179 |
DynObjectEditor.SHOW_ALL, null, true, false); |
|
180 |
editor.editObject(true); |
|
169 |
DataServerExplorer explorer = listExplorer.get(indexExplorer); |
|
170 |
NewDataStoreParameters params; |
|
171 |
try { |
|
172 |
params = explorer.getAddParameters((String)getCProvider().getSelectedItem()); |
|
173 |
editor = new DynObjectEditor(params, |
|
174 |
DynObjectEditor.SHOW_ALL, null, true, false); |
|
175 |
editor.editObject(true); |
|
176 |
} catch (DataException e1) { |
|
177 |
Sextante.addErrorToLog(e1); |
|
178 |
} |
|
181 | 179 |
} |
182 | 180 |
|
183 | 181 |
if(e.getSource() == getCProvider()) { |
184 |
loadExplorerList(getCExplorer(), listExplorer); |
|
185 | 182 |
} |
183 |
|
|
186 | 184 |
if(e.getSource() == getCExplorer()) { |
187 |
loadExplorerList(getCExplorer(), listExplorer); |
|
188 | 185 |
} |
189 | 186 |
} |
190 | 187 |
|
... | ... | |
192 | 189 |
public Object getOutputParameters() { |
193 | 190 |
it++; |
194 | 191 |
return "/tmp/prueba" + it; |
195 |
/*if(editor.getParameters() instanceof DataServerExplorerParameters) { |
|
196 |
DataManager datamanager = DALLocator.getDataManager(); |
|
197 |
DataServerExplorer explorer = null; |
|
198 |
try { |
|
199 |
explorer = datamanager.createServerExplorer((DataServerExplorerParameters)editor.getParameters()); |
|
200 |
} catch (ValidateDataParametersException e) { |
|
201 |
Sextante.addErrorToLog(e); |
|
202 |
} catch (InitializeException e) { |
|
203 |
Sextante.addErrorToLog(e); |
|
204 |
} catch (ProviderNotRegisteredException e) { |
|
205 |
Sextante.addErrorToLog(e); |
|
206 |
} |
|
207 |
return new OutputParameters((String)getCProvider().getSelectedItem(), explorer); |
|
192 |
/*if(editor.getParameters() instanceof NewFeatureStoreParameters) { |
|
193 |
int index = getCExplorer().getSelectedIndex(); |
|
194 |
return new OutputParameters((NewFeatureStoreParameters)editor.getParameters(), listExplorer.get(index)); |
|
208 | 195 |
} |
209 | 196 |
return null;*/ |
210 | 197 |
} |
Also available in: Unified diff