Merge lp:~krause/xabsleditor/projectsupport into lp:~xabsl/xabsleditor/trunk
- projectsupport
- Merge into trunk
Proposed by
Thomas Krause
Status: | Merged |
---|---|
Approved by: | Thomas Krause |
Approved revision: | 130 |
Merge reported by: | Thomas Krause |
Merged at revision: | not available |
Proposed branch: | lp:~krause/xabsleditor/projectsupport |
Merge into: | lp:~xabsl/xabsleditor/trunk |
Diff against target: |
1176 lines (+353/-199) 4 files modified
src/de/hu_berlin/informatik/ki/jxabsleditor/Main.form (+20/-2) src/de/hu_berlin/informatik/ki/jxabsleditor/Main.java (+319/-197) src/de/hu_berlin/informatik/ki/jxabsleditor/editorpanel/XEditorPanel.java (+7/-0) src/de/hu_berlin/informatik/ki/jxabsleditor/parser/XABSLContext.java (+7/-0) |
To merge this branch: | bzr merge lp:~krause/xabsleditor/projectsupport |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thomas Krause | Approve | ||
Review via email: mp+26701@code.launchpad.net |
Commit message
"project" support
Description of the change
To post a comment you must log in.
Revision history for this message
Thomas Krause (krause) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/de/hu_berlin/informatik/ki/jxabsleditor/Main.form' |
2 | --- src/de/hu_berlin/informatik/ki/jxabsleditor/Main.form 2010-06-03 11:13:15 +0000 |
3 | +++ src/de/hu_berlin/informatik/ki/jxabsleditor/Main.form 2010-06-03 13:49:21 +0000 |
4 | @@ -25,7 +25,7 @@ |
5 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newFileAction"/> |
6 | </Events> |
7 | </MenuItem> |
8 | - <MenuItem class="javax.swing.JMenuItem" name="miOpen"> |
9 | + <MenuItem class="javax.swing.JMenuItem" name="miOpenFile"> |
10 | <Properties> |
11 | <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> |
12 | <KeyStroke key="Ctrl+O"/> |
13 | @@ -34,7 +34,7 @@ |
14 | <Image iconType="3" name="/de/hu_berlin/informatik/ki/jxabsleditor/res/fileopen16.png"/> |
15 | </Property> |
16 | <Property name="mnemonic" type="int" value="79"/> |
17 | - <Property name="text" type="java.lang.String" value="Open"/> |
18 | + <Property name="text" type="java.lang.String" value="Open File"/> |
19 | </Properties> |
20 | <Events> |
21 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openFileAction"/> |
22 | @@ -186,6 +186,24 @@ |
23 | </MenuItem> |
24 | </SubComponents> |
25 | </Menu> |
26 | + <Menu class="javax.swing.JMenu" name="mProject"> |
27 | + <Properties> |
28 | + <Property name="mnemonic" type="int" value="112"/> |
29 | + <Property name="text" type="java.lang.String" value="Project"/> |
30 | + </Properties> |
31 | + <SubComponents> |
32 | + <MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> |
33 | + <Properties> |
34 | + <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor"> |
35 | + <FontInfo relative="true"> |
36 | + <Font component="jMenuItem1" italic="true" property="font" relativeSize="true" size="0"/> |
37 | + </FontInfo> |
38 | + </Property> |
39 | + <Property name="text" type="java.lang.String" value="empty"/> |
40 | + </Properties> |
41 | + </MenuItem> |
42 | + </SubComponents> |
43 | + </Menu> |
44 | <Menu class="javax.swing.JMenu" name="mHelp"> |
45 | <Properties> |
46 | <Property name="mnemonic" type="int" value="72"/> |
47 | |
48 | === modified file 'src/de/hu_berlin/informatik/ki/jxabsleditor/Main.java' |
49 | --- src/de/hu_berlin/informatik/ki/jxabsleditor/Main.java 2010-06-03 11:13:15 +0000 |
50 | +++ src/de/hu_berlin/informatik/ki/jxabsleditor/Main.java 2010-06-03 13:49:21 +0000 |
51 | @@ -35,8 +35,11 @@ |
52 | import java.awt.BorderLayout; |
53 | import java.awt.Component; |
54 | import java.awt.Image; |
55 | +import java.awt.MenuItem; |
56 | import java.awt.Point; |
57 | import java.awt.Toolkit; |
58 | +import java.awt.event.ActionEvent; |
59 | +import java.awt.event.ActionListener; |
60 | import java.awt.event.MouseEvent; |
61 | import java.awt.event.WindowAdapter; |
62 | import java.awt.event.WindowEvent; |
63 | @@ -46,12 +49,16 @@ |
64 | import java.io.IOException; |
65 | import java.io.OutputStream; |
66 | import java.io.StringReader; |
67 | -import java.util.ArrayList; |
68 | import java.util.HashMap; |
69 | +import java.util.Map; |
70 | import java.util.Properties; |
71 | +import java.util.TreeMap; |
72 | +import java.util.TreeSet; |
73 | import java.util.logging.Level; |
74 | import java.util.logging.Logger; |
75 | import javax.swing.JFileChooser; |
76 | +import javax.swing.JMenu; |
77 | +import javax.swing.JMenuItem; |
78 | import javax.swing.JOptionPane; |
79 | import javax.swing.UIManager; |
80 | import javax.swing.UnsupportedLookAndFeelException; |
81 | @@ -79,19 +86,12 @@ |
82 | private FileFilter dotFilter = new DotFileFilter(); |
83 | private FileFilter xabslFilter = new XABSLFileFilter(); |
84 | private FileFilter icFilter = new FileNameExtensionFilter("Intermediate code (*.dat)", "dat"); |
85 | - |
86 | private OptionVisualizer optionVisualizer; |
87 | - |
88 | private String defaultCompilationPath = null; |
89 | private boolean splitterManuallySet = false; |
90 | private boolean ignoreSplitterMovedEvent = false; |
91 | - |
92 | - private HashMap<String, File> optionPathMap; |
93 | - |
94 | - |
95 | - private XABSLContext globalXABSLContext = null; |
96 | - private ArrayList<XABSLStateCompetion> localOptionCompletions = null; |
97 | - |
98 | + /** Map from an file to it's agent file (means "project") */ |
99 | + private Map<File, File> file2Agent = new HashMap<File, File>(); |
100 | private FileDrop fileDrop = null; |
101 | |
102 | /** Creates new form Main */ |
103 | @@ -104,18 +104,21 @@ |
104 | UIManager.setLookAndFeel(new MetalLookAndFeel()); |
105 | //UIManager.setLookAndFeel(new NimbusLookAndFeel()); |
106 | } |
107 | - catch(UnsupportedLookAndFeelException ex) |
108 | + catch (UnsupportedLookAndFeelException ex) |
109 | { |
110 | Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
111 | } |
112 | |
113 | initComponents(); |
114 | |
115 | - this.fileDrop = new FileDrop(this.tabbedPanelEditor, new FileDrop.Listener() { |
116 | + this.fileDrop = new FileDrop(this.tabbedPanelEditor, new FileDrop.Listener() |
117 | + { |
118 | + |
119 | @Override |
120 | - public void filesDropped(File[] files) { |
121 | + public void filesDropped(File[] files) |
122 | + { |
123 | // open all the droppt files |
124 | - for(File file: files) |
125 | + for (File file : files) |
126 | { |
127 | openFile(file); |
128 | } |
129 | @@ -125,11 +128,14 @@ |
130 | //fileDrop.install(this.tabbedPanelEditor); |
131 | //fileDrop.setBorderHighlightingEnabled(true); |
132 | |
133 | - addWindowListener(new WindowAdapter() { |
134 | + addWindowListener(new WindowAdapter() |
135 | + { |
136 | + |
137 | @Override |
138 | - public void windowClosing(WindowEvent e) { |
139 | + public void windowClosing(WindowEvent e) |
140 | + { |
141 | // check if there are unsaved files |
142 | - for(Component component: tabbedPanelEditor.getComponents()) |
143 | + for (Component component : tabbedPanelEditor.getComponents()) |
144 | { |
145 | XEditorPanel editor = ((XEditorPanel) component); |
146 | // TODO: try to close the tabs |
147 | @@ -138,8 +144,8 @@ |
148 | System.exit(0); |
149 | } |
150 | }); |
151 | - |
152 | - |
153 | + |
154 | + |
155 | // icon |
156 | Image icon = Toolkit.getDefaultToolkit().getImage( |
157 | this.getClass().getResource("res/XabslEditor.png")); |
158 | @@ -152,12 +158,12 @@ |
159 | |
160 | try |
161 | { |
162 | - if(fConfig.exists() && fConfig.canRead()) |
163 | + if (fConfig.exists() && fConfig.canRead()) |
164 | { |
165 | configuration.load(new FileReader(fConfig)); |
166 | } |
167 | } |
168 | - catch(Exception ex) |
169 | + catch (Exception ex) |
170 | { |
171 | Tools.handleException(ex); |
172 | } |
173 | @@ -171,8 +177,6 @@ |
174 | |
175 | loadConfiguration(); |
176 | |
177 | - this.optionPathMap = new HashMap<String, File>(); |
178 | - |
179 | optionVisualizer = new OptionVisualizer(); |
180 | |
181 | optionVisualizer.setGraphMouseListener(new GraphMouseListener<XabslNode>() |
182 | @@ -182,19 +186,28 @@ |
183 | public void graphClicked(XabslNode v, MouseEvent me) |
184 | { |
185 | XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
186 | - if(editor != null && v.getType() == XabslNode.Type.State && v.getPosInText() > -1) |
187 | + if (editor != null && v.getType() == XabslNode.Type.State && v.getPosInText() > -1) |
188 | { |
189 | editor.setCarretPosition(v.getPosInText()); |
190 | } |
191 | - else if(v.getType() == XabslNode.Type.Option) |
192 | + else if (v.getType() == XabslNode.Type.Option) |
193 | { |
194 | String option = v.getName(); |
195 | - File file = optionPathMap.get(option); |
196 | + File file = null; |
197 | + if (editor.getXABSLContext() != null) |
198 | + { |
199 | + file = editor.getXABSLContext().getOptionPathMap().get(option); |
200 | + } |
201 | |
202 | - if(file != null) |
203 | + if (file != null) |
204 | { |
205 | openFile(file); |
206 | } |
207 | + else |
208 | + { |
209 | + JOptionPane.showMessageDialog(null, "Could not find the file for option " |
210 | + + option, "Option not found", JOptionPane.WARNING_MESSAGE); |
211 | + } |
212 | } |
213 | } |
214 | |
215 | @@ -224,95 +237,161 @@ |
216 | |
217 | private void refreshGraph() |
218 | { |
219 | - if(tabbedPanelEditor.getSelectedComponent() == null) |
220 | + if (tabbedPanelEditor.getSelectedComponent() == null) |
221 | + { |
222 | return; |
223 | - |
224 | - String text = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()).getText(); |
225 | + } |
226 | + |
227 | + XEditorPanel selectedEditorPanel = (XEditorPanel) tabbedPanelEditor.getSelectedComponent(); |
228 | + String text = selectedEditorPanel.getText(); |
229 | |
230 | // Option |
231 | - XParser p = new XParser(this.globalXABSLContext); |
232 | + XParser p = new XParser(selectedEditorPanel.getXABSLContext()); |
233 | p.parse(new StringReader(text)); |
234 | optionVisualizer.setGraph(p.getOptionGraph()); |
235 | |
236 | // refresh autocompetion |
237 | DefaultCompletionProvider completionProvider = new DefaultCompletionProvider(); |
238 | |
239 | - for(State state: p.getStateMap().values()) |
240 | + for (State state : p.getStateMap().values()) |
241 | { |
242 | completionProvider.addCompletion( |
243 | - new XABSLStateCompetion(completionProvider, state.name)); |
244 | + new XABSLStateCompetion(completionProvider, state.name)); |
245 | }//end for |
246 | |
247 | - ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()) |
248 | - .setLocalCompletionProvider(completionProvider); |
249 | + ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()).setLocalCompletionProvider(completionProvider); |
250 | }//end refreshGraph |
251 | |
252 | - private void loadXABSLContext(File folder) |
253 | - { |
254 | - if(this.globalXABSLContext == null) |
255 | - { |
256 | - this.globalXABSLContext = new XABSLContext(); |
257 | + /** Reconstruct the Projects menu entry */ |
258 | + private void updateProjectMenu() |
259 | + { |
260 | + mProject.removeAll(); |
261 | + |
262 | + // get all opened agents |
263 | + TreeSet<File> foundAgents = new TreeSet<File>(); |
264 | + for (int i = 0; i < tabbedPanelEditor.getTabCount(); i++) |
265 | + { |
266 | + XEditorPanel p = (XEditorPanel) tabbedPanelEditor.getComponentAt(i); |
267 | + File agentFile = file2Agent.get(p.getFile()); |
268 | + if (agentFile != null && !foundAgents.contains(agentFile)) |
269 | + { |
270 | + |
271 | + JMenu miAgent = new JMenu(agentFile.getParentFile().getName() + "/" + agentFile.getName()); |
272 | + XABSLContext context = p.getXABSLContext(); |
273 | + |
274 | + final Map<String, File> optionPathMap = context.getOptionPathMap(); |
275 | + Map<String,JMenu> menuSubs = new TreeMap<String, JMenu>(); |
276 | + |
277 | + for (final String option : optionPathMap.keySet()) |
278 | + { |
279 | + String subCategory = option.substring(0,1).toUpperCase(); |
280 | + if(menuSubs.get(subCategory) == null) |
281 | + { |
282 | + menuSubs.put(subCategory, new JMenu(subCategory)); |
283 | + } |
284 | + |
285 | + JMenuItem miOptionOpener = new JMenuItem(option); |
286 | + menuSubs.get(subCategory).add(miOptionOpener); |
287 | + |
288 | + miOptionOpener.addActionListener(new ActionListener() |
289 | + { |
290 | + |
291 | + @Override |
292 | + public void actionPerformed(ActionEvent e) |
293 | + { |
294 | + File f = optionPathMap.get(option); |
295 | + openFile(f); |
296 | + } |
297 | + }); |
298 | + } |
299 | + |
300 | + for(String s : menuSubs.keySet()) |
301 | + { |
302 | + miAgent.add(menuSubs.get(s)); |
303 | + } |
304 | + |
305 | + mProject.add(miAgent); |
306 | + |
307 | + foundAgents.add(agentFile); |
308 | + } |
309 | + } |
310 | + } |
311 | + |
312 | + private XABSLContext loadXABSLContext(File folder, XABSLContext context) |
313 | + { |
314 | + if (context == null) |
315 | + { |
316 | + context = new XABSLContext(); |
317 | } |
318 | |
319 | File[] fileList = folder.listFiles(); |
320 | - for(File file : fileList) |
321 | + for (File file : fileList) |
322 | { |
323 | - if(file.isDirectory()) |
324 | + if (file.isDirectory()) |
325 | { |
326 | - loadXABSLContext(file); |
327 | + loadXABSLContext(file, context); |
328 | } |
329 | - else if(file.getName().toLowerCase().endsWith(".xabsl")) |
330 | + else if (file.getName().toLowerCase().endsWith(".xabsl")) |
331 | { |
332 | - // parse symbols file |
333 | - try{ |
334 | + String name = file.getName().toLowerCase().replace(".xabsl", ""); |
335 | + context.getOptionPathMap().put(name, file); |
336 | + |
337 | + // parse XABSL file |
338 | + try |
339 | + { |
340 | //System.out.println("parse: " + file.getName()); // debug stuff |
341 | |
342 | - XParser p = new XParser(this.globalXABSLContext); |
343 | + XParser p = new XParser(context); |
344 | p.parse(new FileReader(file), file.getAbsolutePath()); |
345 | - |
346 | - }catch(Exception e) |
347 | + |
348 | + } |
349 | + catch (Exception e) |
350 | { |
351 | - System.err.println("Couldn't read the symbols file " + file.getAbsolutePath()); |
352 | + System.err.println("Couldn't read the XABSL file " + file.getAbsolutePath()); |
353 | } |
354 | } |
355 | }//end for |
356 | + |
357 | + return context; |
358 | }//end loadSymbolsTable |
359 | |
360 | - |
361 | - private DefaultCompletionProvider createCompletitionProvider() |
362 | + private DefaultCompletionProvider createCompletitionProvider(XABSLContext context) |
363 | { |
364 | DefaultCompletionProvider provider = new DefaultCompletionProvider() |
365 | { |
366 | + |
367 | @Override |
368 | - protected boolean isValidChar(char ch) { |
369 | + protected boolean isValidChar(char ch) |
370 | + { |
371 | return super.isValidChar(ch) || ch == '.'; |
372 | } |
373 | }; |
374 | |
375 | provider.setParameterizedCompletionParams('(', ", ", ')'); |
376 | |
377 | - if(this.globalXABSLContext != null) |
378 | + if (context != null) |
379 | { |
380 | - for(XABSLContext.XABSLSymbol symbol: this.globalXABSLContext.getSymbolMap().values()) |
381 | + for (XABSLContext.XABSLSymbol symbol : context.getSymbolMap().values()) |
382 | { |
383 | - if(symbol.getParameter().size() == 0) |
384 | + if (symbol.getParameter().size() == 0) |
385 | { |
386 | provider.addCompletion(new XABSLSymbolSimpleCompletion(provider, symbol)); |
387 | - }else |
388 | + } |
389 | + else |
390 | { |
391 | provider.addCompletion(new XABSLSymbolCompletion(provider, symbol)); |
392 | } |
393 | //System.out.println(symbol); // debug stuff |
394 | }//end for |
395 | |
396 | - for(XABSLContext.XABSLOption option: this.globalXABSLContext.getOptionMap().values()) |
397 | + for (XABSLContext.XABSLOption option : context.getOptionMap().values()) |
398 | { |
399 | provider.addCompletion(new XABSLOptionCompletion(provider, option)); |
400 | }//end for |
401 | |
402 | - for(XABSLContext.XABSLEnum xabslEnum: this.globalXABSLContext.getEnumMap().values()) |
403 | + for (XABSLContext.XABSLEnum xabslEnum : context.getEnumMap().values()) |
404 | { |
405 | - for(String param: xabslEnum.getElements()) |
406 | + for (String param : xabslEnum.getElements()) |
407 | { |
408 | provider.addCompletion(new XABSLEnumCompletion(provider, xabslEnum.name, param)); |
409 | }//end for |
410 | @@ -325,40 +404,22 @@ |
411 | "state <name> {\n\tdecision {\n\t}\n\taction {\n\t}\n}", |
412 | "behavior state", |
413 | "behavior state")); |
414 | - |
415 | + |
416 | return provider; |
417 | }//end createCompletitionProvider |
418 | |
419 | - private void createOptionList(File folder) |
420 | - { |
421 | - File[] fileList = folder.listFiles(); |
422 | - for(File file : fileList) |
423 | - { |
424 | - if(file.isDirectory()) |
425 | - { |
426 | - createOptionList(file); |
427 | - } |
428 | - else if(file.getName().toLowerCase().endsWith(".xabsl")) |
429 | - { |
430 | - String name = file.getName().toLowerCase().replace(".xabsl", ""); |
431 | - optionPathMap.put(name, file); |
432 | - //System.out.println(name + " : " + file.getAbsolutePath()); |
433 | - } |
434 | - }//end for |
435 | - }//end createOptionList |
436 | - |
437 | private void loadConfiguration() |
438 | { |
439 | - if(configuration.containsKey("lastOpenedFolder")) |
440 | + if (configuration.containsKey("lastOpenedFolder")) |
441 | { |
442 | fileChooser.setCurrentDirectory( |
443 | new File(configuration.getProperty("lastOpenedFolder"))); |
444 | } |
445 | |
446 | - if(configuration.containsKey(OptionsDialog.DEFAULT_COMPILATION_PATH)) |
447 | + if (configuration.containsKey(OptionsDialog.DEFAULT_COMPILATION_PATH)) |
448 | { |
449 | String path = configuration.getProperty(OptionsDialog.DEFAULT_COMPILATION_PATH); |
450 | - if(new File(path).exists()) |
451 | + if (new File(path).exists()) |
452 | { |
453 | this.defaultCompilationPath = path; |
454 | } |
455 | @@ -390,7 +451,7 @@ |
456 | mbMain = new javax.swing.JMenuBar(); |
457 | mFile = new javax.swing.JMenu(); |
458 | miNew = new javax.swing.JMenuItem(); |
459 | - miOpen = new javax.swing.JMenuItem(); |
460 | + miOpenFile = new javax.swing.JMenuItem(); |
461 | miClose = new javax.swing.JMenuItem(); |
462 | jSeparator1 = new javax.swing.JSeparator(); |
463 | miSave = new javax.swing.JMenuItem(); |
464 | @@ -405,6 +466,8 @@ |
465 | miRefreshGraph = new javax.swing.JMenuItem(); |
466 | jSeparator3 = new javax.swing.JSeparator(); |
467 | miOption = new javax.swing.JMenuItem(); |
468 | + mProject = new javax.swing.JMenu(); |
469 | + jMenuItem1 = new javax.swing.JMenuItem(); |
470 | mHelp = new javax.swing.JMenu(); |
471 | miInfo = new javax.swing.JMenuItem(); |
472 | |
473 | @@ -441,11 +504,11 @@ |
474 | panelCompiler.setLayout(panelCompilerLayout); |
475 | panelCompilerLayout.setHorizontalGroup( |
476 | panelCompilerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
477 | - .addComponent(scrollPaneCompilerOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE) |
478 | + .addComponent(scrollPaneCompilerOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE) |
479 | ); |
480 | panelCompilerLayout.setVerticalGroup( |
481 | panelCompilerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
482 | - .addComponent(scrollPaneCompilerOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) |
483 | + .addComponent(scrollPaneCompilerOutput, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE) |
484 | ); |
485 | |
486 | tabbedPanelView.addTab("Compiler", null, panelCompiler, "The status and output of the compiler."); |
487 | @@ -524,16 +587,16 @@ |
488 | }); |
489 | mFile.add(miNew); |
490 | |
491 | - miOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); |
492 | - miOpen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/de/hu_berlin/informatik/ki/jxabsleditor/res/fileopen16.png"))); // NOI18N |
493 | - miOpen.setMnemonic('O'); |
494 | - miOpen.setText("Open"); |
495 | - miOpen.addActionListener(new java.awt.event.ActionListener() { |
496 | + miOpenFile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); |
497 | + miOpenFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/de/hu_berlin/informatik/ki/jxabsleditor/res/fileopen16.png"))); // NOI18N |
498 | + miOpenFile.setMnemonic('O'); |
499 | + miOpenFile.setText("Open File"); |
500 | + miOpenFile.addActionListener(new java.awt.event.ActionListener() { |
501 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
502 | openFileAction(evt); |
503 | } |
504 | }); |
505 | - mFile.add(miOpen); |
506 | + mFile.add(miOpenFile); |
507 | |
508 | miClose.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK)); |
509 | miClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/de/hu_berlin/informatik/ki/jxabsleditor/res/fileclose16.png"))); // NOI18N |
510 | @@ -642,6 +705,15 @@ |
511 | |
512 | mbMain.add(mEdit); |
513 | |
514 | + mProject.setMnemonic('p'); |
515 | + mProject.setText("Project"); |
516 | + |
517 | + jMenuItem1.setFont(jMenuItem1.getFont().deriveFont((jMenuItem1.getFont().getStyle() | java.awt.Font.ITALIC))); |
518 | + jMenuItem1.setText("empty"); |
519 | + mProject.add(jMenuItem1); |
520 | + |
521 | + mbMain.add(mProject); |
522 | + |
523 | mHelp.setMnemonic('H'); |
524 | mHelp.setText("Help"); |
525 | |
526 | @@ -665,7 +737,7 @@ |
527 | private void newFileAction(java.awt.event.ActionEvent evt)//GEN-FIRST:event_newFileAction |
528 | {//GEN-HEADEREND:event_newFileAction |
529 | // create new tab |
530 | - createDocumentTab(null); |
531 | + createDocumentTab(null, null); |
532 | }//GEN-LAST:event_newFileAction |
533 | |
534 | private void miCloseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_miCloseActionPerformed |
535 | @@ -673,7 +745,7 @@ |
536 | // close current tab |
537 | |
538 | XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
539 | - if(!editor.isChanged()) |
540 | + if (!editor.isChanged()) |
541 | { |
542 | tabbedPanelEditor.remove(editor); |
543 | return; |
544 | @@ -682,11 +754,11 @@ |
545 | int result = JOptionPane.showConfirmDialog(this, "Save changes?", "File was modified.", |
546 | JOptionPane.YES_NO_CANCEL_OPTION); |
547 | |
548 | - if(result == JOptionPane.CANCEL_OPTION) |
549 | + if (result == JOptionPane.CANCEL_OPTION) |
550 | { |
551 | return; |
552 | } |
553 | - else if(result == JOptionPane.NO_OPTION) |
554 | + else if (result == JOptionPane.NO_OPTION) |
555 | { |
556 | tabbedPanelEditor.remove(editor); |
557 | return; |
558 | @@ -697,25 +769,25 @@ |
559 | try |
560 | { |
561 | File file = saveStringToFile(selectedFile, text); |
562 | - if(file != null) |
563 | + if (file != null) |
564 | { |
565 | editor.setChanged(false); |
566 | editor.setFile(file); |
567 | tabbedPanelEditor.setTitleAt(tabbedPanelEditor.getSelectedIndex(), file.getName()); |
568 | }//end if |
569 | } |
570 | - catch(IOException e) |
571 | + catch (IOException e) |
572 | { |
573 | JOptionPane.showMessageDialog(this, |
574 | e.toString(), "The file could not be written.", JOptionPane.ERROR_MESSAGE); |
575 | } |
576 | - catch(Exception e) |
577 | + catch (Exception e) |
578 | { |
579 | JOptionPane.showMessageDialog(this, |
580 | e.toString(), "Could not save the file.", JOptionPane.ERROR_MESSAGE); |
581 | }//end catch |
582 | |
583 | - if(!editor.isChanged()) |
584 | + if (!editor.isChanged()) |
585 | { |
586 | tabbedPanelEditor.remove(editor); |
587 | }//end if |
588 | @@ -731,7 +803,7 @@ |
589 | try |
590 | { |
591 | File file = saveStringToFile(selectedFile, text); |
592 | - if(file != null) |
593 | + if (file != null) |
594 | { |
595 | editor.setChanged(false); |
596 | editor.setFile(file); |
597 | @@ -739,12 +811,12 @@ |
598 | refreshGraph(); |
599 | } |
600 | } |
601 | - catch(IOException e) |
602 | + catch (IOException e) |
603 | { |
604 | JOptionPane.showMessageDialog(this, |
605 | e.toString(), "The file could not be written.", JOptionPane.ERROR_MESSAGE); |
606 | } |
607 | - catch(Exception e) |
608 | + catch (Exception e) |
609 | { |
610 | JOptionPane.showMessageDialog(this, |
611 | e.toString(), "Could not save the file.", JOptionPane.ERROR_MESSAGE); |
612 | @@ -766,7 +838,7 @@ |
613 | { |
614 | // save as a new file |
615 | File file = saveStringToFile(null, text); |
616 | - if(file != null) |
617 | + if (file != null) |
618 | { |
619 | int idx = tabbedPanelEditor.getSelectedIndex(); |
620 | editor.setChanged(false); |
621 | @@ -775,12 +847,12 @@ |
622 | tabbedPanelEditor.setToolTipTextAt(idx, file.getAbsolutePath()); |
623 | } |
624 | } |
625 | - catch(IOException e) |
626 | + catch (IOException e) |
627 | { |
628 | JOptionPane.showMessageDialog(this, |
629 | e.toString(), "The file could not be written.", JOptionPane.ERROR_MESSAGE); |
630 | } |
631 | - catch(Exception e) |
632 | + catch (Exception e) |
633 | { |
634 | JOptionPane.showMessageDialog(this, |
635 | e.toString(), "Could not save the file.", JOptionPane.ERROR_MESSAGE); |
636 | @@ -818,18 +890,18 @@ |
637 | |
638 | fileChooser.setFileFilter(xabslFilter); |
639 | int result = fileChooser.showOpenDialog(this); |
640 | - if(JFileChooser.APPROVE_OPTION != result) |
641 | + if (JFileChooser.APPROVE_OPTION != result) |
642 | { |
643 | return; |
644 | } |
645 | |
646 | File selectedFile = fileChooser.getSelectedFile(); |
647 | - if(selectedFile == null) |
648 | + if (selectedFile == null) |
649 | { |
650 | return; |
651 | } |
652 | |
653 | - if(!selectedFile.exists()) |
654 | + if (!selectedFile.exists()) |
655 | { |
656 | JOptionPane.showMessageDialog(this, |
657 | "File " + selectedFile.getAbsolutePath() + " doesn't exist.", "Error", |
658 | @@ -843,18 +915,22 @@ |
659 | |
660 | public XEditorPanel openFile(File selectedFile) |
661 | { |
662 | - if(selectedFile == null) return null; |
663 | - |
664 | + if (selectedFile == null) |
665 | + { |
666 | + return null; |
667 | + } |
668 | + |
669 | + |
670 | // test if the file is allready opened |
671 | - for(int i = 0; i < tabbedPanelEditor.getTabCount(); i++) |
672 | + for (int i = 0; i < tabbedPanelEditor.getTabCount(); i++) |
673 | { |
674 | Component c = tabbedPanelEditor.getComponentAt(i); |
675 | - if(c instanceof XEditorPanel) |
676 | + if (c instanceof XEditorPanel) |
677 | { |
678 | XEditorPanel editor = (XEditorPanel) c; |
679 | - if( c != null && |
680 | - editor.getFile() != null && |
681 | - selectedFile.compareTo(editor.getFile()) == 0) |
682 | + if (c != null |
683 | + && editor.getFile() != null |
684 | + && selectedFile.compareTo(editor.getFile()) == 0) |
685 | { |
686 | tabbedPanelEditor.setSelectedComponent(c); |
687 | return editor; |
688 | @@ -866,68 +942,68 @@ |
689 | fileChooser.getCurrentDirectory().getAbsolutePath()); |
690 | saveConfiguration(); |
691 | |
692 | - // TODO: make it better |
693 | - this.optionPathMap.clear(); |
694 | File agentsFile = Tools.getAgentFileForOption(selectedFile); |
695 | |
696 | - // needed for function-links |
697 | - createOptionList(agentsFile.getParentFile()); |
698 | - |
699 | - // needed by autocomletition |
700 | - if(this.globalXABSLContext == null) |
701 | - loadXABSLContext(agentsFile.getParentFile()); |
702 | - |
703 | - return createDocumentTab(selectedFile); |
704 | + if (agentsFile != null) |
705 | + { |
706 | + file2Agent.put(selectedFile, agentsFile); |
707 | + XABSLContext newContext = loadXABSLContext(agentsFile.getParentFile(), null); |
708 | + |
709 | + return createDocumentTab(selectedFile, newContext); |
710 | + } |
711 | + else |
712 | + { |
713 | + return null; |
714 | + } |
715 | }//end openFile |
716 | |
717 | - |
718 | private void compileAction(java.awt.event.ActionEvent evt)//GEN-FIRST:event_compileAction |
719 | {//GEN-HEADEREND:event_compileAction |
720 | - if(tabbedPanelEditor.getSelectedComponent() != null) |
721 | + if (tabbedPanelEditor.getSelectedComponent() != null) |
722 | { |
723 | |
724 | - XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
725 | - File optionFile = editor.getFile(); |
726 | - |
727 | - File fout = null; |
728 | - |
729 | - if(defaultCompilationPath == null) |
730 | - { |
731 | - fileChooser.setFileFilter(icFilter); |
732 | - int result = fileChooser.showSaveDialog(this); |
733 | - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); |
734 | - if(result == JFileChooser.APPROVE_OPTION) |
735 | - { |
736 | - fout = fileChooser.getSelectedFile(); |
737 | - } |
738 | - } |
739 | - else |
740 | - { |
741 | - fout = new File(defaultCompilationPath + "/behavior-ic.dat"); |
742 | - } |
743 | - |
744 | - if(fout == null) |
745 | - { |
746 | - JOptionPane.showMessageDialog(this, "No file selected"); |
747 | + XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
748 | + File optionFile = editor.getFile(); |
749 | + |
750 | + File fout = null; |
751 | + |
752 | + if (defaultCompilationPath == null) |
753 | + { |
754 | + fileChooser.setFileFilter(icFilter); |
755 | + int result = fileChooser.showSaveDialog(this); |
756 | + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); |
757 | + if (result == JFileChooser.APPROVE_OPTION) |
758 | + { |
759 | + fout = fileChooser.getSelectedFile(); |
760 | + } |
761 | + } |
762 | + else |
763 | + { |
764 | + fout = new File(defaultCompilationPath + "/behavior-ic.dat"); |
765 | + } |
766 | + |
767 | + if (fout == null) |
768 | + { |
769 | + JOptionPane.showMessageDialog(this, "No file selected"); |
770 | + return; |
771 | + } |
772 | + else if (fout.exists()) |
773 | + { |
774 | + if (!fout.delete()) |
775 | + { |
776 | + JOptionPane.showMessageDialog(this, "Can not overwrite the file " |
777 | + + fout.getAbsolutePath()); |
778 | return; |
779 | } |
780 | - else if(fout.exists()) |
781 | - { |
782 | - if(!fout.delete()) |
783 | - { |
784 | - JOptionPane.showMessageDialog(this, "Can not overwrite the file " + |
785 | - fout.getAbsolutePath()); |
786 | - return; |
787 | - } |
788 | - } |
789 | + } |
790 | |
791 | - CompilerDialog frame = new CompilerDialog(this, true, optionFile, fout, |
792 | - this, configuration); |
793 | - frame.setVisible(true); |
794 | + CompilerDialog frame = new CompilerDialog(this, true, optionFile, fout, |
795 | + this, configuration); |
796 | + frame.setVisible(true); |
797 | } |
798 | else |
799 | { |
800 | - JOptionPane.showMessageDialog(this, |
801 | + JOptionPane.showMessageDialog(this, |
802 | "Please open an *.xabsl file first before compiling", "Error", |
803 | JOptionPane.ERROR_MESSAGE); |
804 | } |
805 | @@ -936,7 +1012,7 @@ |
806 | private void miSearchActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_miSearchActionPerformed |
807 | {//GEN-HEADEREND:event_miSearchActionPerformed |
808 | |
809 | - if(tabbedPanelEditor.getSelectedComponent() != null) |
810 | + if (tabbedPanelEditor.getSelectedComponent() != null) |
811 | { |
812 | XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
813 | editor.getSearchPanel().setVisible(false); |
814 | @@ -947,7 +1023,7 @@ |
815 | private void formComponentResized(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentResized |
816 | {//GEN-HEADEREND:event_formComponentResized |
817 | |
818 | - if(!splitterManuallySet) |
819 | + if (!splitterManuallySet) |
820 | { |
821 | // position splitter in the middle |
822 | ignoreSplitterMovedEvent = true; |
823 | @@ -959,9 +1035,9 @@ |
824 | private void jSplitPanePropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_jSplitPanePropertyChange |
825 | {//GEN-HEADEREND:event_jSplitPanePropertyChange |
826 | |
827 | - if(evt.getPropertyName().equals("dividerLocation")) |
828 | + if (evt.getPropertyName().equals("dividerLocation")) |
829 | { |
830 | - if(!ignoreSplitterMovedEvent) |
831 | + if (!ignoreSplitterMovedEvent) |
832 | { |
833 | splitterManuallySet = true; |
834 | } |
835 | @@ -971,7 +1047,7 @@ |
836 | |
837 | private void miSearchProjectActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_miSearchProjectActionPerformed |
838 | {//GEN-HEADEREND:event_miSearchProjectActionPerformed |
839 | - |
840 | + |
841 | searchInProjectDialog.setVisible(true); |
842 | |
843 | }//GEN-LAST:event_miSearchProjectActionPerformed |
844 | @@ -983,6 +1059,7 @@ |
845 | { |
846 | java.awt.EventQueue.invokeLater(new Runnable() |
847 | { |
848 | + |
849 | @Override |
850 | public void run() |
851 | { |
852 | @@ -991,13 +1068,13 @@ |
853 | }); |
854 | }//end main |
855 | |
856 | - private XEditorPanel createDocumentTab(File file) |
857 | + private XEditorPanel createDocumentTab(File file, XABSLContext context) |
858 | { |
859 | try |
860 | { |
861 | // create new document |
862 | XEditorPanel editor = null; |
863 | - if(file == null) |
864 | + if (file == null) |
865 | { |
866 | editor = new XEditorPanel(); |
867 | int tabCount = tabbedPanelEditor.getTabCount(); |
868 | @@ -1012,19 +1089,33 @@ |
869 | tabbedPanelEditor.addTab(editor.getFile().getName(), null, editor, file.getAbsolutePath()); |
870 | } |
871 | |
872 | - editor.setXABSLContext(this.globalXABSLContext); |
873 | - editor.setCompletionProvider(createCompletitionProvider()); |
874 | + editor.setXABSLContext(context); |
875 | + editor.setCompletionProvider(createCompletitionProvider(editor.getXABSLContext())); |
876 | |
877 | tabbedPanelEditor.setSelectedComponent(editor); |
878 | |
879 | + |
880 | + // update the other openend editors |
881 | + for (int i = 0; i < tabbedPanelEditor.getTabCount(); i++) |
882 | + { |
883 | + XEditorPanel p = (XEditorPanel) tabbedPanelEditor.getTabComponentAt(i); |
884 | + if (p != editor && p != null) |
885 | + { |
886 | + p.setXABSLContext(context); |
887 | + } |
888 | + } |
889 | + |
890 | + updateProjectMenu(); |
891 | + |
892 | editor.addDocumentChangedListener(new DocumentChangedListener() |
893 | { |
894 | + |
895 | @Override |
896 | public void documentChanged(XEditorPanel document) |
897 | { |
898 | tabbedPanelEditor.setSelectedComponent(document); |
899 | int i = tabbedPanelEditor.getSelectedIndex(); |
900 | - if(document.isChanged()) |
901 | + if (document.isChanged()) |
902 | { |
903 | String title = tabbedPanelEditor.getTitleAt(i) + " *"; |
904 | tabbedPanelEditor.setTitleAt(i, title); |
905 | @@ -1032,52 +1123,72 @@ |
906 | } |
907 | }); |
908 | |
909 | + final XEditorPanel editorFinal = editor; |
910 | editor.addHyperlinkListener(new HyperlinkListener() |
911 | { |
912 | + |
913 | @Override |
914 | public void hyperlinkUpdate(HyperlinkEvent e) |
915 | { |
916 | String element = e.getDescription(); |
917 | element = element.replace("no protocol: ", ""); |
918 | - |
919 | - File file = optionPathMap.get(element); |
920 | + |
921 | + |
922 | + File file = null; |
923 | + if (editorFinal.getXABSLContext() != null) |
924 | + { |
925 | + file = editorFinal.getXABSLContext().getOptionPathMap().get(element); |
926 | + } |
927 | int position = 0; |
928 | |
929 | // try to open symbol |
930 | - if(file == null) |
931 | + boolean symbolWasFound = false; |
932 | + |
933 | + if (file == null) |
934 | { |
935 | - XABSLSymbol symbol = globalXABSLContext.getSymbolMap().get(element); |
936 | - if(symbol != null && symbol.getDeclarationSource() != null) |
937 | + XABSLSymbol symbol = editorFinal.getXABSLContext().getSymbolMap().get(element); |
938 | + if (symbol != null && symbol.getDeclarationSource() != null) |
939 | { |
940 | file = new File(symbol.getDeclarationSource().fileName); |
941 | position = symbol.getDeclarationSource().offset; |
942 | + symbolWasFound = true; |
943 | } |
944 | }//end if |
945 | |
946 | - if(file == null) |
947 | + if (file == null) |
948 | { |
949 | XEditorPanel editor = ((XEditorPanel) tabbedPanelEditor.getSelectedComponent()); |
950 | State state = editor.getStateMap().get(element); |
951 | - if(state != null) |
952 | + if (state != null) |
953 | { |
954 | editor.setCarretPosition(state.offset); |
955 | + symbolWasFound = true; |
956 | } |
957 | }//end if |
958 | |
959 | - if(file != null) |
960 | + if (file != null) |
961 | { |
962 | XEditorPanel editor = openFile(file); |
963 | - if(editor != null) |
964 | + if (editor != null) |
965 | + { |
966 | editor.setCarretPosition(position); |
967 | - }//end if |
968 | - |
969 | + } |
970 | + } |
971 | + |
972 | + if (file == null && !symbolWasFound) |
973 | + { |
974 | + JOptionPane.showMessageDialog(null, "Could not find the file for option, symbol or state", |
975 | + "Not found", JOptionPane.WARNING_MESSAGE); |
976 | + } |
977 | + //end if |
978 | + |
979 | //System.out.println(option); |
980 | } |
981 | }); |
982 | |
983 | return editor; |
984 | } |
985 | - catch(Exception e) |
986 | + catch (Exception e) |
987 | { |
988 | JOptionPane.showMessageDialog(this, |
989 | e.toString(), "The file could not be read.", JOptionPane.ERROR_MESSAGE); |
990 | @@ -1090,11 +1201,11 @@ |
991 | |
992 | private File saveStringToFile(File selectedFile, String text) throws Exception |
993 | { |
994 | - if(selectedFile == null) |
995 | + if (selectedFile == null) |
996 | { |
997 | fileChooser.setFileFilter(xabslFilter); |
998 | int result = fileChooser.showSaveDialog(this); |
999 | - if(JFileChooser.APPROVE_OPTION != result) |
1000 | + if (JFileChooser.APPROVE_OPTION != result) |
1001 | { |
1002 | return null; |
1003 | } |
1004 | @@ -1102,7 +1213,7 @@ |
1005 | selectedFile = Tools.validateFileName(selectedFile, fileChooser.getFileFilter()); |
1006 | } |
1007 | |
1008 | - if(selectedFile == null) |
1009 | + if (selectedFile == null) |
1010 | { |
1011 | return null; |
1012 | } |
1013 | @@ -1114,15 +1225,24 @@ |
1014 | return selectedFile; |
1015 | }//end saveStringToFile |
1016 | |
1017 | - public HashMap<String, File> getOptionPathMap() |
1018 | + public Map<String, File> getOptionPathMap() |
1019 | { |
1020 | - return optionPathMap; |
1021 | + XEditorPanel selectedEditorPanel = (XEditorPanel) tabbedPanelEditor.getSelectedComponent(); |
1022 | + if (selectedEditorPanel.getXABSLContext() != null) |
1023 | + { |
1024 | + return selectedEditorPanel.getXABSLContext().getOptionPathMap(); |
1025 | + } |
1026 | + else |
1027 | + { |
1028 | + return null; |
1029 | + } |
1030 | } |
1031 | // Variables declaration - do not modify//GEN-BEGIN:variables |
1032 | private javax.swing.JButton btCompile; |
1033 | private javax.swing.JButton btNew; |
1034 | private javax.swing.JButton btOpen; |
1035 | private javax.swing.JButton btSave; |
1036 | + private javax.swing.JMenuItem jMenuItem1; |
1037 | private javax.swing.JSeparator jSeparator1; |
1038 | private javax.swing.JSeparator jSeparator2; |
1039 | private javax.swing.JSeparator jSeparator3; |
1040 | @@ -1131,12 +1251,13 @@ |
1041 | private javax.swing.JMenu mEdit; |
1042 | private javax.swing.JMenu mFile; |
1043 | private javax.swing.JMenu mHelp; |
1044 | + private javax.swing.JMenu mProject; |
1045 | private javax.swing.JMenuBar mbMain; |
1046 | private javax.swing.JMenuItem miClose; |
1047 | private javax.swing.JMenuItem miCompile; |
1048 | private javax.swing.JMenuItem miInfo; |
1049 | private javax.swing.JMenuItem miNew; |
1050 | - private javax.swing.JMenuItem miOpen; |
1051 | + private javax.swing.JMenuItem miOpenFile; |
1052 | private javax.swing.JMenuItem miOption; |
1053 | private javax.swing.JMenuItem miQuit; |
1054 | private javax.swing.JMenuItem miRefreshGraph; |
1055 | @@ -1158,7 +1279,7 @@ |
1056 | public void compilationFinished(CompileResult result) |
1057 | { |
1058 | txtCompilerOutput.setText(result.messages); |
1059 | - if(result.errors || result.warnings) |
1060 | + if (result.errors || result.warnings) |
1061 | { |
1062 | tabbedPanelView.setSelectedIndex(tabbedPanelView.getTabCount() - 1); |
1063 | } |
1064 | @@ -1170,7 +1291,7 @@ |
1065 | { |
1066 | configuration.store(new FileWriter(fConfig), "JXabslEditor configuration"); |
1067 | } |
1068 | - catch(IOException ex) |
1069 | + catch (IOException ex) |
1070 | { |
1071 | Tools.handleException(ex); |
1072 | } |
1073 | @@ -1178,10 +1299,11 @@ |
1074 | |
1075 | private class XABSLFileFilter extends javax.swing.filechooser.FileFilter |
1076 | { |
1077 | + |
1078 | @Override |
1079 | public boolean accept(File file) |
1080 | { |
1081 | - if(file.isDirectory()) |
1082 | + if (file.isDirectory()) |
1083 | { |
1084 | return true; |
1085 | } |
1086 | @@ -1205,10 +1327,11 @@ |
1087 | |
1088 | private class DotFileFilter extends javax.swing.filechooser.FileFilter |
1089 | { |
1090 | + |
1091 | @Override |
1092 | public boolean accept(File file) |
1093 | { |
1094 | - if(file.isDirectory()) |
1095 | + if (file.isDirectory()) |
1096 | { |
1097 | return true; |
1098 | } |
1099 | @@ -1229,7 +1352,6 @@ |
1100 | } |
1101 | }//end class DotFileFilter |
1102 | |
1103 | - |
1104 | class XABSLErrorOutputStream extends OutputStream |
1105 | { |
1106 | |
1107 | @@ -1255,7 +1377,7 @@ |
1108 | String str = messageBuffer.toString(); |
1109 | str = str.replaceAll("\\(|(\\) : )|,", ";"); |
1110 | String[] splStr = str.split(";"); |
1111 | - if(splStr.length == 4) |
1112 | + if (splStr.length == 4) |
1113 | { |
1114 | fileName = splStr[0]; |
1115 | row = Integer.parseInt(splStr[1]); |
1116 | |
1117 | === modified file 'src/de/hu_berlin/informatik/ki/jxabsleditor/editorpanel/XEditorPanel.java' |
1118 | --- src/de/hu_berlin/informatik/ki/jxabsleditor/editorpanel/XEditorPanel.java 2010-05-30 16:09:14 +0000 |
1119 | +++ src/de/hu_berlin/informatik/ki/jxabsleditor/editorpanel/XEditorPanel.java 2010-06-03 13:49:21 +0000 |
1120 | @@ -61,6 +61,7 @@ |
1121 | private RTextScrollPane scrolPane; |
1122 | |
1123 | private File file; |
1124 | + private XABSLContext context; |
1125 | private boolean changed; |
1126 | private int searchOffset; |
1127 | private String lastSearch; |
1128 | @@ -430,10 +431,16 @@ |
1129 | |
1130 | public void setXABSLContext(XABSLContext xabslContext) |
1131 | { |
1132 | + this.context = xabslContext; |
1133 | textArea.clearParsers(); |
1134 | textArea.addParser(new XParser(xabslContext)); |
1135 | }//end setXABSLContext |
1136 | |
1137 | + public XABSLContext getXABSLContext() |
1138 | + { |
1139 | + return context; |
1140 | + } |
1141 | + |
1142 | // Variables declaration - do not modify//GEN-BEGIN:variables |
1143 | private de.hu_berlin.informatik.ki.jxabsleditor.editorpanel.SearchPanel searchPanel; |
1144 | // End of variables declaration//GEN-END:variables |
1145 | |
1146 | === modified file 'src/de/hu_berlin/informatik/ki/jxabsleditor/parser/XABSLContext.java' |
1147 | --- src/de/hu_berlin/informatik/ki/jxabsleditor/parser/XABSLContext.java 2010-05-30 15:00:41 +0000 |
1148 | +++ src/de/hu_berlin/informatik/ki/jxabsleditor/parser/XABSLContext.java 2010-06-03 13:49:21 +0000 |
1149 | @@ -15,6 +15,7 @@ |
1150 | */ |
1151 | package de.hu_berlin.informatik.ki.jxabsleditor.parser; |
1152 | |
1153 | +import java.io.File; |
1154 | import java.util.ArrayList; |
1155 | import java.util.Map; |
1156 | import java.util.TreeMap; |
1157 | @@ -28,6 +29,7 @@ |
1158 | private Map<String, XABSLSymbol> symbolMap = new TreeMap<String, XABSLSymbol>(); |
1159 | private Map<String, XABSLEnum> enumMap = new TreeMap<String, XABSLEnum>(); |
1160 | private Map<String, XABSLOption> optionMap = new TreeMap<String, XABSLOption>(); |
1161 | + private Map<String, File> optionPathMap = new TreeMap<String, File>(); |
1162 | |
1163 | public Map<String, XABSLOption> getOptionMap() { |
1164 | return optionMap; |
1165 | @@ -41,6 +43,11 @@ |
1166 | return symbolMap; |
1167 | } |
1168 | |
1169 | + public Map<String, File> getOptionPathMap() |
1170 | + { |
1171 | + return optionPathMap; |
1172 | + } |
1173 | + |
1174 | public void add(XABSLSymbol e) { |
1175 | // TODO: symbols cannot be overwritten... |
1176 | if(e != null && !symbolMap.containsKey(e.name)) |