In browsevar, allows a user to plot the variable (already available in editvar).
[scilab.git] / scilab / modules / ui_data / src / java / org / scilab / modules / ui_data / variablebrowser / SwingScilabVariableBrowser.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2010 - DIGITEO - Bruno JOFRET
4  * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
5  * Copyright (C) 2011 - Calixte DENIZET
6  *
7  * This file must be used under the terms of the CeCILL.
8  * This source file is licensed as described in the file COPYING, which
9  * you should have received as part of this distribution.  The terms
10  * are also available at
11  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12  *
13  */
14 package org.scilab.modules.ui_data.variablebrowser;
15
16 import static org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.asynchronousScilabExec;
17
18 import java.awt.Color;
19 import java.awt.MouseInfo;
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
22 import java.awt.event.MouseEvent;
23 import java.awt.event.MouseListener;
24
25 import javax.swing.ActionMap;
26 import javax.swing.SwingUtilities;
27
28 import java.util.ArrayList;
29 import java.util.HashSet;
30 import java.util.List;
31
32 import javax.swing.JMenu;
33 import javax.swing.JScrollPane;
34 import javax.swing.JTable;
35 import javax.swing.ListSelectionModel;
36 import javax.swing.RowFilter;
37 import javax.swing.table.DefaultTableCellRenderer;
38 import javax.swing.table.TableColumn;
39 import javax.swing.table.TableModel;
40 import javax.swing.table.TableRowSorter;
41
42 import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement;
43 import org.scilab.modules.action_binding.highlevel.ScilabInterpreterManagement.InterpreterException;
44 import org.scilab.modules.gui.bridge.tab.SwingScilabTab;
45 import org.scilab.modules.gui.bridge.contextmenu.SwingScilabContextMenu;
46 import org.scilab.modules.gui.bridge.menu.SwingScilabMenu;
47 import org.scilab.modules.gui.contextmenu.ContextMenu;
48 import org.scilab.modules.gui.contextmenu.ScilabContextMenu;
49 import org.scilab.modules.gui.checkboxmenuitem.CheckBoxMenuItem;
50 import org.scilab.modules.gui.menu.Menu;
51 import org.scilab.modules.gui.menu.ScilabMenu;
52 import org.scilab.modules.gui.menubar.MenuBar;
53 import org.scilab.modules.gui.menubar.ScilabMenuBar;
54 import org.scilab.modules.gui.messagebox.ScilabModalDialog;
55 import org.scilab.modules.gui.messagebox.ScilabModalDialog.IconType;
56 import org.scilab.modules.gui.pushbutton.PushButton;
57 import org.scilab.modules.gui.textbox.TextBox;
58 import org.scilab.modules.gui.toolbar.ScilabToolBar;
59 import org.scilab.modules.gui.toolbar.ToolBar;
60 import org.scilab.modules.gui.utils.WindowsConfigurationManager;
61 import org.scilab.modules.localization.Messages;
62 import org.scilab.modules.types.ScilabTypeEnum;
63 import org.scilab.modules.ui_data.BrowseVar;
64 import org.scilab.modules.ui_data.actions.BooleanFilteringAction;
65 import org.scilab.modules.ui_data.actions.CompiledFunctionFilteringAction;
66 import org.scilab.modules.ui_data.actions.DoubleFilteringAction;
67 import org.scilab.modules.ui_data.actions.FunctionLibFilteringAction;
68 import org.scilab.modules.ui_data.actions.GraphicHandlesFilteringAction;
69 import org.scilab.modules.ui_data.actions.HelpAction;
70 import org.scilab.modules.ui_data.actions.ImplicitPolynomialFilteringAction;
71 import org.scilab.modules.ui_data.actions.IntegerFilteringAction;
72 import org.scilab.modules.ui_data.actions.IntrinsicFunctionFilteringAction;
73 import org.scilab.modules.ui_data.actions.ListFilteringAction;
74 import org.scilab.modules.ui_data.actions.MListFilteringAction;
75 import org.scilab.modules.ui_data.actions.MatlabSparseFilteringAction;
76 import org.scilab.modules.ui_data.actions.PointerFilteringAction;
77 import org.scilab.modules.ui_data.actions.PolynomialFilteringAction;
78 import org.scilab.modules.ui_data.actions.ScilabVarFilteringAction;
79 import org.scilab.modules.ui_data.actions.ScilabVarFilteringButtonAction;
80 import org.scilab.modules.ui_data.actions.SparseBoolFilteringAction;
81 import org.scilab.modules.ui_data.actions.SparseFilteringAction;
82 import org.scilab.modules.ui_data.actions.StringFilteringAction;
83 import org.scilab.modules.ui_data.actions.TListFilteringAction;
84 import org.scilab.modules.ui_data.actions.UncompiledFunctionFilteringAction;
85 import org.scilab.modules.ui_data.datatable.SwingTableModel;
86 import org.scilab.modules.ui_data.utils.UiDataMessages;
87 import org.scilab.modules.ui_data.variableeditor.actions.ExportToCsvAction;
88 import org.scilab.modules.ui_data.variableeditor.actions.PlotAction;
89 import org.scilab.modules.ui_data.variablebrowser.actions.CloseAction;
90 import org.scilab.modules.ui_data.variablebrowser.actions.DeleteAction;
91 import org.scilab.modules.ui_data.variablebrowser.actions.RefreshAction;
92 import org.scilab.modules.ui_data.variablebrowser.rowfilter.VariableBrowserRowDataFilter;
93 import org.scilab.modules.ui_data.variablebrowser.rowfilter.VariableBrowserRowTypeFilter;
94
95 /**
96  * Swing implementation of Scilab Variable browser
97  * uses JTable
98  */
99 public final class SwingScilabVariableBrowser extends SwingScilabTab implements SimpleVariableBrowser {
100
101     public static final String VARBROWSERUUID = "3b649047-6a71-4998-bd8e-00d367a4793c";
102
103     private static final long serialVersionUID = 2169382559550113917L;
104
105     private SwingTableModel<Object> dataModel;
106     private JTable table;
107
108     private MenuBar menuBar;
109     private Menu fileMenu;
110     private Menu helpMenu;
111     private Menu filterMenu;
112     private CheckBoxMenuItem filterDoubleCheckBox;
113     private CheckBoxMenuItem filterPolynomialCheckBox;
114     private CheckBoxMenuItem filterScilabVarCheckBox;
115     private CheckBoxMenuItem filterBooleanCheckBox;
116     private CheckBoxMenuItem filterSparseCheckBox;
117     private CheckBoxMenuItem filterSparseBoolCheckBox;
118     private CheckBoxMenuItem filterIntegerCheckBox;
119     private CheckBoxMenuItem filterGraphicHandlesCheckBox;
120     private CheckBoxMenuItem filterStringCheckBox;
121     private CheckBoxMenuItem filterUncompiledFuncCheckBox;
122     private CheckBoxMenuItem filtercompiledFuncCheckBox;
123     private CheckBoxMenuItem filterFunctionLibCheckBox;
124     private CheckBoxMenuItem filterListCheckBox;
125     private CheckBoxMenuItem filterTListCheckBox;
126     private CheckBoxMenuItem filterMListCheckBox;
127     private CheckBoxMenuItem filterPointerCheckBox;
128     private CheckBoxMenuItem filterIntrinsicFunctionCheckBox;
129     private CheckBoxMenuItem filterMatlabSparseCheckBox;
130     private CheckBoxMenuItem filterImplicitPolynomialCheckBox;
131     private PushButton filteringButton;
132
133     private boolean isSetData = false;
134
135     private TableRowSorter < ? > rowSorter;
136
137     /**
138      * Create a JTable with data Model.
139      * @param columnsName : Titles of JTable columns.
140      */
141     public SwingScilabVariableBrowser(String[] columnsName, int[] aligment) {
142         super(UiDataMessages.VARIABLE_BROWSER, VARBROWSERUUID);
143
144         setAssociatedXMLIDForHelp("browsevar");
145
146         buildMenuBar();
147         addMenuBar(menuBar);
148
149         ToolBar toolBar = ScilabToolBar.createToolBar();
150         toolBar.add(RefreshAction.createButton(UiDataMessages.REFRESH));
151         toolBar.addSeparator();
152         toolBar.add(DeleteAction.createButton(this, UiDataMessages.DELETE));
153         toolBar.addSeparator();
154         toolBar.add(HelpAction.createButton(UiDataMessages.HELP));
155         filteringButton = ScilabVarFilteringButtonAction.createButton("Show/hide Scilab variable");
156         //        toolBar.add(filteringButton);
157         addToolBar(toolBar);
158
159         dataModel = new SwingTableModel<Object>(columnsName);
160
161         table = new JTable(dataModel) {
162             //Implement table cell tool tips.
163             public String getToolTipText(MouseEvent e) {
164                 String tip = null;
165                 TableModel model = ((JTable) e.getSource()).getModel();
166                 java.awt.Point p = e.getPoint();
167                 int rowIndex = rowAtPoint(p);
168
169                 if (rowIndex >= 0) {
170                     rowIndex = convertRowIndexToModel(rowIndex);
171                     int colIndex = columnAtPoint(p);
172                     if (colIndex == BrowseVar.TYPE_DESC_COLUMN_INDEX) { /* Scilab type */
173                         try {
174                             tip = Messages.gettext("Scilab type:") + " " + model.getValueAt(rowIndex, BrowseVar.TYPE_COLUMN_INDEX).toString();
175                         } catch (IllegalArgumentException exception) {
176                             /* If the type is not known/managed, don't crash */
177                         }
178                     } else {
179
180                         if (colIndex == BrowseVar.SIZE_COLUMN_INDEX) {
181                             /* Use the getModel() method because the
182                              * column 5 has been removed from display
183                              * but still exist in the model */
184                             tip = Messages.gettext("Bytes:") + " " + model.getValueAt(rowIndex, BrowseVar.BYTES_COLUMN_INDEX).toString();
185                         }
186                     }
187                 }
188                 return tip;
189             }
190         };
191
192         table.setFillsViewportHeight(true);
193         table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
194         table.setAutoCreateRowSorter(true);
195
196         /* Size of the icon column */
197         table.getColumnModel().getColumn(0).setPreferredWidth(30);
198
199         /* Hide the columns. But keep it in memory for the tooltip */
200         TableColumn column = table.getColumnModel().getColumn(BrowseVar.NB_COLS_INDEX);
201         table.removeColumn(column);
202
203         /* The order to removing does matter since it changes the positions */
204
205         column = table.getColumnModel().getColumn(BrowseVar.NB_ROWS_INDEX);
206         table.removeColumn(column);
207
208         column = table.getColumnModel().getColumn(BrowseVar.TYPE_COLUMN_INDEX);
209         table.removeColumn(column);
210
211         column = table.getColumnModel().getColumn(BrowseVar.FROM_SCILAB_COLUMN_INDEX);
212         table.removeColumn(column);
213
214         column = table.getColumnModel().getColumn(BrowseVar.BYTES_COLUMN_INDEX);
215         table.removeColumn(column);
216
217         table.addMouseListener(new BrowseVarMouseListener());
218         // Mouse selection mode
219         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
220         table.setCellSelectionEnabled(true);
221
222         table.setBackground(Color.WHITE);
223         if (table.getGridColor().equals(Color.WHITE)) {
224             table.setGridColor(new Color(128, 128, 128));
225         }
226         table.setShowHorizontalLines(true);
227         table.setShowVerticalLines(true);
228
229         for (int i = 0; i < aligment.length; i++) {
230             align(table, columnsName[i], aligment[i]);
231         }
232
233         // Plug the shortcuts
234         ExportToCsvAction.registerAction(this, table);
235
236         JScrollPane scrollPane = new JScrollPane(table);
237         setContentPane(scrollPane);
238         WindowsConfigurationManager.restorationFinished(this);
239     }
240
241     /**
242      * {@inheritDoc}
243      */
244     public void addInfoBar(TextBox infoBarToAdd) {
245         setInfoBar(infoBarToAdd);
246     }
247
248     /**
249      * {@inheritDoc}
250      */
251     public void addMenuBar(MenuBar menuBarToAdd) {
252         setMenuBar(menuBarToAdd);
253     }
254
255     /**
256      * {@inheritDoc}
257      */
258     public void addToolBar(ToolBar toolBarToAdd) {
259         setToolBar(toolBarToAdd);
260     }
261
262     /**
263      * {@inheritDoc}
264      */
265     public void setColumnNames(String[] columnNames) {
266         dataModel.setColumnNames(columnNames);
267     }
268
269     /**
270      * {@inheritDoc}
271      */
272     public void setData(Object[][] data) {
273         isSetData = true;
274         dataModel.setData(data);
275         rowSorter = new TableRowSorter<TableModel>(dataModel);
276         this.updateRowFiltering();
277     }
278
279     private static void align(JTable table, String name, int alignment) {
280         if (alignment != -1) {
281             DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
282             renderer.setHorizontalAlignment(alignment);
283             try {
284                 TableColumn col = table.getColumn(name);
285                 if (col != null) {
286                     col.setCellRenderer(renderer);
287                 }
288             } catch (IllegalArgumentException e) { }
289         }
290     }
291
292     /**
293      * Update the display after filtering
294      * @see org.scilab.modules.ui_data.variablebrowser.SimpleVariableBrowser#updateRowFiltering()
295      */
296     public void updateRowFiltering() {
297         if (isSetData == false) { /* If the pull of the data has not been done, do it (please) */
298             try {
299                 ScilabInterpreterManagement.synchronousScilabExec("browsevar");
300                 isSetData = true;
301             } catch (InterpreterException e) {
302                 System.err.println(e);
303             }
304         }
305         VariableBrowserRowTypeFilter rowTypeFilter = new VariableBrowserRowTypeFilter(getFilteredTypeValues());
306         VariableBrowserRowDataFilter rowDataFilter = new VariableBrowserRowDataFilter(getFilteredDataValues());
307
308         List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>();
309         RowFilter<Object, Object> compoundRowFilter = null;
310         filters.add(rowTypeFilter);
311         filters.add(rowDataFilter);
312         compoundRowFilter = RowFilter.andFilter(filters);
313
314         rowSorter.setRowFilter(compoundRowFilter);
315         table.setRowSorter(rowSorter);
316     }
317
318     /**
319      * MouseListener inner class
320      */
321     private class BrowseVarMouseListener implements MouseListener {
322
323         /**
324          * Contructor
325          */
326         public BrowseVarMouseListener() {
327
328         }
329
330         /**
331          * Mouse CLICKED event handling
332          * @param e the event
333          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
334          */
335         public void mouseClicked(MouseEvent e) {
336
337             // Right click management
338             if ((e.getClickCount() == 1 && SwingUtilities.isRightMouseButton(e)) || e.isPopupTrigger()) {
339
340
341                 int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint());
342                 // Does nothing if no variable selected
343                 if (clickedRow != -1) {
344                     displayContextMenu();
345                 }
346             }
347
348             if (e.getClickCount() >= 2) {
349                 int clickedRow = ((JTable) e.getSource()).rowAtPoint(e.getPoint());
350                 if (clickedRow != -1) {
351                     String variableName = table.getValueAt(clickedRow, BrowseVar.NAME_COLUMN_INDEX).toString();
352
353                     String variableVisibility = ((JTable) e.getSource())
354                                                 .getValueAt(((JTable) e.getSource()).getSelectedRow(), BrowseVar.VISIBILITY_COLUMN_INDEX).toString();
355
356                     // Global variables are not editable yet
357                     if (variableVisibility.equals("global")) {
358                         ScilabModalDialog.show(getBrowserTab(),
359                                                UiDataMessages.GLOBAL_NOT_EDITABLE,
360                                                UiDataMessages.VARIABLE_EDITOR,
361                                                IconType.ERROR_ICON);
362                         return;
363                     }
364
365                     try {
366                         asynchronousScilabExec(null,
367                                                "if exists(\"" + variableName + "\") == 1 then "
368                                                + "  try "
369                                                + "    editvar(\"" + variableName + "\"); "
370                                                + "  catch "
371                                                + "    messagebox(\"Variables of type \"\"\" + typeof ("
372                                                + variableName + ") + \"\"\" can not be edited.\""
373                                                + ",\"" + UiDataMessages.VARIABLE_EDITOR + "\", \"error\", \"modal\");"
374                                                + "    clear ans;"   // clear return value of messagebox
375                                                + "  end "
376                                                + "else "
377                                                + "  messagebox(\"Variable \"\""
378                                                + variableName + "\"\" no more exists.\""
379                                                + ",\"" + UiDataMessages.VARIABLE_EDITOR + "\", \"error\", \"modal\");"
380                                                + "  clear ans;"  // clear return value of messagebox
381                                                + "  browsevar();" // Reload browsevar to remove cleared variables
382                                                + "end");
383                     } catch (InterpreterException e1) {
384                         System.err.println("An error in the interpreter has been catched: " + e1.getLocalizedMessage());
385                     }
386                 }
387             }
388         }
389
390         /**
391          * Mouse ENTERED event handling
392          * @param e the event
393          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
394          */
395         public void mouseEntered(MouseEvent e) {
396         }
397
398         /**
399          * Mouse EXITED event handling
400          * @param e the event
401          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
402          */
403         public void mouseExited(MouseEvent e) {
404         }
405
406         /**
407          * Mouse PRESSED event handling
408          * @param e the event
409          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
410          */
411         public void mousePressed(MouseEvent e) {
412         }
413
414         /**
415          * Mouse RELEASED event handling
416          * @param e the event
417          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
418          */
419         public void mouseReleased(MouseEvent e) {
420
421         }
422
423         /**
424          * Create and display the context menu
425          */
426         private void displayContextMenu() {
427             ContextMenu menu = ScilabContextMenu.createContextMenu();
428
429             DeleteAction delete = new DeleteAction(SwingScilabVariableBrowser.this);
430             menu.add(delete.createMenuItem());
431
432             ExportToCsvAction csvExport = new ExportToCsvAction((SwingScilabTab)SwingScilabVariableBrowser.this, UiDataMessages.EXPORTCSV);
433             menu.add(csvExport.createMenuItem(SwingScilabVariableBrowser.this, UiDataMessages.EXPORTCSV));
434
435             Menu menuPlot = ScilabMenu.createMenu();
436             menuPlot.setText(UiDataMessages.PLOTALL);
437             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "plot2d", false));
438             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "Matplot", false));
439             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "grayplot", false));
440             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "Sgrayplot", false));
441             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "champ", false));
442             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "histplot", false));
443             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "mesh", false));
444             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "surf", false));
445             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "hist3d", false));
446             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "contour2d", false));
447             menuPlot.add(PlotAction.createMenuItem((SwingScilabTab)SwingScilabVariableBrowser.this, "pie", false));
448             menu.add(menuPlot);
449
450             menu.setVisible(true);
451
452             ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
453                 MouseInfo.getPointerInfo().getLocation().x,
454                 MouseInfo.getPointerInfo().getLocation().y);
455
456         }
457
458
459     }
460
461     /**
462      * Creates the menuBar
463      */
464     public void buildMenuBar() {
465         menuBar = ScilabMenuBar.createMenuBar();
466
467         fileMenu = ScilabMenu.createMenu();
468         fileMenu.setText(UiDataMessages.FILE);
469         fileMenu.setMnemonic('F');
470         fileMenu.add(RefreshAction.createMenuItem(UiDataMessages.REFRESH));
471         fileMenu.addSeparator();
472         fileMenu.add(CloseAction.createMenu());
473
474         menuBar.add(fileMenu);
475
476         filterMenu = ScilabMenu.createMenu();
477         filterMenu.setText(UiDataMessages.FILTER);
478         filterMenu.setMnemonic('I');
479
480         filterScilabVarCheckBox = ScilabVarFilteringAction.createCheckBoxMenu();
481         filterScilabVarCheckBox.setChecked(true);
482         filterMenu.add(filterScilabVarCheckBox);
483
484         filterMenu.addSeparator();
485
486         filterBooleanCheckBox = BooleanFilteringAction.createCheckBoxMenu();
487         filterBooleanCheckBox.setChecked(true);
488         filterMenu.add(filterBooleanCheckBox);
489
490         filterDoubleCheckBox = DoubleFilteringAction.createCheckBoxMenu();
491         filterDoubleCheckBox.setChecked(true);
492         filterMenu.add(filterDoubleCheckBox);
493
494         filterPolynomialCheckBox = PolynomialFilteringAction.createCheckBoxMenu();
495         filterPolynomialCheckBox.setChecked(true);
496         filterMenu.add(filterPolynomialCheckBox);
497
498         filterFunctionLibCheckBox = FunctionLibFilteringAction.createCheckBoxMenu();
499         filterMenu.add(filterFunctionLibCheckBox);
500
501         filterStringCheckBox = StringFilteringAction.createCheckBoxMenu();
502         filterStringCheckBox.setChecked(true);
503         filterMenu.add(filterStringCheckBox);
504
505         filterSparseCheckBox = SparseFilteringAction.createCheckBoxMenu();
506         filterSparseCheckBox.setChecked(true);
507         filterMenu.add(filterSparseCheckBox);
508
509         filterSparseBoolCheckBox = SparseBoolFilteringAction.createCheckBoxMenu();
510         filterSparseBoolCheckBox.setChecked(true);
511         filterMenu.add(filterSparseBoolCheckBox);
512
513         filterIntegerCheckBox = IntegerFilteringAction.createCheckBoxMenu();
514         filterIntegerCheckBox.setChecked(true);
515         filterMenu.add(filterIntegerCheckBox);
516
517         filterGraphicHandlesCheckBox = GraphicHandlesFilteringAction.createCheckBoxMenu();
518         filterGraphicHandlesCheckBox.setChecked(true);
519         filterMenu.add(filterGraphicHandlesCheckBox);
520
521         filterUncompiledFuncCheckBox = UncompiledFunctionFilteringAction.createCheckBoxMenu();
522         filterMenu.add(filterUncompiledFuncCheckBox);
523
524         filtercompiledFuncCheckBox = CompiledFunctionFilteringAction.createCheckBoxMenu();
525         filterMenu.add(filtercompiledFuncCheckBox);
526
527         filterListCheckBox = ListFilteringAction.createCheckBoxMenu();
528         filterListCheckBox.setChecked(true);
529         filterMenu.add(filterListCheckBox);
530
531         filterTListCheckBox = TListFilteringAction.createCheckBoxMenu();
532         filterTListCheckBox.setChecked(true);
533         filterMenu.add(filterTListCheckBox);
534
535         filterMListCheckBox = MListFilteringAction.createCheckBoxMenu();
536         filterMListCheckBox.setChecked(true);
537         filterMenu.add(filterMListCheckBox);
538
539         filterPointerCheckBox = PointerFilteringAction.createCheckBoxMenu();
540         filterPointerCheckBox.setChecked(true);
541         filterMenu.add(filterPointerCheckBox);
542
543         filterIntrinsicFunctionCheckBox = IntrinsicFunctionFilteringAction.createCheckBoxMenu();
544         filterMenu.add(filterIntrinsicFunctionCheckBox);
545
546         filterMatlabSparseCheckBox = MatlabSparseFilteringAction.createCheckBoxMenu();
547         filterMenu.add(filterMatlabSparseCheckBox);
548
549         filterImplicitPolynomialCheckBox = ImplicitPolynomialFilteringAction.createCheckBoxMenu();
550         filterMenu.add(filterImplicitPolynomialCheckBox);
551
552         menuBar.add(filterMenu);
553
554         helpMenu = ScilabMenu.createMenu();
555         helpMenu.setText("?");
556         helpMenu.setMnemonic('?');
557         helpMenu.add(HelpAction.createMenuItem(UiDataMessages.HELP));
558         menuBar.add(helpMenu);
559     }
560
561
562     /**
563      * Filter management of data (Scilab or user data)
564      * @return the set of filtered values
565      */
566     public boolean getFilteredDataValues() {
567         return filterScilabVarCheckBox.isChecked();
568
569     }
570
571     /**
572      * Filter management of type
573      * @return the set of filtered values
574      */
575     public HashSet<ScilabTypeEnum> getFilteredTypeValues() {
576         HashSet<ScilabTypeEnum> filteredValues = new HashSet<ScilabTypeEnum>();
577         // TODO to replace later by something which smells less
578         if (!filterBooleanCheckBox.isChecked()) {
579             filteredValues.add(ScilabTypeEnum.sci_boolean);
580         }
581
582         if (!filterDoubleCheckBox.isChecked()) {
583             filteredValues.add(ScilabTypeEnum.sci_matrix);
584         }
585
586         if (!filterFunctionLibCheckBox.isChecked()) {
587             filteredValues.add(ScilabTypeEnum.sci_lib);
588         }
589
590         if (!filterStringCheckBox.isChecked()) {
591             filteredValues.add(ScilabTypeEnum.sci_strings);
592         }
593
594         if (!filterPolynomialCheckBox.isChecked()) {
595             filteredValues.add(ScilabTypeEnum.sci_poly);
596         }
597
598         if (!filterSparseCheckBox.isChecked()) {
599             filteredValues.add(ScilabTypeEnum.sci_sparse);
600         }
601
602         if (!filterSparseBoolCheckBox.isChecked()) {
603             filteredValues.add(ScilabTypeEnum.sci_boolean_sparse);
604         }
605
606         if (!filterIntegerCheckBox.isChecked()) {
607             filteredValues.add(ScilabTypeEnum.sci_ints);
608         }
609
610         if (!filterGraphicHandlesCheckBox.isChecked()) {
611             filteredValues.add(ScilabTypeEnum.sci_handles);
612         }
613
614         if (!filterUncompiledFuncCheckBox.isChecked()) {
615             filteredValues.add(ScilabTypeEnum.sci_u_function);
616         }
617
618         if (!filtercompiledFuncCheckBox.isChecked()) {
619             filteredValues.add(ScilabTypeEnum.sci_c_function);
620         }
621
622         if (!filterListCheckBox.isChecked()) {
623             filteredValues.add(ScilabTypeEnum.sci_list);
624         }
625
626         if (!filterTListCheckBox.isChecked()) {
627             filteredValues.add(ScilabTypeEnum.sci_tlist);
628         }
629
630         if (!filterMListCheckBox.isChecked()) {
631             filteredValues.add(ScilabTypeEnum.sci_mlist);
632         }
633
634         if (!filterPointerCheckBox.isChecked()) {
635             filteredValues.add(ScilabTypeEnum.sci_pointer);
636         }
637
638         if (!filterIntrinsicFunctionCheckBox.isChecked()) {
639             filteredValues.add(ScilabTypeEnum.sci_intrinsic_function);
640         }
641
642         if (!filterMatlabSparseCheckBox.isChecked()) {
643             filteredValues.add(ScilabTypeEnum.sci_matlab_sparse);
644         }
645
646         if (!filterImplicitPolynomialCheckBox.isChecked()) {
647             filteredValues.add(ScilabTypeEnum.sci_implicit_poly);
648         }
649
650         return filteredValues;
651     }
652
653     /**
654      * Get this browser as a Tab object
655      * @return the tab
656      */
657     public SwingScilabTab getBrowserTab() {
658         return this;
659     }
660
661
662     /**
663      * Return the variable Browser Table
664      * @return The variable Browser Table
665      */
666     public JTable getTable() {
667         return table;
668     }
669 }