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 / composer / DefaultJDialogEditor.java @ 368
History | View | Annotate | Download (2.17 KB)
1 |
package org.gvsig.scripting.swing.impl.composer; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.event.ActionListener; |
5 |
|
6 |
import javax.swing.JEditorPane; |
7 |
import javax.swing.JPanel; |
8 |
import javax.swing.JScrollPane; |
9 |
import javax.swing.JTabbedPane; |
10 |
import javax.swing.text.JTextComponent; |
11 |
|
12 |
import org.gvsig.scripting.ScriptingDialog; |
13 |
import org.gvsig.scripting.ScriptingScript; |
14 |
import org.gvsig.scripting.swing.api.JDialogEditor; |
15 |
import org.gvsig.scripting.swing.api.JThinG; |
16 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
17 |
|
18 |
|
19 |
public class DefaultJDialogEditor extends JDialogEditor{ |
20 |
|
21 |
/**
|
22 |
*
|
23 |
*/
|
24 |
private static final long serialVersionUID = 5032349017514086800L; |
25 |
JThinG thing; |
26 |
protected ScriptingDialog script;
|
27 |
protected JTabbedPane pestana; |
28 |
EditorHelper editorHelper; |
29 |
|
30 |
public DefaultJDialogEditor(ScriptingUIManager uimanager, ScriptingDialog script) {
|
31 |
super();
|
32 |
this.script = script;
|
33 |
this.editorHelper = new EditorHelper(uimanager,(ScriptingScript) script); |
34 |
makeUI(); |
35 |
} |
36 |
|
37 |
private void makeUI(){ |
38 |
pestana = new JTabbedPane(); |
39 |
pestana.setTabPlacement(JTabbedPane.BOTTOM);
|
40 |
pestana.addTab("Dialog", getDialogPanel());
|
41 |
pestana.addTab("Code", editorHelper.getCodePanel());
|
42 |
pestana.addTab("Properties", editorHelper.getPropertiesPanel());
|
43 |
this.setLayout( new BorderLayout() ); |
44 |
this.add(BorderLayout.CENTER, pestana); |
45 |
} |
46 |
|
47 |
public ScriptingDialog getDialog(){
|
48 |
return (ScriptingDialog) this.script; |
49 |
} |
50 |
|
51 |
public void save(){ |
52 |
this.editorHelper.saveScript( ((JPropertiesScript)pestana.getComponent(2))); |
53 |
thing.save(this.getDialog().getDialogFile());
|
54 |
} |
55 |
|
56 |
private JPanel getDialogPanel(){ |
57 |
JPanel panel = new JPanel(); |
58 |
panel.setLayout( new BorderLayout() ); |
59 |
|
60 |
thing = this.editorHelper.getUIManager().createJThinG();
|
61 |
thing.load(this.getDialog().getDialogFile());
|
62 |
|
63 |
panel.add(new JScrollPane(thing),BorderLayout.CENTER); |
64 |
panel.setVisible(true);
|
65 |
|
66 |
return panel;
|
67 |
} |
68 |
|
69 |
public void addDefaultActionListener(ActionListener actionlistener) { |
70 |
this.editorHelper.addDefaultActionListener(actionlistener);
|
71 |
} |
72 |
|
73 |
public JTextComponent getJTextComponent(){ |
74 |
return this.editorHelper.getJEditorPanel(); |
75 |
} |
76 |
|
77 |
public ScriptingScript getScript() {
|
78 |
return (ScriptingScript) this.script; |
79 |
} |
80 |
} |