Revision 639
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingExtension.java | ||
---|---|---|
126 | 126 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
127 | 127 |
|
128 | 128 |
if ("tools-scripting-launcher".equalsIgnoreCase(command)) { |
129 |
winmanager.showWindow(uimanager.createLauncher(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
|
129 |
winmanager.showWindow(uimanager.createLauncher().asJComponent(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL);
|
|
130 | 130 |
|
131 | 131 |
} else if ("tools-scripting-composer".equalsIgnoreCase(command)) { |
132 | 132 |
DynObject preferences = this.getPlugin().getPluginProperties(); |
... | ... | |
137 | 137 |
uiManager.setWindowManager(winmanager); |
138 | 138 |
} |
139 | 139 |
JScriptingComposer composer = uimanager.createComposer(); |
140 |
uiManager.showWindow(composer, uimanager.getTranslation("Scripting_Composer")); |
|
140 |
uiManager.showWindow(composer.asJComponent(), uimanager.getTranslation("Scripting_Composer"));
|
|
141 | 141 |
|
142 | 142 |
} else { |
143 | 143 |
ScriptingBaseScript script = uimanager.getManager().getScript(command); |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.main/src/main/java/org/gvsig/scripting/main/Main.java | ||
---|---|---|
9 | 9 |
import java.util.Date; |
10 | 10 |
import java.util.HashMap; |
11 | 11 |
import java.util.Map; |
12 |
import javax.swing.JComponent; |
|
12 | 13 |
|
13 | 14 |
import javax.swing.JFrame; |
14 | 15 |
import javax.swing.JMenu; |
15 | 16 |
import javax.swing.JMenuBar; |
16 | 17 |
import javax.swing.JMenuItem; |
17 |
import javax.swing.JPanel; |
|
18 | 18 |
import javax.swing.WindowConstants; |
19 | 19 |
|
20 | 20 |
import org.apache.commons.cli.CommandLine; |
... | ... | |
194 | 194 |
menuBar.add(menu_file); |
195 | 195 |
|
196 | 196 |
frame.add(menuBar, BorderLayout.NORTH); |
197 |
frame.add(uimanager.createLauncher(), BorderLayout.CENTER); |
|
197 |
frame.add(uimanager.createLauncher().asJComponent(), BorderLayout.CENTER);
|
|
198 | 198 |
|
199 | 199 |
// Display the window. |
200 | 200 |
frame.pack(); |
... | ... | |
215 | 215 |
} |
216 | 216 |
|
217 | 217 |
private void showComposer() { |
218 |
showWindow(uimanager.createComposer(), "Scripting Composer"); |
|
218 |
showWindow(uimanager.createComposer().asJComponent(), "Scripting Composer");
|
|
219 | 219 |
} |
220 | 220 |
|
221 | 221 |
private void showPackageInstaller(ScriptingManager manager) { |
... | ... | |
226 | 226 |
// not implemented |
227 | 227 |
} |
228 | 228 |
|
229 |
private void showWindow(JPanel panel, String title) {
|
|
229 |
private void showWindow(JComponent component, String title) {
|
|
230 | 230 |
JFrame frame = new JFrame(title); |
231 | 231 |
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
232 | 232 |
|
233 |
frame.setContentPane(panel);
|
|
233 |
frame.setContentPane(component);
|
|
234 | 234 |
|
235 | 235 |
// Display the window. |
236 | 236 |
frame.pack(); |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/DefaultScriptingUIManager.java | ||
---|---|---|
4 | 4 |
import java.awt.Dimension; |
5 | 5 |
import java.net.URL; |
6 | 6 |
import java.net.URLClassLoader; |
7 |
import java.util.ArrayList; |
|
8 | 7 |
import java.util.Collection; |
9 |
import java.util.Collections; |
|
10 | 8 |
import java.util.HashMap; |
11 |
import java.util.List; |
|
12 | 9 |
import java.util.Locale; |
13 | 10 |
import java.util.Map; |
14 | 11 |
import javax.help.HelpSet; |
... | ... | |
17 | 14 |
import javax.help.ScriptingHelpModel; |
18 | 15 |
import javax.swing.Action; |
19 | 16 |
import javax.swing.ImageIcon; |
17 |
import javax.swing.JComponent; |
|
20 | 18 |
import javax.swing.JPanel; |
21 | 19 |
import org.gvsig.about.AboutLocator; |
22 | 20 |
import org.gvsig.about.AboutManager; |
... | ... | |
26 | 24 |
import org.gvsig.scripting.ScriptingLocator; |
27 | 25 |
import org.gvsig.scripting.ScriptingManager; |
28 | 26 |
import org.gvsig.scripting.ScriptingScript; |
27 |
import org.gvsig.scripting.ScriptingUnit; |
|
29 | 28 |
import org.gvsig.scripting.swing.api.JCodeEditor; |
30 | 29 |
import org.gvsig.scripting.swing.api.JDialogEditor; |
30 |
import org.gvsig.scripting.swing.api.JEditor; |
|
31 | 31 |
import org.gvsig.scripting.swing.api.JScriptingBrowser; |
32 | 32 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
33 | 33 |
import org.gvsig.scripting.swing.api.JScriptingConsole; |
... | ... | |
53 | 53 |
|
54 | 54 |
private final static Logger logger = LoggerFactory.getLogger(DefaultScriptingUIManager.class); |
55 | 55 |
|
56 |
private ScriptingManager manager; |
|
57 |
private Map<String, URL> userHelps = new HashMap<String, URL>();
|
|
56 |
private final ScriptingManager manager;
|
|
57 |
private final Map<String, URL> userHelps = new HashMap<>();
|
|
58 | 58 |
private I18nManager i18nManager; |
59 | 59 |
private WindowManager windowsManager = null; |
60 |
private Map<String,Action> composerTools = new HashMap<>(); |
|
61 |
private Map<String,MenuEntry> composerMenus = new HashMap<>(); |
|
60 |
private final Map<String,Action> composerTools = new HashMap<>(); |
|
61 |
private final Map<String,MenuEntry> composerMenus = new HashMap<>(); |
|
62 |
private JScriptingComposer activeComposer; |
|
62 | 63 |
|
63 | 64 |
private static class DefaultMenuEntry implements MenuEntry { |
64 | 65 |
private final Action action; |
... | ... | |
88 | 89 |
this.i18nManager = ToolsLocator.getI18nManager(); |
89 | 90 |
} |
90 | 91 |
|
92 |
@Override |
|
91 | 93 |
public JScriptingComposer createComposer() { |
92 | 94 |
return new DefaultJScriptingComposer(this); |
93 | 95 |
} |
94 | 96 |
|
97 |
@Override |
|
95 | 98 |
public JPanel createInstaller() { |
96 | 99 |
// TODO Auto-generated method stub |
97 | 100 |
return null; |
98 | 101 |
} |
99 | 102 |
|
103 |
@Override |
|
100 | 104 |
public JScriptingLauncher createLauncher() { |
101 | 105 |
return new DefaultJScriptingLauncher(this); |
102 | 106 |
} |
103 | 107 |
|
108 |
@Override |
|
104 | 109 |
public ImageIcon getIcon(String name) { |
105 | 110 |
return this.getIcon(name, null); |
106 | 111 |
} |
107 | 112 |
|
113 |
@Override |
|
108 | 114 |
public ImageIcon getIcon(String name, String size) { |
109 | 115 |
if (name == null) { |
110 | 116 |
return new ImageIcon(); |
... | ... | |
162 | 168 |
return new String[]{curr, "en", "es"}; |
163 | 169 |
} |
164 | 170 |
|
171 |
@Override |
|
165 | 172 |
public JPanel getUserHelp() { |
166 | 173 |
String[] langs = this.getPrerreferedLanguages(); |
167 | 174 |
URL url = null; |
168 |
for (int i = 0; i < langs.length; i++) {
|
|
169 |
url = this.userHelps.get(langs[i]);
|
|
175 |
for (String lang : langs) {
|
|
176 |
url = this.userHelps.get(lang); |
|
170 | 177 |
if (url != null) { |
171 | 178 |
break; |
172 | 179 |
} |
... | ... | |
181 | 188 |
urls[0] = url; |
182 | 189 |
ClassLoader loader = new URLClassLoader(urls, this.getClass().getClassLoader()); |
183 | 190 |
|
184 |
HelpSet helpSet = null;
|
|
191 |
HelpSet helpSet; |
|
185 | 192 |
try { |
186 | 193 |
URL resource; |
187 | 194 |
resource = loader.getResource("org/gvsig/scripting/help/help.hs"); |
... | ... | |
200 | 207 |
|
201 | 208 |
} |
202 | 209 |
|
210 |
@Override |
|
203 | 211 |
public void addUserHelp(String langName, URL resource) { |
204 | 212 |
this.userHelps.put(langName.toLowerCase(), resource); |
205 | 213 |
} |
206 | 214 |
|
215 |
@Override |
|
207 | 216 |
public AboutManager getAboutManager() { |
208 | 217 |
return AboutLocator.getManager(); |
209 | 218 |
} |
210 | 219 |
|
211 |
private void showWindow(JPanel panel, String title, WindowManager.MODE mode) {
|
|
220 |
private void showWindow(JComponent panel, String title, WindowManager.MODE mode) {
|
|
212 | 221 |
WindowManager winmanager = this.getWindowManager(); |
213 | 222 |
if( winmanager instanceof WindowManager_v2 ) { |
214 | 223 |
((WindowManager_v2)winmanager).showWindow(panel, title, mode, getIcon("scripting_python").getImage()); |
... | ... | |
217 | 226 |
} |
218 | 227 |
} |
219 | 228 |
|
220 |
public void showDialog(JPanel panel, String title) { |
|
229 |
@Override |
|
230 |
public void showDialog(JComponent panel, String title) { |
|
221 | 231 |
this.showWindow(panel, title, WindowManager.MODE.DIALOG); |
222 | 232 |
} |
223 | 233 |
|
224 |
public void showWindow(JPanel panel, String title) { |
|
234 |
@Override |
|
235 |
public void showWindow(JComponent panel, String title) { |
|
225 | 236 |
this.showWindow(panel, title, WindowManager.MODE.WINDOW); |
226 | 237 |
} |
227 | 238 |
|
228 |
public void showTool(JPanel panel, String title) { |
|
239 |
@Override |
|
240 |
public void showTool(JComponent panel, String title) { |
|
229 | 241 |
this.showWindow(panel, title, WindowManager.MODE.TOOL); |
230 | 242 |
} |
231 | 243 |
|
244 |
@Override |
|
232 | 245 |
public JScriptingBrowser createBrowser(ScriptingUIManager uimanager, ScriptingFolder root, boolean foldersOnly) { |
233 | 246 |
return new DefaultJScriptingBrowser(uimanager, root, foldersOnly); |
234 | 247 |
} |
235 | 248 |
|
249 |
@Override |
|
236 | 250 |
public JScriptingBrowser createBrowser(ScriptingUIManager uimanager, ScriptingFolder root) { |
237 | 251 |
return new DefaultJScriptingBrowser(uimanager, root, false); |
238 | 252 |
} |
239 | 253 |
|
254 |
@Override |
|
240 | 255 |
public JCodeEditor createJCodeEditor(ScriptingUIManager uimanager, ScriptingScript script) { |
241 | 256 |
return new DefaultJCodeEditor(uimanager, script); |
242 | 257 |
} |
243 | 258 |
|
259 |
@Override |
|
244 | 260 |
public JDialogEditor createJDialogEditor(ScriptingUIManager uimanager, ScriptingDialog script) { |
245 | 261 |
return new DefaultJDialogEditor(uimanager, script); |
246 | 262 |
} |
247 | 263 |
|
264 |
@Override |
|
248 | 265 |
public JThinG createJThinG() { |
249 | 266 |
JThinG thing = new DefaultJThinG(); |
250 | 267 |
return thing; |
251 | 268 |
} |
252 | 269 |
|
270 |
@Override |
|
253 | 271 |
public JThinlet createJThinlet() { |
254 | 272 |
JThinlet thinlet = new DefaultJThinlet(); |
255 | 273 |
return thinlet; |
256 | 274 |
} |
257 | 275 |
|
276 |
@Override |
|
258 | 277 |
public SyntaxtHighlightTextComponent createSyntaxHighlightingPanel() { |
259 | 278 |
try { |
260 | 279 |
return new JRSyntaxTextArea(); |
... | ... | |
264 | 283 |
} |
265 | 284 |
} |
266 | 285 |
|
286 |
@Override |
|
267 | 287 |
public String getTranslation(String key) { |
268 | 288 |
if (this.i18nManager == null) { |
269 | 289 |
this.i18nManager = ToolsLocator.getI18nManager(); |
... | ... | |
271 | 291 |
return i18nManager.getTranslation(key); |
272 | 292 |
} |
273 | 293 |
|
294 |
@Override |
|
274 | 295 |
public WindowManager getWindowManager() { |
275 | 296 |
if( this.windowsManager==null ) { |
276 | 297 |
this.windowsManager = ToolsSwingLocator.getWindowManager(); |
... | ... | |
278 | 299 |
return this.windowsManager; |
279 | 300 |
} |
280 | 301 |
|
302 |
@Override |
|
281 | 303 |
public void setWindowManager(WindowManager windowsManager) { |
282 | 304 |
this.windowsManager = windowsManager; |
283 | 305 |
} |
... | ... | |
309 | 331 |
return this.composerTools.values(); |
310 | 332 |
} |
311 | 333 |
|
334 |
@Override |
|
335 |
public JEditor createEditor(ScriptingUnit unit) { |
|
336 |
if( unit instanceof ScriptingDialog ) { |
|
337 |
return new DefaultJDialogEditor(this, (ScriptingDialog) unit); |
|
338 |
} |
|
339 |
if( unit instanceof ScriptingScript ) { |
|
340 |
return new DefaultJCodeEditor(this, (ScriptingScript) unit); |
|
341 |
} |
|
342 |
return null; |
|
343 |
} |
|
344 |
|
|
345 |
public void setActiveComposer(JScriptingComposer composer) { |
|
346 |
this.activeComposer = composer; |
|
347 |
} |
|
312 | 348 |
|
349 |
public JScriptingComposer getActiveComposer() { |
|
350 |
return this.activeComposer; |
|
351 |
} |
|
352 |
|
|
313 | 353 |
} |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/DefaultJScriptingLauncher.java | ||
---|---|---|
1 | 1 |
package org.gvsig.scripting.swing.impl; |
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Component; |
|
5 | 4 |
import java.awt.Dimension; |
6 | 5 |
import java.awt.event.ActionEvent; |
7 | 6 |
import java.awt.event.ActionListener; |
8 | 7 |
import java.util.ArrayList; |
9 | 8 |
import java.util.List; |
9 |
import javax.swing.JComponent; |
|
10 |
import javax.swing.JPanel; |
|
10 | 11 |
|
11 | 12 |
import javax.swing.JTabbedPane; |
12 | 13 |
|
13 | 14 |
import org.gvsig.scripting.ScriptingBaseScript; |
14 |
import org.gvsig.scripting.ScriptingDialog; |
|
15 | 15 |
import org.gvsig.scripting.ScriptingFolder; |
16 | 16 |
import org.gvsig.scripting.ScriptingManager; |
17 | 17 |
import org.gvsig.scripting.ScriptingRunningException; |
18 |
import org.gvsig.scripting.ScriptingScript; |
|
18 |
import org.gvsig.scripting.swing.api.JScriptingBrowser; |
|
19 |
import org.gvsig.scripting.swing.api.JScriptingBrowser.BrowserActionEvent; |
|
19 | 20 |
import org.gvsig.scripting.swing.api.JScriptingLauncher; |
20 | 21 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
21 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingBrowser.BrowserActionEvent; |
|
22 |
import org.gvsig.scripting.swing.impl.composer.DefaultJScriptingComposer; |
|
23 |
import org.gvsig.tools.task.AbstractMonitorableTask; |
|
22 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingBrowser.DefaultBrowserActionEvent; |
|
24 | 23 |
import org.slf4j.Logger; |
25 | 24 |
import org.slf4j.LoggerFactory; |
26 | 25 |
|
27 |
public class DefaultJScriptingLauncher extends JScriptingLauncher implements ActionListener{
|
|
26 |
public class DefaultJScriptingLauncher extends JPanel implements JScriptingLauncher, ActionListener {
|
|
28 | 27 |
|
29 |
private static Logger LOG = LoggerFactory.getLogger(DefaultJScriptingLauncher.class);
|
|
30 |
/**
|
|
31 |
*
|
|
32 |
*/
|
|
33 |
private static final long serialVersionUID = -2612734398104678920L;
|
|
28 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultJScriptingLauncher.class);
|
|
29 |
/**
|
|
30 |
*
|
|
31 |
*/
|
|
32 |
private static final long serialVersionUID = -2612734398104678920L;
|
|
34 | 33 |
|
35 |
protected ActionListener defaultActionlistener = null;
|
|
36 |
protected ActionListener selectionActionlistener = null;
|
|
37 |
protected ActionListener dropDownActionlistener = null;
|
|
38 |
JTabbedPane pestana;
|
|
39 |
ScriptingUIManager uimanager;
|
|
40 |
ScriptingManager manager;
|
|
34 |
protected ActionListener defaultActionlistener = null;
|
|
35 |
// protected ActionListener selectionActionlistener = null;
|
|
36 |
// protected ActionListener dropDownActionlistener = null;
|
|
37 |
JTabbedPane pestana;
|
|
38 |
ScriptingUIManager uimanager;
|
|
39 |
ScriptingManager manager;
|
|
41 | 40 |
|
42 |
public static class LauncherActionEvent extends ActionEvent{ |
|
41 |
public DefaultJScriptingLauncher(ScriptingUIManager uimanager) { |
|
42 |
this.uimanager = uimanager; |
|
43 |
this.manager = uimanager.getManager(); |
|
43 | 44 |
|
44 |
/** |
|
45 |
* |
|
46 |
*/ |
|
47 |
private static final long serialVersionUID = -6960022165103651050L; |
|
48 |
private ScriptingBaseScript script= null; |
|
45 |
List<ScriptingFolder> folders = new ArrayList<>(); |
|
46 |
folders.add(manager.getUserFolder()); |
|
47 |
folders.addAll(manager.getAlternativeUserFolders()); |
|
48 |
folders.add(manager.getSystemFolder()); |
|
49 |
pestana = new JTabbedPane(); |
|
50 |
for (ScriptingFolder folder : folders) { |
|
51 |
DefaultJScriptingBrowser browser = new DefaultJScriptingBrowser(uimanager, folder); |
|
52 |
browser.addDefaultActionListener(this); |
|
53 |
pestana.addTab(uimanager.getTranslation(folder.getName()), browser); |
|
54 |
} |
|
55 |
this.setLayout(new BorderLayout()); |
|
56 |
this.add(pestana, BorderLayout.CENTER); |
|
57 |
this.setPreferredSize(new Dimension(260, 300)); |
|
58 |
} |
|
49 | 59 |
|
50 |
public LauncherActionEvent(Object source, int id, String command, ScriptingBaseScript script) { |
|
51 |
super(source,id,command); |
|
52 |
this.script = script; |
|
53 |
} |
|
54 | 60 |
|
55 |
public ScriptingBaseScript getScript(){
|
|
56 |
return this.script;
|
|
57 |
}
|
|
58 |
}
|
|
61 |
@Override
|
|
62 |
public JScriptingBrowser getSelectedBrowser() {
|
|
63 |
return (JScriptingBrowser) this.pestana.getSelectedComponent();
|
|
64 |
}
|
|
59 | 65 |
|
60 |
public DefaultJScriptingLauncher(ScriptingUIManager uimanager) { |
|
61 |
this.uimanager = uimanager; |
|
62 |
this.manager = uimanager.getManager(); |
|
66 |
@Override |
|
67 |
public JComponent asJComponent() { |
|
68 |
return this; |
|
69 |
} |
|
63 | 70 |
|
71 |
@Override |
|
72 |
public void refresh() { |
|
73 |
for (int i = 0; i < pestana.getTabCount(); i++) { |
|
74 |
DefaultJScriptingBrowser browser = (DefaultJScriptingBrowser) (pestana.getComponentAt(i)); |
|
75 |
browser.refresh(); |
|
76 |
} |
|
77 |
pestana.repaint(); |
|
78 |
} |
|
64 | 79 |
|
65 |
List<ScriptingFolder> folders = new ArrayList<ScriptingFolder>(); |
|
66 |
folders.add(manager.getUserFolder()); |
|
67 |
folders.addAll(manager.getAlternativeUserFolders()); |
|
68 |
folders.add(manager.getSystemFolder()); |
|
69 |
pestana = new JTabbedPane(); |
|
70 |
for (ScriptingFolder folder : folders) { |
|
71 |
DefaultJScriptingBrowser browser = new DefaultJScriptingBrowser(uimanager,folder); |
|
72 |
browser.addDefaultActionListener(this); |
|
73 |
pestana.addTab( uimanager.getTranslation(folder.getName()), browser); |
|
74 |
} |
|
75 |
this.setLayout( new BorderLayout() ); |
|
76 |
this.add(pestana,BorderLayout.CENTER ); |
|
77 |
this.setPreferredSize(new Dimension(260,300)); |
|
78 |
} |
|
80 |
@Override |
|
81 |
public void addDefaultActionListener(ActionListener actionlistener) { |
|
82 |
this.defaultActionlistener = actionlistener; |
|
83 |
} |
|
79 | 84 |
|
80 |
public void refresh(){ |
|
81 |
for( int i=0; i < pestana.getTabCount(); i++ ) { |
|
82 |
DefaultJScriptingBrowser browser = (DefaultJScriptingBrowser)(pestana.getComponentAt(i)); |
|
83 |
browser.refresh(); |
|
84 |
} |
|
85 |
pestana.repaint(); |
|
86 |
} |
|
85 |
@Override |
|
86 |
public void actionPerformed(ActionEvent e) { |
|
87 |
BrowserActionEvent e2 = (BrowserActionEvent) e; |
|
87 | 88 |
|
88 |
public JTabbedPane getTabbedPane(){ |
|
89 |
return this.pestana; |
|
90 |
} |
|
91 |
|
|
92 |
public void addDefaultActionListener(ActionListener actionlistener) { |
|
93 |
this.defaultActionlistener = actionlistener; |
|
94 |
} |
|
95 |
|
|
96 |
public void addSelectionActionListener(ActionListener actionlistener) { |
|
97 |
this.selectionActionlistener = actionlistener; |
|
98 |
} |
|
99 |
|
|
100 |
public void addDropDownActionListener(ActionListener actionlistener) { |
|
101 |
this.dropDownActionlistener = actionlistener; |
|
102 |
} |
|
103 |
|
|
104 |
public void actionPerformed(ActionEvent e) { |
|
105 |
BrowserActionEvent e2 = (BrowserActionEvent) e; |
|
106 |
|
|
107 |
switch(e.getID()){ |
|
108 |
case DefaultJScriptingBrowser.DEFAULT_ACTION: |
|
109 |
if(this.defaultActionlistener==null){ |
|
110 |
ScriptingBaseScript script = e2.getScript(); |
|
111 |
try { |
|
112 |
script.compile(); |
|
113 |
script.runAsTask(null); |
|
114 |
} catch (ScriptingRunningException ex) { |
|
115 |
LOG.warn("Problems launching script '"+script.getName() +"'", ex); |
|
116 |
} |
|
117 |
}else{ |
|
118 |
this.defaultActionlistener.actionPerformed( |
|
119 |
new LauncherActionEvent(this, DEFAULT_ACTION, "default", e2.getScript()) |
|
120 |
); |
|
121 |
} |
|
122 |
break; |
|
123 |
case DefaultJScriptingBrowser.DROPDOWN_ACTION: |
|
124 |
case DefaultJScriptingBrowser.SELECTION_ACTION: |
|
125 |
if( this.defaultActionlistener != null ) { |
|
126 |
this.defaultActionlistener.actionPerformed( |
|
127 |
new LauncherActionEvent(this, DEFAULT_ACTION, "default", e2.getScript()) |
|
128 |
); |
|
129 |
} |
|
130 |
break; |
|
131 |
} |
|
132 |
} |
|
89 |
switch (e.getID()) { |
|
90 |
case DefaultJScriptingBrowser.DEFAULT_ACTION: |
|
91 |
if (this.defaultActionlistener == null) { |
|
92 |
ScriptingBaseScript script = e2.getScript(); |
|
93 |
try { |
|
94 |
script.compile(); |
|
95 |
script.runAsTask(null); |
|
96 |
} catch (ScriptingRunningException ex) { |
|
97 |
LOG.warn("Problems launching script '" + script.getName() + "'", ex); |
|
98 |
} |
|
99 |
} else { |
|
100 |
this.defaultActionlistener.actionPerformed( |
|
101 |
new DefaultBrowserActionEvent(this, DEFAULT_ACTION, "default", e2.getScript()) |
|
102 |
); |
|
103 |
} |
|
104 |
break; |
|
105 |
case DefaultJScriptingBrowser.DROPDOWN_ACTION: |
|
106 |
case DefaultJScriptingBrowser.SELECTION_ACTION: |
|
107 |
if (this.defaultActionlistener != null) { |
|
108 |
this.defaultActionlistener.actionPerformed( |
|
109 |
new DefaultBrowserActionEvent(this, DEFAULT_ACTION, "default", e2.getScript()) |
|
110 |
); |
|
111 |
} |
|
112 |
break; |
|
113 |
} |
|
114 |
} |
|
133 | 115 |
} |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/DefaultJScriptingBrowser.java | ||
---|---|---|
20 | 20 |
import javax.swing.ImageIcon; |
21 | 21 |
import javax.swing.JComponent; |
22 | 22 |
import javax.swing.JLabel; |
23 |
import javax.swing.JPanel; |
|
23 | 24 |
import javax.swing.JScrollPane; |
24 | 25 |
import javax.swing.JTree; |
25 | 26 |
import javax.swing.KeyStroke; |
... | ... | |
42 | 43 |
import org.slf4j.LoggerFactory; |
43 | 44 |
import org.slf4j.Logger; |
44 | 45 |
|
45 |
public class DefaultJScriptingBrowser extends JScriptingBrowser { |
|
46 |
public class DefaultJScriptingBrowser extends JPanel implements JScriptingBrowser {
|
|
46 | 47 |
|
47 | 48 |
private static final Logger logger = LoggerFactory.getLogger(DefaultJScriptingBrowser.class); |
49 |
private static final long serialVersionUID = 3140698910497806258L; |
|
48 | 50 |
|
49 | 51 |
protected ScriptingUIManager uimanager; |
50 | 52 |
protected ScriptingManager manager; |
... | ... | |
53 | 55 |
protected ScriptingFolder root; |
54 | 56 |
protected ActionListener defaultActionlistener = null; |
55 | 57 |
protected ActionListener selectionActionlistener = null; |
56 |
protected ActionListener dropDownActionlistener = null; |
|
57 | 58 |
private final boolean foldersOnly; |
58 | 59 |
|
59 |
public static class BrowserActionEvent extends ActionEvent {
|
|
60 |
public static class DefaultBrowserActionEvent extends ActionEvent implements BrowserActionEvent {
|
|
60 | 61 |
|
61 | 62 |
/** |
62 | 63 |
* |
... | ... | |
64 | 65 |
private static final long serialVersionUID = -1474410768278633364L; |
65 | 66 |
private ScriptingBaseScript script = null; |
66 | 67 |
|
67 |
public BrowserActionEvent(Object source, int id, String command, |
|
68 |
public DefaultBrowserActionEvent(Object source, int id, String command,
|
|
68 | 69 |
ScriptingBaseScript script) { |
69 | 70 |
super(source, id, command); |
70 | 71 |
this.script = script; |
71 | 72 |
} |
72 | 73 |
|
74 |
@Override |
|
73 | 75 |
public ScriptingBaseScript getScript() { |
74 | 76 |
return this.script; |
75 | 77 |
} |
... | ... | |
203 | 205 |
this.makeUI(); |
204 | 206 |
} |
205 | 207 |
|
208 |
@Override |
|
209 |
public JComponent asJComponent() { |
|
210 |
return this; |
|
211 |
} |
|
212 |
|
|
206 | 213 |
public void refresh() { |
207 | 214 |
((ScriptingFolderTreeModel) this.treeModel).reload(); |
208 | 215 |
} |
... | ... | |
217 | 224 |
return this.root; |
218 | 225 |
} |
219 | 226 |
|
227 |
@Override |
|
220 | 228 |
public void addDefaultActionListener(ActionListener actionlistener) { |
221 | 229 |
this.defaultActionlistener = actionlistener; |
222 | 230 |
} |
223 | 231 |
|
232 |
@Override |
|
224 | 233 |
public void addSelectionActionListener(ActionListener actionlistener) { |
225 | 234 |
this.selectionActionlistener = actionlistener; |
226 | 235 |
} |
227 | 236 |
|
228 |
public void addDropDownActionListener(ActionListener actionlistener) { |
|
229 |
this.dropDownActionlistener = actionlistener; |
|
230 |
} |
|
231 |
|
|
232 | 237 |
private void makeUI() { |
233 | 238 |
if (this.foldersOnly) { |
234 | 239 |
treeModel = new ScriptingFolderTreeModelFoldersOnly(root); |
... | ... | |
248 | 253 |
public void valueChanged(TreeSelectionEvent e) { |
249 | 254 |
if (selectionActionlistener != null) { |
250 | 255 |
JComponent tree = (JComponent) e.getSource(); |
251 |
ActionEvent event = new BrowserActionEvent( |
|
256 |
ActionEvent event = new DefaultBrowserActionEvent(
|
|
252 | 257 |
tree.getParent(), |
253 | 258 |
SELECTION_ACTION, |
254 | 259 |
"select", |
... | ... | |
317 | 322 |
ScriptingUnit unit = (ScriptingUnit) path.getLastPathComponent(); |
318 | 323 |
if (unit instanceof ScriptingBaseScript) { |
319 | 324 |
if (this.defaultActionlistener != null) { |
320 |
ActionEvent event = new BrowserActionEvent( |
|
325 |
ActionEvent event = new DefaultBrowserActionEvent(
|
|
321 | 326 |
this, |
322 | 327 |
DEFAULT_ACTION, |
323 | 328 |
"default", |
... | ... | |
329 | 334 |
} |
330 | 335 |
|
331 | 336 |
private class EnterAction extends AbstractAction { |
337 |
private static final long serialVersionUID = -3673546098243190397L; |
|
332 | 338 |
|
333 | 339 |
@Override |
334 | 340 |
public void actionPerformed(ActionEvent ae) { |
... | ... | |
339 | 345 |
} |
340 | 346 |
|
341 | 347 |
private class ExpandSelectedNodeAction extends AbstractAction { |
348 |
private static final long serialVersionUID = -4121272513454221967L; |
|
342 | 349 |
|
343 | 350 |
@Override |
344 | 351 |
public void actionPerformed(ActionEvent ae) { |
... | ... | |
382 | 389 |
setOpaque(false); |
383 | 390 |
} |
384 | 391 |
|
385 |
private Map<String, ImageIcon> icons = new HashMap<String, ImageIcon>();
|
|
392 |
private final Map<String, ImageIcon> icons = new HashMap<>();
|
|
386 | 393 |
|
387 | 394 |
private ImageIcon getIcon(String iconName) { |
388 | 395 |
ImageIcon img = this.icons.get(iconName); |
... | ... | |
401 | 408 |
return getIcon(unit.getIconNames()[0]); |
402 | 409 |
} |
403 | 410 |
|
411 |
@Override |
|
404 | 412 |
public Component getTreeCellRendererComponent(JTree tree, Object value, |
405 | 413 |
boolean sel, boolean expanded, boolean leaf, int row, |
406 | 414 |
boolean hasFocus) { |
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/JCodePanel.java | ||
---|---|---|
4 | 4 |
import java.awt.event.ActionListener; |
5 | 5 |
import java.awt.event.KeyEvent; |
6 | 6 |
import java.awt.event.KeyListener; |
7 |
import java.beans.PropertyChangeEvent; |
|
8 | 7 |
import java.beans.PropertyChangeListener; |
9 |
import java.util.HashSet; |
|
10 |
import java.util.Set; |
|
11 | 8 |
import javax.swing.JPanel; |
12 | 9 |
import javax.swing.text.JTextComponent; |
13 | 10 |
import org.gvsig.scripting.ScriptingScript; |
... | ... | |
36 | 33 |
this.initComponent(); |
37 | 34 |
} |
38 | 35 |
|
39 |
public void addDefaultActionListener(ActionListener actionlistener) {
|
|
36 |
public void addUpdateCaretPositionActionListener(ActionListener actionlistener) {
|
|
40 | 37 |
editorText.addUpdateCaretPositionActionListener(actionlistener); |
41 | 38 |
} |
42 | 39 |
|
... | ... | |
97 | 94 |
public JTextComponent getJTextComponent() { |
98 | 95 |
return this.editorText.getJTextComponent(); |
99 | 96 |
} |
97 |
|
|
98 |
public void selectLine(int line) { |
|
99 |
JTextComponent editor = this.getJTextComponent(); |
|
100 |
editor.requestFocusInWindow(); |
|
101 |
|
|
102 |
String code = editor.getText(); |
|
103 |
int lineCounter = 0; |
|
104 |
int initialSelection = 0; |
|
105 |
int finalSelection = 0; |
|
106 |
for (int j = 0; j < code.length(); j++) { |
|
107 |
if (code.charAt(j) == '\n') { |
|
108 |
lineCounter++; |
|
109 |
if (lineCounter == line - 1) { |
|
110 |
initialSelection = j; |
|
111 |
} |
|
112 |
if (lineCounter == line || (finalSelection == 0 && j == code.length() - 1)) { |
|
113 |
finalSelection = j; |
|
114 |
} |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
editor.select(initialSelection, finalSelection); |
|
119 |
} |
|
120 |
|
|
100 | 121 |
} |
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 | ||
---|---|---|
6 | 6 |
import java.beans.PropertyChangeListener; |
7 | 7 |
import java.util.HashSet; |
8 | 8 |
import java.util.Set; |
9 |
import javax.swing.JComponent; |
|
9 | 10 |
|
10 | 11 |
import javax.swing.JPanel; |
11 | 12 |
import javax.swing.JScrollPane; |
12 | 13 |
import javax.swing.JTabbedPane; |
13 | 14 |
import javax.swing.text.JTextComponent; |
15 |
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; |
|
14 | 16 |
|
15 | 17 |
import org.gvsig.scripting.ScriptingDialog; |
16 | 18 |
import org.gvsig.scripting.ScriptingScript; |
... | ... | |
18 | 20 |
import org.gvsig.scripting.swing.api.JThinG; |
19 | 21 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
20 | 22 |
|
21 |
public class DefaultJDialogEditor extends JDialogEditor { |
|
23 |
public class DefaultJDialogEditor extends JPanel implements JDialogEditor {
|
|
22 | 24 |
|
23 | 25 |
private static final long serialVersionUID = 5032349017514086800L; |
24 | 26 |
private JThinG thing; |
25 | 27 |
protected ScriptingDialog script; |
26 | 28 |
protected JTabbedPane pestana; |
27 |
private EditorHelper editorHelper; |
|
29 |
private final EditorHelper editorHelper;
|
|
28 | 30 |
private final ScriptingUIManager uimanager; |
29 | 31 |
private boolean modified; |
30 | 32 |
protected Set<PropertyChangeListener> changeListeners; |
... | ... | |
105 | 107 |
} |
106 | 108 |
|
107 | 109 |
@Override |
108 |
public void addDefaultActionListener(ActionListener actionlistener) {
|
|
109 |
this.editorHelper.getCodePanel().addDefaultActionListener(actionlistener);
|
|
110 |
public void addUpdateCaretPositionActionListener(ActionListener actionlistener) {
|
|
111 |
this.editorHelper.getCodePanel().addUpdateCaretPositionActionListener(actionlistener);
|
|
110 | 112 |
} |
111 | 113 |
|
112 | 114 |
@Override |
... | ... | |
133 | 135 |
public boolean isModified() { |
134 | 136 |
return this.modified; |
135 | 137 |
} |
138 |
|
|
139 |
@Override |
|
140 |
public void selectLine(int line) { |
|
141 |
this.editorHelper.getCodePanel().selectLine(line); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public int getLineCount() { |
|
146 |
JTextComponent textComponent = this.editorHelper.getCodePanel().getJTextComponent(); |
|
147 |
if( textComponent instanceof RSyntaxTextArea ) { |
|
148 |
return ((RSyntaxTextArea)textComponent).getLineCount(); |
|
149 |
} |
|
150 |
return 0; |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public JComponent asJComponent() { |
|
155 |
return this; |
|
156 |
} |
|
136 | 157 |
} |
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/EditorHelper.java | ||
---|---|---|
24 | 24 |
this.propertiesPanel = null; |
25 | 25 |
} |
26 | 26 |
|
27 |
public void addDefaultActionListener(ActionListener actionlistener) {
|
|
28 |
this.codePanel.addDefaultActionListener(actionlistener);
|
|
27 |
public void addUpdateCaretPositionActionListener(ActionListener actionlistener) {
|
|
28 |
this.codePanel.addUpdateCaretPositionActionListener(actionlistener);
|
|
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
public JPropertiesScript getPropertiesPanel() { |
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/DefaultJScriptingComposer.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Color; |
5 |
import java.awt.Component; |
|
6 | 5 |
import java.awt.Cursor; |
7 | 6 |
import java.awt.Dialog; |
8 | 7 |
import java.awt.Dimension; |
9 |
import java.awt.FlowLayout; |
|
10 | 8 |
import java.awt.Font; |
11 | 9 |
import java.awt.event.ActionEvent; |
12 | 10 |
import java.awt.event.ActionListener; |
... | ... | |
14 | 12 |
import java.beans.PropertyChangeEvent; |
15 | 13 |
import java.beans.PropertyChangeListener; |
16 | 14 |
import java.io.File; |
17 |
import java.io.OutputStream;
|
|
18 |
import java.io.PrintStream;
|
|
15 |
import java.util.ArrayList;
|
|
16 |
import java.util.Date;
|
|
19 | 17 |
import java.util.HashMap; |
20 | 18 |
import java.util.HashSet; |
21 | 19 |
import java.util.Iterator; |
... | ... | |
30 | 28 |
import javax.swing.JButton; |
31 | 29 |
import javax.swing.JComponent; |
32 | 30 |
import javax.swing.JLabel; |
33 |
import javax.swing.JMenu; |
|
34 | 31 |
import javax.swing.JMenuBar; |
35 | 32 |
import javax.swing.JMenuItem; |
36 | 33 |
import javax.swing.JOptionPane; |
... | ... | |
39 | 36 |
import javax.swing.JSplitPane; |
40 | 37 |
import javax.swing.JTabbedPane; |
41 | 38 |
import javax.swing.JTable; |
42 |
import javax.swing.JTextArea; |
|
43 | 39 |
import javax.swing.JToolBar; |
44 | 40 |
import javax.swing.KeyStroke; |
45 | 41 |
import javax.swing.ListSelectionModel; |
46 | 42 |
import javax.swing.SwingConstants; |
47 | 43 |
import javax.swing.SwingUtilities; |
48 | 44 |
import javax.swing.UIManager; |
45 |
import javax.swing.event.AncestorEvent; |
|
46 |
import javax.swing.event.AncestorListener; |
|
49 | 47 |
import javax.swing.event.ChangeEvent; |
50 | 48 |
import javax.swing.event.ChangeListener; |
51 | 49 |
import javax.swing.event.ListSelectionEvent; |
52 | 50 |
import javax.swing.event.ListSelectionListener; |
53 | 51 |
import javax.swing.table.DefaultTableModel; |
54 |
import javax.swing.text.BadLocationException;
|
|
52 |
import javax.swing.table.TableModel;
|
|
55 | 53 |
import javax.swing.text.JTextComponent; |
56 | 54 |
import org.fife.rsta.ui.GoToDialog; |
57 | 55 |
import org.fife.rsta.ui.search.FindDialog; |
... | ... | |
68 | 66 |
import org.gvsig.scripting.CompileErrorException; |
69 | 67 |
import org.gvsig.scripting.ExecuteErrorException; |
70 | 68 |
import org.gvsig.scripting.ScriptingBaseScript; |
71 |
import org.gvsig.scripting.ScriptingDialog; |
|
72 | 69 |
import org.gvsig.scripting.ScriptingFolder; |
73 | 70 |
import org.gvsig.scripting.ScriptingManager; |
74 | 71 |
import org.gvsig.scripting.ScriptingNotification; |
... | ... | |
77 | 74 |
import org.gvsig.scripting.swing.api.JCodeEditor; |
78 | 75 |
import org.gvsig.scripting.swing.api.JEditor; |
79 | 76 |
import org.gvsig.scripting.swing.api.JScriptingBrowser; |
77 |
import org.gvsig.scripting.swing.api.JScriptingBrowser.BrowserActionEvent; |
|
80 | 78 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
79 |
import org.gvsig.scripting.swing.api.JScriptingComposer.Dock.DockedPanel; |
|
80 |
import org.gvsig.scripting.swing.api.JScriptingComposer.Problems; |
|
81 |
import org.gvsig.scripting.swing.api.JScriptingComposer.Problems.Problem; |
|
81 | 82 |
import org.gvsig.scripting.swing.api.JScriptingConsole; |
83 |
import org.gvsig.scripting.swing.api.JScriptingLauncher; |
|
82 | 84 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
83 | 85 |
import org.gvsig.scripting.swing.api.ScriptingUIManager.MenuEntry; |
84 | 86 |
import org.gvsig.scripting.swing.api.SyntaxtHighlightTextComponent.UpdateCaretPositionActionEvent; |
85 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingBrowser; |
|
86 | 87 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingConsole; |
87 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingLauncher; |
|
88 |
import org.gvsig.scripting.swing.impl.DefaultJScriptingLauncher.LauncherActionEvent; |
|
89 | 88 |
import org.gvsig.scripting.swing.impl.DefaultScriptingUIManager; |
90 | 89 |
import org.gvsig.scripting.swing.impl.JDialogContent; |
91 | 90 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
96 | 95 |
import org.gvsig.tools.packageutils.PackageManager; |
97 | 96 |
import org.gvsig.tools.packageutils.Version; |
98 | 97 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
98 |
import org.gvsig.tools.swing.api.Component; |
|
99 | 99 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
100 | 100 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
101 | 101 |
import org.slf4j.Logger; |
102 | 102 |
import org.slf4j.LoggerFactory; |
103 | 103 |
|
104 |
public class DefaultJScriptingComposer extends JScriptingComposer implements Observer, ActionListener, SearchListener { |
|
105 |
private JToolBar tools; |
|
104 |
public class DefaultJScriptingComposer extends JPanel implements JScriptingComposer, Observer, ActionListener { |
|
106 | 105 |
|
106 |
/** |
|
107 |
* |
|
108 |
*/ |
|
109 |
private static final long serialVersionUID = 1L; |
|
110 |
|
|
111 |
private static final Logger logger = LoggerFactory.getLogger(DefaultJScriptingComposer.class); |
|
112 |
|
|
113 |
public static final int CLOSE_ACTION = 1; |
|
114 |
|
|
115 |
private final ScriptingUIManager uimanager; |
|
116 |
private final ScriptingManager manager; |
|
117 |
private final ClassLoader loader; |
|
118 |
|
|
119 |
private JSplitPane mainPanel; |
|
120 |
private Dock dock; |
|
121 |
|
|
122 |
private Map<String, ToolEntry> menus; |
|
123 |
private JMenuBar menuBar; |
|
124 |
|
|
125 |
private Map<String, ToolEntry> tools; |
|
126 |
private JToolBar toolBar; |
|
127 |
|
|
128 |
private StatusBar statusBar; |
|
129 |
|
|
130 |
private FindDialog findDialog; |
|
131 |
private ReplaceDialog replaceDialog; |
|
132 |
private GoToDialog gotoDialog; |
|
133 |
|
|
134 |
private ActionListener defaultActionlistener = null; |
|
135 |
|
|
136 |
private Set<ChangeListener> changeEditorListeners = null; |
|
137 |
|
|
107 | 138 |
private class GoToLineAction extends AbstractAction { |
108 | 139 |
|
140 |
private static final long serialVersionUID = -7353913671104893812L; |
|
141 |
|
|
109 | 142 |
public GoToLineAction() { |
110 | 143 |
super(uimanager.getTranslation("go_to_line_Xhorizontal_ellipsisX")); |
111 | 144 |
int c = getToolkit().getMenuShortcutKeyMask(); |
112 | 145 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_L, c)); |
146 |
putValue(ACTION_COMMAND_KEY, "GotoLine"); |
|
113 | 147 |
} |
114 | 148 |
|
115 | 149 |
@Override |
116 | 150 |
public void actionPerformed(ActionEvent e) { |
117 |
|
|
118 |
RSyntaxTextArea textArea = getCurrentRSyntaxTextArea(); |
|
119 |
if (textArea == null) { |
|
151 |
JEditor editor = getCurrentEditor(); |
|
152 |
if (!(editor instanceof JCodeEditor)) { |
|
120 | 153 |
return; |
121 | 154 |
} |
122 |
|
|
155 |
JCodeEditor codeEditor = (JCodeEditor) editor; |
|
123 | 156 |
if (findDialog.isVisible()) { |
124 | 157 |
findDialog.setVisible(false); |
125 | 158 |
} |
126 | 159 |
if (replaceDialog.isVisible()) { |
127 | 160 |
replaceDialog.setVisible(false); |
128 | 161 |
} |
129 |
gotoDialog.setMaxLineNumberAllowed(textArea.getLineCount());
|
|
162 |
gotoDialog.setMaxLineNumberAllowed(codeEditor.getLineCount());
|
|
130 | 163 |
gotoDialog.setVisible(true); |
131 | 164 |
int line = gotoDialog.getLineNumber(); |
165 |
|
|
132 | 166 |
if (line > 0) { |
133 |
try { |
|
134 |
textArea.setCaretPosition(textArea.getLineStartOffset(line - 1)); |
|
135 |
} catch (BadLocationException ble) { // Never happens |
|
136 |
UIManager.getLookAndFeel().provideErrorFeedback(textArea); |
|
137 |
ble.printStackTrace(); |
|
138 |
} |
|
167 |
codeEditor.selectLine(line); |
|
139 | 168 |
} |
140 | 169 |
} |
170 |
|
|
171 |
@Override |
|
172 |
public boolean isEnabled() { |
|
173 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
174 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
175 |
} |
|
141 | 176 |
} |
142 | 177 |
|
143 | 178 |
private class ShowFindDialogAction extends AbstractAction { |
144 | 179 |
|
180 |
private static final long serialVersionUID = -7840632153011361661L; |
|
181 |
|
|
145 | 182 |
public ShowFindDialogAction() { |
146 | 183 |
super(uimanager.getTranslation("find_Xhorizontal_ellipsisX")); |
147 | 184 |
int c = getToolkit().getMenuShortcutKeyMask(); |
148 | 185 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, c)); |
186 |
putValue(ACTION_COMMAND_KEY, "ShowFindDialog"); |
|
149 | 187 |
} |
150 | 188 |
|
189 |
@Override |
|
151 | 190 |
public void actionPerformed(ActionEvent e) { |
152 | 191 |
if (replaceDialog.isVisible()) { |
153 | 192 |
replaceDialog.setVisible(false); |
154 | 193 |
} |
155 | 194 |
findDialog.setVisible(true); |
156 | 195 |
} |
196 |
|
|
197 |
@Override |
|
198 |
public boolean isEnabled() { |
|
199 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
200 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
201 |
} |
|
157 | 202 |
} |
158 | 203 |
|
159 | 204 |
private class ShowReplaceDialogAction extends AbstractAction { |
160 | 205 |
|
206 |
private static final long serialVersionUID = 7209167803487996060L; |
|
207 |
|
|
161 | 208 |
public ShowReplaceDialogAction() { |
162 | 209 |
super(uimanager.getTranslation("replace_Xhorizontal_ellipsisX")); |
163 | 210 |
int c = getToolkit().getMenuShortcutKeyMask(); |
164 | 211 |
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_H, c)); |
212 |
putValue(ACTION_COMMAND_KEY, "ShowReplaceDialog"); |
|
165 | 213 |
} |
166 | 214 |
|
167 | 215 |
@Override |
... | ... | |
171 | 219 |
} |
172 | 220 |
replaceDialog.setVisible(true); |
173 | 221 |
} |
222 |
|
|
223 |
@Override |
|
224 |
public boolean isEnabled() { |
|
225 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
226 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
227 |
} |
|
174 | 228 |
} |
175 | 229 |
|
176 | 230 |
private class LauncherAction extends AbstractAction { |
177 | 231 |
|
232 |
private static final long serialVersionUID = 6257776255757689286L; |
|
233 |
|
|
178 | 234 |
public LauncherAction() { |
179 | 235 |
super(uimanager.getTranslation("Launcher")); |
236 |
putValue(ACTION_COMMAND_KEY, "ShowLauncher"); |
|
180 | 237 |
} |
181 | 238 |
|
182 | 239 |
@Override |
183 | 240 |
public void actionPerformed(ActionEvent e) { |
184 | 241 |
getWindowManager().showWindow( |
185 |
uimanager.createLauncher(), |
|
242 |
uimanager.createLauncher().asJComponent(),
|
|
186 | 243 |
uimanager.getTranslation("Scripting_Launcher"), |
187 | 244 |
WindowManager.MODE.TOOL |
188 | 245 |
); |
... | ... | |
192 | 249 |
|
193 | 250 |
private class SelectAllAction extends AbstractAction { |
194 | 251 |
|
252 |
private static final long serialVersionUID = 2725549699989067383L; |
|
253 |
|
|
195 | 254 |
public SelectAllAction() { |
196 | 255 |
super(uimanager.getTranslation("Select_all")); |
197 | 256 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-select-all")); |
198 | 257 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Select_all")); |
258 |
putValue(ACTION_COMMAND_KEY, "DocumentSelectAll"); |
|
199 | 259 |
} |
200 | 260 |
|
201 | 261 |
@Override |
... | ... | |
203 | 263 |
currentScriptSelectAll(); |
204 | 264 |
} |
205 | 265 |
|
266 |
@Override |
|
267 |
public boolean isEnabled() { |
|
268 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
269 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
270 |
} |
|
271 |
|
|
206 | 272 |
} |
207 | 273 |
|
208 | 274 |
private class PackageScriptAction extends AbstractAction { |
209 | 275 |
|
276 |
private static final long serialVersionUID = 8020393562984016720L; |
|
277 |
|
|
210 | 278 |
public PackageScriptAction() { |
211 | 279 |
super(uimanager.getTranslation("_Package_script")); |
212 | 280 |
putValue(Action.SMALL_ICON, uimanager.getIcon("package")); |
281 |
putValue(ACTION_COMMAND_KEY, "PackageScript"); |
|
213 | 282 |
} |
214 | 283 |
|
215 | 284 |
@Override |
... | ... | |
219 | 288 |
|
220 | 289 |
} |
221 | 290 |
|
222 |
private class ImportJavadocAction extends AbstractAction {
|
|
291 |
private class AboutAction extends AbstractAction {
|
|
223 | 292 |
|
224 |
public ImportJavadocAction() { |
|
225 |
super(uimanager.getTranslation("Import_JavaDoc")); |
|
226 |
putValue(Action.SMALL_ICON, uimanager.getIcon("list-add")); |
|
227 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Import_JavaDoc")); |
|
228 |
} |
|
293 |
private static final long serialVersionUID = -4928359535828269502L; |
|
229 | 294 |
|
230 |
@Override |
|
231 |
public void actionPerformed(ActionEvent e) { |
|
232 |
getWindowManager().showWindow( |
|
233 |
getImportHelpDialog(), |
|
234 |
uimanager.getTranslation("JavaDoc"), |
|
235 |
WindowManager.MODE.WINDOW |
|
236 |
); |
|
237 |
} |
|
238 |
|
|
239 |
} |
|
240 |
|
|
241 |
private class RemoveHelpAction extends AbstractAction { |
|
242 |
|
|
243 |
public RemoveHelpAction() { |
|
244 |
super(uimanager.getTranslation("Remove_help")); |
|
245 |
putValue(Action.SMALL_ICON, uimanager.getIcon("list-remove")); |
|
246 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Remove_JavaDoc")); |
|
247 |
} |
|
248 |
|
|
249 |
@Override |
|
250 |
public void actionPerformed(ActionEvent e) { |
|
251 |
try { |
|
252 |
//getRemoveHelpDialog(); |
|
253 |
JOptionPane.showMessageDialog( |
|
254 |
DefaultJScriptingComposer.this, |
|
255 |
"Falta por implementar", |
|
256 |
"Warning", |
|
257 |
JOptionPane.INFORMATION_MESSAGE |
|
258 |
); |
|
259 |
} catch (Exception e1) { |
|
260 |
logger.warn("Can't remove help",e1); |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
} |
|
265 |
|
|
266 |
private class HelpAction extends AbstractAction { |
|
267 |
|
|
268 |
public HelpAction() { |
|
269 |
super(uimanager.getTranslation("Help_contents")); |
|
270 |
int c = getToolkit().getMenuShortcutKeyMask(); |
|
271 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F1, c)); |
|
272 |
putValue(Action.SMALL_ICON, uimanager.getIcon("help-browser")); |
|
273 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Help_contents")); |
|
274 |
|
|
275 |
} |
|
276 |
|
|
277 |
@Override |
|
278 |
public void actionPerformed(ActionEvent e) { |
|
279 |
try { |
|
280 |
uimanager.showWindow( |
|
281 |
uimanager.getHelp(), |
|
282 |
uimanager.getTranslation("Help_contents") |
|
283 |
); |
|
284 |
} catch(Exception ex) { |
|
285 |
logger.warn("Can't show help dialog.",ex); |
|
286 |
JOptionPane.showMessageDialog( |
|
287 |
DefaultJScriptingComposer.this, |
|
288 |
uimanager.getTranslation("_Cant_show_help_dialog") |
|
289 |
+ "\n\n" |
|
290 |
+ uimanager.getTranslation("_See_the_error_log_for_more_information"), |
|
291 |
"_Warning", |
|
292 |
JOptionPane.WARNING_MESSAGE |
|
293 |
); |
|
294 |
} |
|
295 |
} |
|
296 |
|
|
297 |
} |
|
298 |
|
|
299 |
private class AboutAction extends AbstractAction { |
|
300 |
|
|
301 | 295 |
public AboutAction() { |
302 | 296 |
super(uimanager.getTranslation("About_scripts_editor")); |
303 | 297 |
putValue(Action.SMALL_ICON, uimanager.getIcon("about")); |
304 | 298 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("About_scripts_editor")); |
299 |
putValue(ACTION_COMMAND_KEY, "About"); |
|
305 | 300 |
} |
306 | 301 |
|
307 | 302 |
@Override |
... | ... | |
317 | 312 |
|
318 | 313 |
private class CutAction extends AbstractAction { |
319 | 314 |
|
315 |
private static final long serialVersionUID = -8549655706085425411L; |
|
316 |
|
|
320 | 317 |
public CutAction() { |
321 | 318 |
super(uimanager.getTranslation("Cut")); |
322 | 319 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-cut")); |
323 | 320 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Cut")); |
321 |
putValue(ACTION_COMMAND_KEY, "DocumentCut"); |
|
324 | 322 |
} |
325 | 323 |
|
326 | 324 |
@Override |
... | ... | |
328 | 326 |
currentScriptCut(); |
329 | 327 |
} |
330 | 328 |
|
329 |
@Override |
|
330 |
public boolean isEnabled() { |
|
331 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
332 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
333 |
} |
|
334 |
|
|
331 | 335 |
} |
332 | 336 |
|
333 | 337 |
private class CopyAction extends AbstractAction { |
334 | 338 |
|
339 |
private static final long serialVersionUID = -6870773810752024874L; |
|
340 |
|
|
335 | 341 |
public CopyAction() { |
336 | 342 |
super(uimanager.getTranslation("Copy")); |
337 | 343 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-copy")); |
338 | 344 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Copy")); |
345 |
putValue(ACTION_COMMAND_KEY, "DocumentCopy"); |
|
339 | 346 |
} |
340 | 347 |
|
341 | 348 |
@Override |
... | ... | |
343 | 350 |
currentScriptCopy(); |
344 | 351 |
} |
345 | 352 |
|
353 |
@Override |
|
354 |
public boolean isEnabled() { |
|
355 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
356 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
357 |
} |
|
358 |
|
|
346 | 359 |
} |
347 | 360 |
|
348 | 361 |
private class PasteAction extends AbstractAction { |
349 | 362 |
|
363 |
private static final long serialVersionUID = -5829551248494873061L; |
|
364 |
|
|
350 | 365 |
public PasteAction() { |
351 | 366 |
super(uimanager.getTranslation("Paste")); |
352 | 367 |
putValue(Action.SMALL_ICON, uimanager.getIcon("edit-paste")); |
353 | 368 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Paste")); |
369 |
putValue(ACTION_COMMAND_KEY, "DocumentPaste"); |
|
354 | 370 |
} |
355 | 371 |
|
356 | 372 |
@Override |
... | ... | |
358 | 374 |
currentScriptPaste(); |
359 | 375 |
} |
360 | 376 |
|
377 |
@Override |
|
378 |
public boolean isEnabled() { |
|
379 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
380 |
return panel != null && panel.getComponent() instanceof JCodeEditor; |
|
381 |
} |
|
382 |
|
|
361 | 383 |
} |
362 | 384 |
|
363 | 385 |
private class ExitAction extends AbstractAction { |
364 | 386 |
|
387 |
private static final long serialVersionUID = 9165363564675325925L; |
|
388 |
|
|
365 | 389 |
public ExitAction() { |
366 | 390 |
super(uimanager.getTranslation("Close")); |
367 | 391 |
putValue(Action.SMALL_ICON, uimanager.getIcon("exit")); |
368 | 392 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close")); |
393 |
putValue(ACTION_COMMAND_KEY, "CloseComposer"); |
|
369 | 394 |
} |
370 | 395 |
|
371 | 396 |
@Override |
... | ... | |
382 | 407 |
|
383 | 408 |
private class SaveAction extends AbstractAction { |
384 | 409 |
|
410 |
private static final long serialVersionUID = -870379961486387727L; |
|
411 |
|
|
385 | 412 |
public SaveAction() { |
386 | 413 |
super(uimanager.getTranslation("Save")); |
387 | 414 |
int c = getToolkit().getMenuShortcutKeyMask(); |
388 | 415 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, c)); |
389 | 416 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-save")); |
390 | 417 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Save")); |
418 |
putValue(ACTION_COMMAND_KEY, "DocumentSave"); |
|
391 | 419 |
} |
392 | 420 |
|
393 | 421 |
@Override |
394 | 422 |
public void actionPerformed(ActionEvent e) { |
395 | 423 |
currentScriptSave(); |
396 | 424 |
} |
425 |
|
|
426 |
@Override |
|
427 |
public boolean isEnabled() { |
|
428 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
429 |
return panel != null; |
|
430 |
} |
|
397 | 431 |
} |
398 | 432 |
|
399 | 433 |
private class RunAction extends AbstractAction { |
400 | 434 |
|
435 |
private static final long serialVersionUID = 4851968883766990149L; |
|
436 |
|
|
401 | 437 |
public RunAction() { |
402 | 438 |
super(uimanager.getTranslation("Run")); |
403 | 439 |
int c = getToolkit().getMenuShortcutKeyMask(); |
404 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5,0)); |
|
440 |
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
|
|
405 | 441 |
putValue(Action.SMALL_ICON, uimanager.getIcon("run")); |
406 | 442 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Run")); |
443 |
putValue(ACTION_COMMAND_KEY, "DocumentRun"); |
|
407 | 444 |
} |
408 | 445 |
|
409 | 446 |
@Override |
... | ... | |
411 | 448 |
currentScriptExecute(); |
412 | 449 |
} |
413 | 450 |
|
451 |
@Override |
|
452 |
public boolean isEnabled() { |
|
453 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
454 |
return panel != null; |
|
455 |
} |
|
414 | 456 |
} |
415 | 457 |
|
416 | 458 |
private class CloseAllAction extends AbstractAction { |
417 | 459 |
|
460 |
private static final long serialVersionUID = 3385142920283598457L; |
|
461 |
|
|
418 | 462 |
public CloseAllAction() { |
419 | 463 |
super(uimanager.getTranslation("Close_all_documents")); |
420 | 464 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-closeall")); |
421 | 465 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_all_documents")); |
466 |
putValue(ACTION_COMMAND_KEY, "CloseAll"); |
|
422 | 467 |
} |
423 | 468 |
|
424 | 469 |
@Override |
425 | 470 |
public void actionPerformed(ActionEvent e) { |
426 |
closeAllScripts(); |
|
471 |
closeAllScripts();
|
|
427 | 472 |
} |
428 | 473 |
|
474 |
@Override |
|
475 |
public boolean isEnabled() { |
|
476 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
477 |
return panel != null; |
|
478 |
} |
|
479 |
|
|
429 | 480 |
} |
430 | 481 |
|
431 |
private class CloseTabAction extends AbstractAction {
|
|
482 |
private class CloseDocumentAction extends AbstractAction {
|
|
432 | 483 |
|
433 |
private final Component component;
|
|
434 |
|
|
435 |
public CloseTabAction(Component component) {
|
|
436 |
super(uimanager.getTranslation("Close_tab"));
|
|
484 |
private static final long serialVersionUID = 4152188500446249755L;
|
|
485 |
|
|
486 |
public CloseDocumentAction() {
|
|
487 |
super(uimanager.getTranslation("Close_document"));
|
|
437 | 488 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-close")); |
438 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_tab")); |
|
439 |
this.component = component;
|
|
489 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_current_tab"));
|
|
490 |
putValue(ACTION_COMMAND_KEY, "DocumentClose");
|
|
440 | 491 |
} |
441 | 492 |
|
442 | 493 |
@Override |
443 | 494 |
public void actionPerformed(ActionEvent e) { |
444 |
int index = scriptEditors.indexOfComponent(component); |
|
445 |
if( index == -1 ) { |
|
446 |
return; |
|
447 |
} |
|
448 |
scriptClose(index); |
|
495 |
currentScriptClose(); |
|
449 | 496 |
} |
450 | 497 |
|
498 |
@Override |
|
499 |
public boolean isEnabled() { |
|
500 |
DockedPanel panel = dock.getSelected(Dock.DOCK_CENTER); |
|
501 |
return panel != null; |
|
502 |
} |
|
503 |
|
|
451 | 504 |
} |
452 |
|
|
453 |
private class CloseDocumentAction extends AbstractAction { |
|
454 | 505 |
|
455 |
public CloseDocumentAction() { |
|
456 |
super(uimanager.getTranslation("Close_document")); |
|
457 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-close")); |
|
458 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Close_current_tab")); |
|
506 |
private class ShowConsoleAction extends AbstractAction { |
|
507 |
|
|
508 |
private static final long serialVersionUID = -7545333555439711068L; |
|
509 |
|
|
510 |
public ShowConsoleAction() { |
|
511 |
super(uimanager.getTranslation("Console")); |
|
512 |
putValue(Action.SMALL_ICON, uimanager.getIcon("show-console")); |
|
513 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Show_console_panel")); |
|
514 |
putValue(ACTION_COMMAND_KEY, "ShowConsole"); |
|
459 | 515 |
} |
460 | 516 |
|
461 | 517 |
@Override |
462 | 518 |
public void actionPerformed(ActionEvent e) { |
463 |
currentScriptClose();
|
|
519 |
addConsolePanel();
|
|
464 | 520 |
} |
521 |
} |
|
465 | 522 |
|
523 |
private class ShowProblemsAction extends AbstractAction { |
|
524 |
|
|
525 |
private static final long serialVersionUID = 5276964996914550830L; |
|
526 |
|
|
527 |
public ShowProblemsAction() { |
|
528 |
super(uimanager.getTranslation("Problems")); |
|
529 |
putValue(Action.SMALL_ICON, uimanager.getIcon("show-problems")); |
|
530 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Show_problems_panel")); |
|
531 |
putValue(ACTION_COMMAND_KEY, "ShowProblems"); |
|
532 |
} |
|
533 |
|
|
534 |
@Override |
|
535 |
public void actionPerformed(ActionEvent e) { |
|
536 |
addProblemsPanel(); |
|
537 |
} |
|
466 | 538 |
} |
467 | 539 |
|
540 |
private class ShowProjectsAction extends AbstractAction { |
|
541 |
|
|
542 |
private static final long serialVersionUID = 5873598740133693862L; |
|
543 |
|
|
544 |
public ShowProjectsAction() { |
|
545 |
super(uimanager.getTranslation("Projects")); |
|
546 |
putValue(Action.SMALL_ICON, uimanager.getIcon("show-projects")); |
|
547 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Show_projects_panel")); |
|
548 |
putValue(ACTION_COMMAND_KEY, "ShowProjects"); |
|
549 |
} |
|
550 |
|
|
551 |
@Override |
|
552 |
public void actionPerformed(ActionEvent e) { |
|
553 |
addProjectsPanel(); |
|
554 |
} |
|
555 |
} |
|
556 |
|
|
468 | 557 |
private class NewDocumentAction extends AbstractAction { |
469 | 558 |
|
559 |
private static final long serialVersionUID = 7889613706183211620L; |
|
560 |
|
|
470 | 561 |
public NewDocumentAction() { |
471 | 562 |
super(uimanager.getTranslation("New")); |
472 | 563 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-add")); |
473 | 564 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("New")); |
565 |
putValue(ACTION_COMMAND_KEY, "DocumentNew"); |
|
474 | 566 |
} |
475 | 567 |
|
476 | 568 |
@Override |
... | ... | |
478 | 570 |
try { |
479 | 571 |
scriptNew(); |
480 | 572 |
} catch (Exception e1) { |
481 |
logger.warn("Can't create a new document",e1); |
|
573 |
logger.warn("Can't create a new document", e1);
|
|
482 | 574 |
} |
483 | 575 |
} |
484 | 576 |
|
485 | 577 |
} |
486 | 578 |
|
487 |
private class EditAction extends AbstractAction { |
|
579 |
private class ProjectEditAction extends AbstractAction {
|
|
488 | 580 |
|
489 |
public EditAction() { |
|
581 |
private static final long serialVersionUID = -3393464285985649074L; |
|
582 |
|
|
583 |
public ProjectEditAction() { |
|
490 | 584 |
super(uimanager.getTranslation("Edit")); |
491 | 585 |
putValue(Action.SMALL_ICON, uimanager.getIcon("doc-edit")); |
492 | 586 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Open_edition_mode")); |
587 |
putValue(ACTION_COMMAND_KEY, "DocumentEdit"); |
|
493 | 588 |
} |
494 | 589 |
|
495 | 590 |
@Override |
496 | 591 |
public void actionPerformed(ActionEvent e) { |
497 | 592 |
try { |
498 | 593 |
ScriptingUnit selectedItem = getLauncherSelectedScript(); |
499 |
if( selectedItem instanceof ScriptingBaseScript ) {
|
|
500 |
scriptEdit((ScriptingBaseScript)selectedItem); |
|
594 |
if (selectedItem instanceof ScriptingBaseScript) {
|
|
595 |
scriptEdit((ScriptingBaseScript) selectedItem);
|
|
501 | 596 |
} |
502 | 597 |
} catch (Exception e1) { |
503 |
logger.warn("Can't edit document",e1); |
|
598 |
logger.warn("Can't edit document", e1);
|
|
504 | 599 |
} |
505 | 600 |
} |
506 | 601 |
} |
507 | 602 |
|
508 |
private class RefreshTreeAction extends AbstractAction {
|
|
603 |
private class ProjectRefreshAction extends AbstractAction {
|
|
509 | 604 |
|
510 |
public RefreshTreeAction() { |
|
605 |
private static final long serialVersionUID = 1944121660002532563L; |
|
606 |
|
|
607 |
public ProjectRefreshAction() { |
|
511 | 608 |
super(uimanager.getTranslation("Refresh")); |
512 | 609 |
putValue(Action.SMALL_ICON, uimanager.getIcon("refresh")); |
513 | 610 |
putValue(Action.SHORT_DESCRIPTION, uimanager.getTranslation("Refresh_directories")); |
611 |
putValue(ACTION_COMMAND_KEY, "ProjectsRefresh"); |
|
514 | 612 |
} |
515 | 613 |
|
516 | 614 |
@Override |
Also available in: Unified diff