gvsig-catalog / org.gvsig.catalog / branches / org.gvsig.catalog-CSW2.0.2 / org.gvsig.catalog / org.gvsig.catalog.extension / src / main / java / org / gvsig / catalog / gui / LoaderWizardPanel.java @ 64
History | View | Annotate | Download (4.12 KB)
1 |
package org.gvsig.catalog.gui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
|
7 |
import javax.swing.JButton; |
8 |
import javax.swing.JComponent; |
9 |
import javax.swing.JOptionPane; |
10 |
import javax.swing.event.ListSelectionEvent; |
11 |
import javax.swing.event.ListSelectionListener; |
12 |
|
13 |
import org.apache.commons.lang3.StringUtils; |
14 |
import org.gvsig.app.gui.WizardPanel; |
15 |
import org.gvsig.app.gui.wizards.WizardListener; |
16 |
import org.gvsig.catalog.loaders.WCSLayerLoader; |
17 |
import org.gvsig.fmap.dal.DataStoreParameters; |
18 |
import org.gvsig.i18n.Messages; |
19 |
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel; |
20 |
import org.slf4j.Logger; |
21 |
import org.slf4j.LoggerFactory; |
22 |
|
23 |
public class LoaderWizardPanel implements WizardListener, ListSelectionListener{ |
24 |
|
25 |
private Logger logger = LoggerFactory.getLogger(LoaderWizardPanel.class); |
26 |
|
27 |
private WizardPanel wizardPanel;
|
28 |
private JButton OKButton; |
29 |
private JButton CancelButton; |
30 |
private DataStoreParameters dataStoreParameters;
|
31 |
|
32 |
public LoaderWizardPanel(WizardPanel panel){
|
33 |
this(panel, null); |
34 |
} |
35 |
|
36 |
public LoaderWizardPanel(WizardPanel panel, DataStoreParameters dataStoreParameters){
|
37 |
this.dataStoreParameters = dataStoreParameters;
|
38 |
|
39 |
this.wizardPanel = panel;
|
40 |
this.wizardPanel.setVisible(true); |
41 |
this.wizardPanel.setPreferredSize(new Dimension(510, 427)); |
42 |
|
43 |
this.wizardPanel.addWizardListener(this); |
44 |
((WCSParamsPanel)this.wizardPanel).getFormatsPanel().getLstCRSs().addListSelectionListener(this); |
45 |
((WCSParamsPanel)this.wizardPanel).getFormatsPanel().getLstFormats().addListSelectionListener(this); |
46 |
|
47 |
// if(this.dataStoreParameters != null &&
|
48 |
// this.wizardPanel instanceof WCSParamsPanel){
|
49 |
// //((WCSParamsPanel)this.wizardPanel).refreshData((WCSDataParametersImpl) this.dataStoreParameters);
|
50 |
// }
|
51 |
|
52 |
this.OKButton = new JButton(Messages.getText("Connect")); |
53 |
this.OKButton.addActionListener(new ActionListener() { |
54 |
public void actionPerformed(ActionEvent e) { |
55 |
JOptionPane pane = getOptionPane((JComponent)e.getSource()); |
56 |
pane.setValue(OKButton); |
57 |
} |
58 |
}); |
59 |
this.OKButton.setEnabled(false); |
60 |
|
61 |
this.CancelButton = new JButton(Messages.getText("Cancel")); |
62 |
this.CancelButton.addActionListener(new ActionListener() { |
63 |
public void actionPerformed(ActionEvent e) { |
64 |
JOptionPane pane = getOptionPane((JComponent)e.getSource()); |
65 |
pane.setValue(CancelButton); |
66 |
} |
67 |
}); |
68 |
} |
69 |
|
70 |
|
71 |
protected JOptionPane getOptionPane(JComponent parent) { |
72 |
JOptionPane pane = null; |
73 |
if (!(parent instanceof JOptionPane)) { |
74 |
pane = getOptionPane((JComponent)parent.getParent());
|
75 |
} else {
|
76 |
pane = (JOptionPane) parent;
|
77 |
} |
78 |
return pane;
|
79 |
} |
80 |
|
81 |
public void wizardStateChanged(boolean finishable) { |
82 |
logger.debug("Thing happened!");
|
83 |
} |
84 |
|
85 |
public WizardPanel getWizardPanel(){
|
86 |
return this.wizardPanel; |
87 |
} |
88 |
|
89 |
|
90 |
public void error(Exception e) { |
91 |
// TODO Auto-generated method stub
|
92 |
|
93 |
} |
94 |
|
95 |
public boolean showWizardOnDialog() { |
96 |
|
97 |
int option = JOptionPane. |
98 |
showOptionDialog(null, this.wizardPanel, Messages.getText("WCS_Parameters"), |
99 |
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, |
100 |
null, new JButton[]{this.CancelButton, this.OKButton}, this.OKButton); |
101 |
if(option==1){ |
102 |
WCSParamsPanel wcsParamsPanel = (WCSParamsPanel)this.wizardPanel;
|
103 |
dataStoreParameters.setDynValue(WCSLayerLoader.FIELD_SRSSTR, wcsParamsPanel.getSRS()); |
104 |
dataStoreParameters.setDynValue(WCSLayerLoader.FIELD_FORMAT, wcsParamsPanel.getFormat()); |
105 |
// dataStoreParameters.setDynValue(WCSLayerLoader.FIELD_WIDTH, nameValue[1]);
|
106 |
// dataStoreParameters.setDynValue(WCSLayerLoader.FIELD_HEIGHT, nameValue[1]);
|
107 |
dataStoreParameters.setDynValue(WCSLayerLoader.FIELD_PARAM, wcsParamsPanel.getParameterPanel().getParameterString()); |
108 |
return true; |
109 |
} |
110 |
return false; |
111 |
} |
112 |
|
113 |
public void valueChanged(ListSelectionEvent e) { |
114 |
logger.debug("Thing happened!");
|
115 |
WCSParamsPanel wcsParamsPanel = (WCSParamsPanel)this.wizardPanel;
|
116 |
if(!StringUtils.isBlank(wcsParamsPanel.getSRS()) && !StringUtils.isBlank(wcsParamsPanel.getFormat())){
|
117 |
this.OKButton.setEnabled(true); |
118 |
} |
119 |
} |
120 |
|
121 |
} |