gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.swing / org.gvsig.scripting.swing.impl / src / main / java / org / gvsig / scripting / swing / impl / JDialogContent.java @ 457
History | View | Annotate | Download (4.64 KB)
1 |
package org.gvsig.scripting.swing.impl; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.Font; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.ComponentEvent; |
10 |
import java.awt.event.ComponentListener; |
11 |
|
12 |
import javax.swing.BorderFactory; |
13 |
import javax.swing.Box; |
14 |
import javax.swing.BoxLayout; |
15 |
import javax.swing.JButton; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JPanel; |
18 |
|
19 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
20 |
|
21 |
|
22 |
public class JDialogContent extends JPanel implements ComponentListener{ |
23 |
/**
|
24 |
*
|
25 |
*/
|
26 |
private static final long serialVersionUID = 1L; |
27 |
protected JPanel PanelDialog = null; |
28 |
static JLabel status; |
29 |
protected ScriptingUIManager uimanager;
|
30 |
protected JButton accept = null; |
31 |
private String title; |
32 |
|
33 |
public JDialogContent(ScriptingUIManager uimanager, String icon, String title, String description, final DialogPanel content){ |
34 |
this.uimanager = uimanager;
|
35 |
this.setLayout(new BorderLayout()); |
36 |
|
37 |
this.title = title;
|
38 |
|
39 |
// Cabecera
|
40 |
JLabel titleLabel = new JLabel(title); |
41 |
titleLabel.setFont(new Font("Serif",Font.BOLD,15)); |
42 |
|
43 |
JLabel descriptionLabel = new JLabel(description); |
44 |
descriptionLabel.setFont(new Font("Serif",Font.PLAIN,12)); |
45 |
|
46 |
JPanel titlePane = new JPanel(new BorderLayout()); |
47 |
titlePane.add(titleLabel, BorderLayout.CENTER);
|
48 |
titlePane.add(descriptionLabel, BorderLayout.SOUTH);
|
49 |
titlePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 120)); |
50 |
|
51 |
JLabel picture = new JLabel(uimanager.getIcon(icon,"big")); |
52 |
picture.setPreferredSize(new Dimension(50,50)); |
53 |
|
54 |
JPanel header = new JPanel(new BorderLayout()); |
55 |
header.add(picture, BorderLayout.EAST);
|
56 |
header.add(titlePane, BorderLayout.CENTER);
|
57 |
header.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 10)); |
58 |
|
59 |
|
60 |
// Contenedor central
|
61 |
JPanel contentPane = new JPanel(new BorderLayout()); |
62 |
contentPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
63 |
content.getJComponent().setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, new Color(220,220,220))); |
64 |
contentPane.add(content.getJComponent(), BorderLayout.CENTER);
|
65 |
|
66 |
// Botonera
|
67 |
JButton help = new JButton(uimanager.getIcon("help-browser")); |
68 |
help.setPreferredSize(new Dimension(25,25)); |
69 |
help.addActionListener(new ActionListener(){ |
70 |
public void actionPerformed(ActionEvent arg0) { |
71 |
getHelpPanel(); |
72 |
} |
73 |
}); |
74 |
|
75 |
JPanel buttons = new JPanel(new BorderLayout()); |
76 |
|
77 |
JPanel optionsPane = new JPanel(); |
78 |
optionsPane.setLayout(new BoxLayout(optionsPane, BoxLayout.LINE_AXIS)); |
79 |
optionsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
80 |
optionsPane.add(Box.createHorizontalGlue());
|
81 |
|
82 |
content.getJComponent().addComponentListener(this);
|
83 |
|
84 |
if(content.isVisibleAccept()){
|
85 |
accept = new JButton(this.uimanager.getTranslation("Accept")); |
86 |
accept.addActionListener(new ActionListener(){ |
87 |
public void actionPerformed(ActionEvent arg0) { |
88 |
content.actionAccept(); |
89 |
} |
90 |
}); |
91 |
|
92 |
optionsPane.add(accept); |
93 |
optionsPane.add(Box.createRigidArea(new Dimension(10, 0))); |
94 |
} |
95 |
|
96 |
if(content.isVisibleCancel()){
|
97 |
JButton cancel = new JButton(this.uimanager.getTranslation("Cancel")); |
98 |
cancel.addActionListener(new ActionListener(){ |
99 |
public void actionPerformed(ActionEvent arg0) { |
100 |
content.actionCancel(); |
101 |
} |
102 |
}); |
103 |
|
104 |
optionsPane.add(cancel); |
105 |
optionsPane.add(Box.createRigidArea(new Dimension(10, 0))); |
106 |
} |
107 |
|
108 |
if( content.isVisibleApply()){
|
109 |
JButton apply = new JButton(this.uimanager.getTranslation("Apply")); |
110 |
apply.addActionListener(new ActionListener(){ |
111 |
public void actionPerformed(ActionEvent arg0) { |
112 |
content.actionApply(); |
113 |
} |
114 |
}); |
115 |
|
116 |
optionsPane.add(apply); |
117 |
} |
118 |
|
119 |
JPanel helpPane = new JPanel(); |
120 |
helpPane.setLayout(new BoxLayout(helpPane, BoxLayout.LINE_AXIS)); |
121 |
helpPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
122 |
helpPane.add(Box.createHorizontalGlue());
|
123 |
helpPane.add(help); |
124 |
|
125 |
buttons.add(helpPane,BorderLayout.WEST);
|
126 |
buttons.add(optionsPane, BorderLayout.EAST);
|
127 |
|
128 |
|
129 |
// Integramos en el frame
|
130 |
this.add(header, BorderLayout.NORTH); |
131 |
this.add(contentPane, BorderLayout.CENTER); |
132 |
this.add(buttons, BorderLayout.SOUTH); |
133 |
|
134 |
|
135 |
//this.uimanager.showDialog(this, title);
|
136 |
} |
137 |
|
138 |
public void showDialog(){ |
139 |
this.uimanager.showDialog(this, title); |
140 |
} |
141 |
|
142 |
public void getHelpPanel(){ |
143 |
uimanager.showDialog(uimanager.getAPIHelp(),"JavaDoc");
|
144 |
} |
145 |
|
146 |
public void componentHidden(ComponentEvent arg0) { |
147 |
this.setVisible(false); |
148 |
|
149 |
} |
150 |
|
151 |
public void componentMoved(ComponentEvent arg0) { |
152 |
|
153 |
} |
154 |
|
155 |
public void componentResized(ComponentEvent arg0) { |
156 |
|
157 |
} |
158 |
|
159 |
public void componentShown(ComponentEvent arg0) { |
160 |
|
161 |
} |
162 |
|
163 |
} |