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 @ 165
History | View | Annotate | Download (2.62 KB)
1 | 165 | jobacas | 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 | |||
12 | import org.gvsig.scripting.ScriptingBaseScript; |
||
13 | import org.gvsig.scripting.ScriptingScript; |
||
14 | import org.gvsig.scripting.swing.api.JCodeEditor; |
||
15 | import org.gvsig.scripting.swing.api.ScriptingUIManager; |
||
16 | |||
17 | |||
18 | public class DefaultJCodeEditor extends JCodeEditor{ |
||
19 | |||
20 | /**
|
||
21 | *
|
||
22 | */
|
||
23 | private static final long serialVersionUID = 5191252525229037754L; |
||
24 | protected JTabbedPane pestana; |
||
25 | JTextField name;
|
||
26 | JTextArea description;
|
||
27 | EditorHelper editorHelper; |
||
28 | // JEditorPaneSyntaxHighlighting editor;
|
||
29 | |||
30 | protected ScriptingBaseScript script;
|
||
31 | // protected ScriptingUIManager uimanager;
|
||
32 | |||
33 | //-----------------------
|
||
34 | // protected ActionListener defaultActionlistener = null;
|
||
35 | |||
36 | public static class EditorActionEvent extends ActionEvent{ |
||
37 | |||
38 | /**
|
||
39 | *
|
||
40 | */
|
||
41 | private static final long serialVersionUID = 8011710639269922487L; |
||
42 | private int line = 0; |
||
43 | private int column = 0; |
||
44 | // private int position = 0;
|
||
45 | |||
46 | public EditorActionEvent(Object source, int id, String command, int line, int column) { |
||
47 | super(source,id,command);
|
||
48 | this.line = line;
|
||
49 | this.column = column;
|
||
50 | } |
||
51 | |||
52 | public int[] getLineAndColumn(){ |
||
53 | int x[] = {this.line,this.column}; |
||
54 | return x;
|
||
55 | } |
||
56 | |||
57 | } |
||
58 | |||
59 | public void addDefaultActionListener(ActionListener actionlistener) { |
||
60 | this.editorHelper.addDefaultActionListener(actionlistener);
|
||
61 | } |
||
62 | //-------------
|
||
63 | |||
64 | public DefaultJCodeEditor(ScriptingUIManager uimanager, ScriptingScript script){
|
||
65 | this.script = script;
|
||
66 | this.editorHelper = new EditorHelper(uimanager,this.getScript()); |
||
67 | makeUI(); |
||
68 | } |
||
69 | |||
70 | public ScriptingScript getScript(){
|
||
71 | return (ScriptingScript) this.script; |
||
72 | } |
||
73 | |||
74 | private void makeUI(){ |
||
75 | pestana = new JTabbedPane(); |
||
76 | pestana.setTabPlacement(JTabbedPane.BOTTOM);
|
||
77 | pestana.addTab("Code", editorHelper.getCodePanel());
|
||
78 | pestana.addTab("Properties", editorHelper.getPropertiesPanel());
|
||
79 | this.setLayout( new BorderLayout() ); |
||
80 | this.add(BorderLayout.CENTER, pestana); |
||
81 | } |
||
82 | |||
83 | |||
84 | public void save(){ |
||
85 | this.editorHelper.saveScript( ((JPropertiesScript)pestana.getComponent(1))); |
||
86 | } |
||
87 | |||
88 | public JEditorPane getJEditorPanel(){ |
||
89 | return this.editorHelper.getJEditorPanel(); |
||
90 | } |
||
91 | |||
92 | /*private String cursorLocation(String text, int point){
|
||
93 | int row=0;
|
||
94 | int positionLastRow=0;
|
||
95 | for(int i=0;i<point;i++){
|
||
96 | String x = ""+text.charAt(i)+"";
|
||
97 | if(x.equals("\n")){
|
||
98 | row++;
|
||
99 | positionLastRow = i;
|
||
100 | }
|
||
101 | }
|
||
102 | String result = row+":"+(point-positionLastRow);
|
||
103 | |||
104 | return result;
|
||
105 | }*/
|
||
106 | |||
107 | } |