Merge remote-tracking branch 'refs/remotes/origin/master' into graphic
[scilab.git] / scilab / modules / xcos / src / java / org / scilab / modules / xcos / XcosTab.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2010-2011 - DIGITEO - Clement DAVID
4  *
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 package org.scilab.modules.xcos;
14
15 import java.beans.PropertyChangeEvent;
16 import java.beans.PropertyChangeListener;
17 import java.net.MalformedURLException;
18 import java.net.URL;
19 import java.util.List;
20 import java.util.ListIterator;
21 import java.util.UUID;
22
23 import javax.swing.JCheckBoxMenuItem;
24
25 import org.apache.commons.logging.LogFactory;
26 import org.scilab.modules.graph.actions.CopyAction;
27 import org.scilab.modules.graph.actions.CutAction;
28 import org.scilab.modules.graph.actions.DeleteAction;
29 import org.scilab.modules.graph.actions.InvertSelectionAction;
30 import org.scilab.modules.graph.actions.PasteAction;
31 import org.scilab.modules.graph.actions.RedoAction;
32 import org.scilab.modules.graph.actions.SelectAllAction;
33 import org.scilab.modules.graph.actions.UndoAction;
34 import org.scilab.modules.graph.actions.ZoomInAction;
35 import org.scilab.modules.graph.actions.ZoomOutAction;
36 import org.scilab.modules.graph.event.ArrowKeyListener;
37 import org.scilab.modules.gui.bridge.menu.SwingScilabMenu;
38 import org.scilab.modules.gui.bridge.tab.SwingScilabTab;
39 import org.scilab.modules.gui.bridge.window.SwingScilabWindow;
40 import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem;
41 import org.scilab.modules.gui.menu.Menu;
42 import org.scilab.modules.gui.menu.ScilabMenu;
43 import org.scilab.modules.gui.menubar.MenuBar;
44 import org.scilab.modules.gui.menubar.ScilabMenuBar;
45 import org.scilab.modules.gui.menuitem.MenuItem;
46 import org.scilab.modules.gui.pushbutton.PushButton;
47 import org.scilab.modules.gui.tab.SimpleTab;
48 import org.scilab.modules.gui.tabfactory.ScilabTabFactory;
49 import org.scilab.modules.gui.textbox.ScilabTextBox;
50 import org.scilab.modules.gui.toolbar.ScilabToolBar;
51 import org.scilab.modules.gui.toolbar.ToolBar;
52 import org.scilab.modules.gui.utils.BarUpdater;
53 import org.scilab.modules.gui.utils.ClosingOperationsManager;
54 import org.scilab.modules.gui.utils.WindowsConfigurationManager;
55 import org.scilab.modules.xcos.actions.AboutXcosAction;
56 import org.scilab.modules.xcos.actions.CloseAction;
57 import org.scilab.modules.xcos.actions.CompileAction;
58 import org.scilab.modules.xcos.actions.DebugLevelAction;
59 import org.scilab.modules.xcos.actions.DiagramBackgroundAction;
60 import org.scilab.modules.xcos.actions.ExportAction;
61 import org.scilab.modules.xcos.actions.FitDiagramToViewAction;
62 import org.scilab.modules.xcos.actions.InitModelicaAction;
63 import org.scilab.modules.xcos.actions.NewDiagramAction;
64 import org.scilab.modules.xcos.actions.NormalViewAction;
65 import org.scilab.modules.xcos.actions.OpenAction;
66 import org.scilab.modules.xcos.actions.PrintAction;
67 import org.scilab.modules.xcos.actions.QuitAction;
68 import org.scilab.modules.xcos.actions.RecentFileAction;
69 import org.scilab.modules.xcos.actions.SaveAction;
70 import org.scilab.modules.xcos.actions.SaveAsAction;
71 import org.scilab.modules.xcos.actions.SetContextAction;
72 import org.scilab.modules.xcos.actions.SetupAction;
73 import org.scilab.modules.xcos.actions.ShowHideShadowAction;
74 import org.scilab.modules.xcos.actions.StartAction;
75 import org.scilab.modules.xcos.actions.StopAction;
76 import org.scilab.modules.xcos.actions.ViewDiagramBrowserAction;
77 import org.scilab.modules.xcos.actions.ViewGridAction;
78 import org.scilab.modules.xcos.actions.ViewViewportAction;
79 import org.scilab.modules.xcos.actions.XcosDemonstrationsAction;
80 import org.scilab.modules.xcos.actions.XcosDocumentationAction;
81 import org.scilab.modules.xcos.block.actions.BlockDocumentationAction;
82 import org.scilab.modules.xcos.block.actions.BlockParametersAction;
83 import org.scilab.modules.xcos.block.actions.BorderColorAction;
84 import org.scilab.modules.xcos.block.actions.CodeGenerationAction;
85 import org.scilab.modules.xcos.block.actions.FilledColorAction;
86 import org.scilab.modules.xcos.block.actions.FlipAction;
87 import org.scilab.modules.xcos.block.actions.MirrorAction;
88 import org.scilab.modules.xcos.block.actions.RegionToSuperblockAction;
89 import org.scilab.modules.xcos.block.actions.RotateAction;
90 import org.scilab.modules.xcos.block.actions.ViewDetailsAction;
91 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionBottom;
92 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionCenter;
93 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionLeft;
94 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionMiddle;
95 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionRight;
96 import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionTop;
97 import org.scilab.modules.xcos.configuration.ConfigurationManager;
98 import org.scilab.modules.xcos.configuration.model.DocumentType;
99 import org.scilab.modules.xcos.configuration.utils.ConfigurationConstants;
100 import org.scilab.modules.xcos.graph.XcosDiagram;
101 import org.scilab.modules.xcos.link.actions.StyleHorizontalAction;
102 import org.scilab.modules.xcos.link.actions.StyleStraightAction;
103 import org.scilab.modules.xcos.link.actions.StyleVerticalAction;
104 import org.scilab.modules.xcos.palette.actions.ViewPaletteBrowserAction;
105 import org.scilab.modules.xcos.palette.view.PaletteManagerView;
106 import org.scilab.modules.xcos.utils.XcosMessages;
107
108 /**
109  * Xcos tab operations
110  * 
111  * This class implement specific operation of an Xcos Tab.
112  */
113 // CSOFF: ClassFanOutComplexity
114 // CSOFF: ClassDataAbstractionCoupling
115 public class XcosTab extends SwingScilabTab implements SimpleTab {
116     public static final String DEFAULT_WIN_UUID = "xcos-default-window";
117     public static final String DEFAULT_TAB_UUID = "xcos-default-tab";
118
119     /*
120      * Instance fields
121      */
122     private MenuBar menuBar;
123     private Menu fileMenu;
124     private Menu recentsMenu;
125     private Menu edit;
126     private Menu view;
127     private Menu simulate;
128     private Menu format;
129     private Menu alignMenu;
130     private Menu linkStyle;
131     private Menu tools;
132     private Menu help;
133
134     private JCheckBoxMenuItem viewport;
135
136     private PushButton openAction;
137     private PushButton saveAction;
138     private PushButton saveAsAction;
139     private PushButton printAction;
140     private PushButton newDiagramAction;
141     private PushButton deleteAction;
142     private PushButton undoAction;
143     private PushButton redoAction;
144     private PushButton fitDiagramToViewAction;
145     private PushButton startAction;
146     private PushButton stopAction;
147     private PushButton zoomInAction;
148     private PushButton zoomOutAction;
149     private PushButton xcosDemonstrationAction;
150     private PushButton xcosDocumentationAction;
151
152     private static class ClosingOperation
153             implements
154             org.scilab.modules.gui.utils.ClosingOperationsManager.ClosingOperation {
155         private final XcosDiagram graph;
156
157         public ClosingOperation(XcosDiagram graph) {
158             this.graph = graph;
159         }
160
161         @Override
162         public boolean canClose() {
163             return Xcos.getInstance().canClose(graph);
164         }
165
166         @Override
167         public void destroy() {
168             Xcos.getInstance().destroy(graph);
169             graph.setOpened(false);
170         }
171
172         @Override
173         public String askForClosing(final List<SwingScilabTab> list) {
174             return Xcos.getInstance().askForClosing(graph, list);
175         }
176
177         @Override
178         public void updateDependencies(List<SwingScilabTab> list,
179                 ListIterator<SwingScilabTab> it) {
180             final PaletteManagerView palette = PaletteManagerView.get();
181
182             /*
183              * if palette is not visible, then break
184              */
185             if (palette == null) {
186                 return;
187             }
188
189             /*
190              * If it already contains the palette, then break.
191              */
192             if (list.contains(palette)) {
193                 return;
194             }
195
196
197             final boolean wasLastOpened = Xcos.getInstance()
198                     .wasLastOpened(list);
199
200             /*
201              * Append the palette if all the xcos files will be closed
202              */
203             if (wasLastOpened) {
204                 it.add(palette);
205             }
206
207         }
208     }
209
210     private static class EndedRestoration implements
211             WindowsConfigurationManager.EndedRestoration {
212         private final XcosDiagram graph;
213
214         public EndedRestoration(XcosDiagram graph) {
215             this.graph = graph;
216         }
217
218         @Override
219         public void finish() {
220             graph.updateTabTitle();
221
222             ConfigurationManager.getInstance().removeFromRecentTabs(
223                     graph.getDiagramTab());
224         }
225     }
226
227     /**
228      * Default constructor
229      * 
230      * @param diagram
231      *            The associated diagram
232      */
233     private XcosTab(XcosDiagram graph, String uuid) {
234         super(XcosMessages.XCOS, uuid);
235
236         /** tab association */
237         graph.setDiagramTab(uuid);
238         setWindowIcon(Xcos.ICON.getImage());
239
240         initComponents(graph);
241
242         graph.getAsComponent().addKeyListener(new ArrowKeyListener());
243     }
244
245     /*
246      * Static API for Tabs
247      */
248
249     /**
250      * Get the tab for a graph.
251      * 
252      * @param graph
253      *            the graph
254      * @return the tab (can be null)
255      */
256     public static XcosTab get(XcosDiagram graph) {
257         final String uuid = graph.getDiagramTab();
258         if (uuid == null) {
259             return null;
260         }
261
262         return (XcosTab) ScilabTabFactory.getInstance().getFromCache(uuid);
263     }
264
265     /**
266      * Restore or create the viewport tab for the graph
267      * 
268      * @param graph
269      *            the graph
270      */
271     public static void restore(XcosDiagram graph) {
272         restore(graph, true);
273     }
274
275     /**
276      * Restore or create the tab for the graph
277      * 
278      * @param graph
279      *            the graph
280      * @param visible
281      *            should the tab should be visible
282      */
283     public static void restore(final XcosDiagram graph, final boolean visible) {
284         String uuid = graph.getDiagramTab();
285         if (uuid == null) {
286             uuid = UUID.randomUUID().toString();
287         }
288
289         final XcosTab tab = new XcosTab(graph, uuid);
290         ScilabTabFactory.getInstance().addToCache(tab);
291
292         Xcos.getInstance().addDiagram(graph.getSavedFile(), graph);
293         graph.setOpened(true);
294
295         if (visible) {
296             tab.createDefaultWindow().setVisible(true);
297
298             graph.updateTabTitle();
299             BarUpdater.updateBars(tab.getParentWindowId(), tab.getMenuBar(), tab.getToolBar(), tab.getInfoBar(), tab.getName(), tab.getWindowIcon());
300         }
301
302         ClosingOperationsManager.addDependencyWithRoot((SwingScilabTab) tab);
303         ClosingOperationsManager.registerClosingOperation((SwingScilabTab) tab,
304                 new ClosingOperation(graph));
305         WindowsConfigurationManager.registerEndedRestoration(
306                 (SwingScilabTab) tab, new EndedRestoration(graph));
307     }
308
309     /*
310      * Specific implementation
311      */
312
313     /**
314      * Instantiate all the subcomponents of this Tab.
315      * 
316      * @param diagram
317      *            the diagram
318      */
319     private void initComponents(final XcosDiagram diagram) {
320         /* Create the menu bar */
321         menuBar = createMenuBar(diagram);
322         setMenuBar(menuBar);
323
324         /* Create the toolbar */
325         final ToolBar toolBar = createToolBar(diagram);
326         setToolBar(toolBar);
327
328         // No SimpleTab.addMember(ScilabComponent ...) so perform a raw
329         // association.
330         setContentPane(diagram.getAsComponent());
331
332         /* Create the infoBar */
333         setInfoBar(ScilabTextBox.createTextBox());
334     }
335
336     /**
337      * Create the windows menu bar
338      * 
339      * @param diagram
340      *            the diagram
341      * @return the Xcos diagram menu bar
342      */
343     // CSOFF: JavaNCSS
344     private MenuBar createMenuBar(final XcosDiagram diagram) {
345
346         menuBar = ScilabMenuBar.createMenuBar();
347
348         /** FILE MENU */
349         fileMenu = ScilabMenu.createMenu();
350         fileMenu.setText(XcosMessages.FILE);
351         fileMenu.setMnemonic('F');
352
353         fileMenu.add(NewDiagramAction.createMenu(diagram));
354         fileMenu.add(OpenAction.createMenu(diagram));
355         fileMenu.addSeparator();
356         fileMenu.add(SaveAction.createMenu(diagram));
357         fileMenu.add(SaveAsAction.createMenu(diagram));
358         fileMenu.add(ExportAction.createMenu(diagram));
359
360         recentsMenu = createRecentMenu();
361
362         fileMenu.add(recentsMenu);
363
364         fileMenu.add(PrintAction.createMenu(diagram));
365         fileMenu.addSeparator();
366         fileMenu.add(CloseAction.createMenu(diagram));
367         fileMenu.addSeparator();
368         fileMenu.add(QuitAction.createMenu(diagram));
369
370         menuBar.add(fileMenu);
371
372         /** Edit menu */
373         edit = ScilabMenu.createMenu();
374         edit.setText(XcosMessages.EDIT);
375         edit.setMnemonic('E');
376         menuBar.add(edit);
377
378         edit.add(UndoAction.undoMenu(diagram));
379         edit.add(RedoAction.redoMenu(diagram));
380         edit.addSeparator();
381         edit.add(CutAction.cutMenu(diagram));
382         edit.add(CopyAction.copyMenu(diagram));
383         edit.add(PasteAction.pasteMenu(diagram));
384         edit.add(DeleteAction.createMenu(diagram));
385         edit.addSeparator();
386         edit.add(SelectAllAction.createMenu(diagram));
387         edit.add(InvertSelectionAction.createMenu(diagram));
388         edit.addSeparator();
389         edit.add(BlockParametersAction.createMenu(diagram));
390         edit.addSeparator();
391         edit.add(RegionToSuperblockAction.createMenu(diagram));
392
393         /** View menu */
394         view = ScilabMenu.createMenu();
395         view.setText(XcosMessages.VIEW);
396         view.setMnemonic('V');
397         menuBar.add(view);
398
399         view.add(ZoomInAction.zoominMenu(diagram));
400         view.add(ZoomOutAction.zoomoutMenu(diagram));
401         view.add(FitDiagramToViewAction.createMenu(diagram));
402         view.add(NormalViewAction.createMenu(diagram));
403         view.addSeparator();
404         view.add(ViewPaletteBrowserAction.createCheckBoxMenu(diagram));
405         view.add(ViewDiagramBrowserAction.createMenu(diagram));
406         final CheckBoxMenuItem menuItem = ViewViewportAction
407                 .createCheckBoxMenu(diagram);
408         viewport = (JCheckBoxMenuItem) menuItem.getAsSimpleCheckBoxMenuItem();
409         view.add(menuItem);
410         view.add(ViewDetailsAction.createMenu(diagram));
411
412         /** Simulation menu */
413         simulate = ScilabMenu.createMenu();
414         simulate.setText(XcosMessages.SIMULATION);
415         simulate.setMnemonic('S');
416         menuBar.add(simulate);
417
418         final MenuItem startMenu = StartAction.createMenu(diagram);
419         final MenuItem stopMenu = StopAction.createMenu(diagram);
420
421         simulate.add(SetupAction.createMenu(diagram));
422         simulate.add(DebugLevelAction.createMenu(diagram));
423         simulate.add(SetContextAction.createMenu(diagram));
424         simulate.add(CompileAction.createMenu(diagram));
425         simulate.add(InitModelicaAction.createMenu(diagram));
426         simulate.add(startMenu);
427         simulate.add(stopMenu);
428
429         /** Format menu */
430         format = ScilabMenu.createMenu();
431         format.setText(XcosMessages.FORMAT);
432         format.setMnemonic('O');
433         menuBar.add(format);
434
435         format.add(RotateAction.createMenu(diagram));
436         format.add(FlipAction.createMenu(diagram));
437         format.add(MirrorAction.createMenu(diagram));
438         format.add(ShowHideShadowAction.createMenu(diagram));
439
440         format.addSeparator();
441         alignMenu = ScilabMenu.createMenu();
442         alignMenu.setText(XcosMessages.ALIGN_BLOCKS);
443         alignMenu.add(AlignBlockActionLeft.createMenu(diagram));
444         alignMenu.add(AlignBlockActionCenter.createMenu(diagram));
445         alignMenu.add(AlignBlockActionRight.createMenu(diagram));
446         alignMenu.addSeparator();
447         alignMenu.add(AlignBlockActionTop.createMenu(diagram));
448         alignMenu.add(AlignBlockActionMiddle.createMenu(diagram));
449         alignMenu.add(AlignBlockActionBottom.createMenu(diagram));
450         format.add(alignMenu);
451         format.addSeparator();
452
453         format.add(BorderColorAction.createMenu(diagram));
454         format.add(FilledColorAction.createMenu(diagram));
455         format.addSeparator();
456
457         linkStyle = ScilabMenu.createMenu();
458         linkStyle.setText(XcosMessages.LINK_STYLE);
459         linkStyle.add(StyleHorizontalAction.createMenu(diagram));
460         linkStyle.add(StyleStraightAction.createMenu(diagram));
461         linkStyle.add(StyleVerticalAction.createMenu(diagram));
462         format.add(linkStyle);
463         format.addSeparator();
464
465         format.add(DiagramBackgroundAction.createMenu(diagram));
466         final CheckBoxMenuItem gridMenu = ViewGridAction
467                 .createCheckBoxMenu(diagram);
468         format.add(gridMenu);
469
470         /** Tools menu */
471         tools = ScilabMenu.createMenu();
472         tools.setText(XcosMessages.TOOLS);
473         tools.setMnemonic('T');
474         menuBar.add(tools);
475
476         tools.add(CodeGenerationAction.createMenu(diagram));
477
478         /** Help menu */
479         help = ScilabMenu.createMenu();
480         help.setText(XcosMessages.HELP);
481         help.setMnemonic('?');
482         menuBar.add(help);
483
484         help.add(XcosDocumentationAction.createMenu(diagram));
485         help.add(BlockDocumentationAction.createMenu(diagram));
486         help.addSeparator();
487         help.add(XcosDemonstrationsAction.createMenu(diagram));
488         help.addSeparator();
489         help.add(AboutXcosAction.createMenu(diagram));
490
491         return menuBar;
492     }
493
494     // CSON: JavaNCSS
495
496     /**
497      * Create the recent menu from the previously opened files
498      * 
499      * @return the recent menu
500      */
501     private Menu createRecentMenu() {
502         final Menu recent;
503
504         recent = ScilabMenu.createMenu();
505         recent.setText(XcosMessages.RECENT_FILES);
506
507         final ConfigurationManager manager = ConfigurationManager.getInstance();
508         final List<DocumentType> recentFiles = manager.getSettings()
509                 .getRecent();
510         for (int i = 0; i < recentFiles.size(); i++) {
511             URL url;
512             try {
513                 url = new URL(recentFiles.get(i).getUrl());
514             } catch (final MalformedURLException e) {
515                 LogFactory.getLog(XcosTab.class).error(e);
516                 break;
517             }
518             recent.add(RecentFileAction.createMenu(url));
519         }
520
521         ConfigurationManager.getInstance().addPropertyChangeListener(
522                 ConfigurationConstants.RECENT_FILES_CHANGED,
523                 new PropertyChangeListener() {
524                     @Override
525                     public void propertyChange(final PropertyChangeEvent evt) {
526                         assert evt.getPropertyName().equals(
527                                 ConfigurationConstants.RECENT_FILES_CHANGED);
528
529                         /*
530                          * We only handle menu creation there. Return when this
531                          * is not the case.
532                          */
533                         if (evt.getOldValue() != null) {
534                             return;
535                         }
536
537                         URL url;
538                         try {
539                             url = new URL(((DocumentType) evt.getNewValue())
540                                     .getUrl());
541                         } catch (final MalformedURLException e) {
542                             LogFactory.getLog(XcosTab.class).error(e);
543                             return;
544                         }
545
546                         ((SwingScilabMenu) recent.getAsSimpleMenu()).add(
547                                 (SwingScilabMenu) RecentFileAction.createMenu(
548                                         url).getAsSimpleMenu(), 0);
549                     }
550                 });
551
552         return recent;
553     }
554
555     /**
556      * Create the Tab toolbar
557      * 
558      * @param diagram
559      *            the associated diagram
560      * @return tool bar
561      */
562     private ToolBar createToolBar(final XcosDiagram diagram) {
563         final ToolBar toolBar = ScilabToolBar.createToolBar();
564
565         newDiagramAction = NewDiagramAction.createButton(diagram);
566         toolBar.add(newDiagramAction);
567
568         openAction = OpenAction.createButton(diagram);
569         toolBar.add(openAction);
570
571         toolBar.addSeparator();
572
573         saveAction = SaveAction.createButton(diagram);
574         toolBar.add(saveAction);
575         saveAsAction = SaveAsAction.createButton(diagram);
576         toolBar.add(saveAsAction);
577
578         toolBar.addSeparator();
579
580         printAction = PrintAction.createButton(diagram);
581         toolBar.add(printAction);
582
583         toolBar.addSeparator();
584
585         deleteAction = DeleteAction.createButton(diagram);
586         toolBar.add(deleteAction);
587
588         toolBar.addSeparator();
589
590         // UNDO / REDO
591         undoAction = UndoAction.undoButton(diagram);
592         redoAction = RedoAction.redoButton(diagram);
593         toolBar.add(undoAction);
594         toolBar.add(redoAction);
595
596         toolBar.addSeparator();
597
598         fitDiagramToViewAction = FitDiagramToViewAction.createButton(diagram);
599         toolBar.add(fitDiagramToViewAction);
600
601         toolBar.addSeparator();
602
603         // START / STOP
604         startAction = StartAction.createButton(diagram);
605         stopAction = StopAction.createButton(diagram);
606
607         toolBar.add(startAction);
608         toolBar.add(stopAction);
609
610         toolBar.addSeparator();
611
612         // ZOOMIN / ZOOMOUT
613         zoomInAction = ZoomInAction.zoominButton(diagram);
614         toolBar.add(zoomInAction);
615         zoomOutAction = ZoomOutAction.zoomoutButton(diagram);
616         toolBar.add(zoomOutAction);
617
618         toolBar.addSeparator();
619
620         xcosDemonstrationAction = XcosDemonstrationsAction
621                 .createButton(diagram);
622         toolBar.add(xcosDemonstrationAction);
623         xcosDocumentationAction = XcosDocumentationAction.createButton(diagram);
624         toolBar.add(xcosDocumentationAction);
625
626         return toolBar;
627     }
628
629     /**
630      * Check/uncheck the viewport check box menu item
631      * 
632      * @param status
633      *            the checked status
634      */
635     public void setViewportChecked(boolean status) {
636         viewport.setSelected(status);
637     }
638
639     /**
640      * Get the check/uncheck status of the check box menu item
641      * 
642      * @param status
643      *            the checked status
644      */
645     public boolean isViewportChecked() {
646         return viewport.isSelected();
647     }
648
649     private SwingScilabWindow createDefaultWindow() {
650         final SwingScilabWindow win;
651
652         final SwingScilabWindow configuration = WindowsConfigurationManager.createWindow(
653                 DEFAULT_WIN_UUID, false);
654         if (configuration != null) {
655             win = configuration;
656         } else {
657             win = new SwingScilabWindow();
658         }
659
660         win.addTab(this);
661         return win;
662     }
663 }
664
665 // CSON: ClassDataAbstractionCoupling
666 // CSON: ClassFanOutComplexity