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 / DefaultJCodeEditor.java @ 368
History | View | Annotate | Download (2.36 KB)
1 |
package org.gvsig.scripting.swing.impl.composer; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
6 |
|
7 |
import javax.swing.JEditorPane; |
8 |
import javax.swing.JTabbedPane; |
9 |
import javax.swing.JTextArea; |
10 |
import javax.swing.JTextField; |
11 |
import javax.swing.text.JTextComponent; |
12 |
|
13 |
import org.gvsig.scripting.ScriptingBaseScript; |
14 |
import org.gvsig.scripting.ScriptingScript; |
15 |
import org.gvsig.scripting.swing.api.JCodeEditor; |
16 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
17 |
|
18 |
|
19 |
public class DefaultJCodeEditor extends JCodeEditor{ |
20 |
|
21 |
/**
|
22 |
*
|
23 |
*/
|
24 |
private static final long serialVersionUID = 5191252525229037754L; |
25 |
protected JTabbedPane pestana; |
26 |
JTextField name;
|
27 |
JTextArea description;
|
28 |
EditorHelper editorHelper; |
29 |
// JEditorPaneSyntaxHighlighting editor;
|
30 |
|
31 |
protected ScriptingBaseScript script;
|
32 |
// protected ScriptingUIManager uimanager;
|
33 |
|
34 |
//-----------------------
|
35 |
// protected ActionListener defaultActionlistener = null;
|
36 |
|
37 |
public static class EditorActionEvent extends ActionEvent{ |
38 |
|
39 |
/**
|
40 |
*
|
41 |
*/
|
42 |
private static final long serialVersionUID = 8011710639269922487L; |
43 |
private int line = 0; |
44 |
private int column = 0; |
45 |
// private int position = 0;
|
46 |
|
47 |
public EditorActionEvent(Object source, int id, String command, int line, int column) { |
48 |
super(source,id,command);
|
49 |
this.line = line;
|
50 |
this.column = column;
|
51 |
} |
52 |
|
53 |
public int[] getLineAndColumn(){ |
54 |
int x[] = {this.line,this.column}; |
55 |
return x;
|
56 |
} |
57 |
|
58 |
} |
59 |
|
60 |
public void addDefaultActionListener(ActionListener actionlistener) { |
61 |
this.editorHelper.addDefaultActionListener(actionlistener);
|
62 |
} |
63 |
//-------------
|
64 |
|
65 |
public DefaultJCodeEditor(ScriptingUIManager uimanager, ScriptingScript script){
|
66 |
this.script = script;
|
67 |
this.editorHelper = new EditorHelper(uimanager,this.getScript()); |
68 |
makeUI(); |
69 |
} |
70 |
|
71 |
public ScriptingScript getScript(){
|
72 |
return (ScriptingScript) this.script; |
73 |
} |
74 |
|
75 |
private void makeUI(){ |
76 |
pestana = new JTabbedPane(); |
77 |
pestana.setTabPlacement(JTabbedPane.BOTTOM);
|
78 |
pestana.addTab("Code", editorHelper.getCodePanel());
|
79 |
pestana.addTab("Properties", editorHelper.getPropertiesPanel());
|
80 |
this.setLayout( new BorderLayout() ); |
81 |
this.add(BorderLayout.CENTER, pestana); |
82 |
} |
83 |
|
84 |
public void save(){ |
85 |
this.editorHelper.saveScript( ((JPropertiesScript)pestana.getComponent(1))); |
86 |
} |
87 |
|
88 |
public JTextComponent getJTextComponent(){ |
89 |
return this.editorHelper.getJEditorPanel(); |
90 |
} |
91 |
} |