root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / dialog / ImportNewCrsDialog.java @ 11669
History | View | Annotate | Download (3.55 KB)
1 |
package org.gvsig.crs.gui.dialog; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.CardLayout; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.GridLayout; |
8 |
import java.awt.event.ActionEvent; |
9 |
|
10 |
import javax.swing.JButton; |
11 |
import javax.swing.JPanel; |
12 |
import javax.swing.ListSelectionModel; |
13 |
|
14 |
import org.gvsig.crs.gui.listeners.ImportNewCrsDialogListener; |
15 |
import org.gvsig.crs.gui.panels.EPSGpanel; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.andami.ui.mdiManager.IWindow; |
19 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
20 |
|
21 |
public class ImportNewCrsDialog extends JPanel implements IWindow { |
22 |
|
23 |
final String epsg = PluginServices.getText(this,"EPSG"); |
24 |
private EPSGpanel epsgPanel = null; |
25 |
private int crsCode = -1; |
26 |
|
27 |
private JPanel jPanelMain = null; |
28 |
|
29 |
private JPanel jPanelButtons; |
30 |
private JButton jButtonAccept; |
31 |
private JButton jButonCancel; |
32 |
|
33 |
private String option = ""; |
34 |
|
35 |
public ImportNewCrsDialog(String opt) { |
36 |
epsgPanel = new EPSGpanel();
|
37 |
epsgPanel.connection(); |
38 |
setOption(opt); |
39 |
initialize(); |
40 |
setListeners(); |
41 |
} |
42 |
|
43 |
public void initialize() { |
44 |
this.setBounds(0, 0, 525, 260); |
45 |
this.setLayout(new GridLayout(0,1)); |
46 |
this.add(getJPanelMain(), BorderLayout.CENTER); |
47 |
this.add(getJPanelButtons(), BorderLayout.SOUTH); |
48 |
} |
49 |
|
50 |
public JPanel getJPanelMain(){ |
51 |
if (jPanelMain == null){ |
52 |
jPanelMain = new JPanel(); |
53 |
jPanelMain.setLayout(new CardLayout()); |
54 |
jPanelMain.setPreferredSize(new Dimension(525, 230)); |
55 |
jPanelMain.add(epsg, epsgPanel); |
56 |
} |
57 |
|
58 |
return jPanelMain;
|
59 |
} |
60 |
|
61 |
private JPanel getJPanelButtons() { |
62 |
if(jPanelButtons == null) { |
63 |
jPanelButtons = new JPanel(); |
64 |
jPanelButtons.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
65 |
//jPanelButtons.setPreferredSize(new Dimension(525,50));
|
66 |
jPanelButtons.add(getJButtonCancel(),null);
|
67 |
jPanelButtons.add(getJButtonAccept(),null);
|
68 |
} |
69 |
return jPanelButtons;
|
70 |
} |
71 |
|
72 |
public JButton getJButtonCancel() { |
73 |
if(jButonCancel == null) { |
74 |
jButonCancel = new JButton(); |
75 |
jButonCancel.setText(PluginServices.getText(this,"cancel")); |
76 |
jButonCancel.setPreferredSize(new Dimension(100,25)); |
77 |
jButonCancel.setMnemonic('C');
|
78 |
jButonCancel.setToolTipText("Cancel");
|
79 |
} |
80 |
return jButonCancel;
|
81 |
} |
82 |
|
83 |
public void cancelButton_actionPerformed(ActionEvent e) { |
84 |
PluginServices.getMDIManager().closeWindow(this);
|
85 |
} |
86 |
|
87 |
public JButton getJButtonAccept() { |
88 |
if(jButtonAccept == null) { |
89 |
jButtonAccept = new JButton(); |
90 |
jButtonAccept.setText(PluginServices.getText(this,"ok")); |
91 |
jButtonAccept.setPreferredSize(new Dimension(100,25)); |
92 |
jButtonAccept.setEnabled(false);
|
93 |
jButtonAccept.setMnemonic('A');
|
94 |
jButtonAccept.setToolTipText(PluginServices.getText(this,"ok")); |
95 |
} |
96 |
return jButtonAccept;
|
97 |
} |
98 |
|
99 |
private void setListeners() { |
100 |
ImportNewCrsDialogListener listener = new ImportNewCrsDialogListener(this); |
101 |
|
102 |
getJButtonCancel().addActionListener(listener); |
103 |
getJButtonAccept().addActionListener(listener); |
104 |
|
105 |
ListSelectionModel rowSM = getEpsgPanel().getJTable().getSelectionModel();
|
106 |
rowSM.addListSelectionListener(listener); |
107 |
|
108 |
getEpsgPanel().getJTable().addMouseListener(listener); |
109 |
|
110 |
} |
111 |
|
112 |
public void setOption(String opt){ |
113 |
this.option = opt;
|
114 |
} |
115 |
|
116 |
public String getOption() { |
117 |
return option;
|
118 |
} |
119 |
|
120 |
public EPSGpanel getEpsgPanel() {
|
121 |
return epsgPanel;
|
122 |
} |
123 |
|
124 |
public void setCode(int code) { |
125 |
this.crsCode = code;
|
126 |
} |
127 |
|
128 |
public int getCode() { |
129 |
return this.crsCode; |
130 |
} |
131 |
|
132 |
public WindowInfo getWindowInfo() {
|
133 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
134 |
m_viewinfo.setTitle(PluginServices.getText(this, "Importar")+" "+option); |
135 |
return m_viewinfo;
|
136 |
} |
137 |
|
138 |
} |