Example usage for javax.swing.table DefaultTableModel DefaultTableModel

List of usage examples for javax.swing.table DefaultTableModel DefaultTableModel

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel DefaultTableModel.

Prototype

public DefaultTableModel() 

Source Link

Document

Constructs a default DefaultTableModel which is a table of zero columns and zero rows.

Usage

From source file:org.alex73.skarynka.scan.ui.book.BooksController.java

TableModel model() {
    return new DefaultTableModel() {
        @Override/*w w  w  .  ja va2s. c o  m*/
        public int getColumnCount() {
            return Context.getPermissions().BookControl ? 4 : 3;
        }

        @Override
        public int getRowCount() {
            return books.size();
        }

        @Override
        public String getColumnName(int column) {
            switch (column) {
            case 0:
                return Messages.getString("PANEL_BOOK_TABLE_NAME");
            case 1:
                return Messages.getString("PANEL_BOOK_TABLE_PAGES");
            case 2:
                return Messages.getString("PANEL_BOOK_TABLE_PAGE_SIZE");
            case 3:
                return Messages.getString("PANEL_BOOK_TABLE_STATUS");
            }
            return null;
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }

        @Override
        public Object getValueAt(int row, int column) {
            BookRow b = books.get(row);
            switch (column) {
            case 0:
                return b.bookName;
            case 1:
                return b.pagesCount;
            case 2:
                return b.info;
            case 3:
                return b.status;
            }
            return null;
        }
    };
}

From source file:org.eclim.installer.step.EclipsePluginsStep.java

@Override
public void displayed() {
    setBusy(true);/*from   w ww .  ja v a 2  s.c  o m*/
    setPreviousEnabled(false);

    try {
        overallLabel.setText("");
        overallProgress.setValue(0);
        taskLabel.setText("");
        taskProgress.setValue(0);
        taskProgress.setIndeterminate(true);

        // handle step re-entry.
        if (featuresPanel != null) {
            stepPanel.remove(featuresPanel);
        }

        EclipseInfo info = (EclipseInfo) Installer.getContext().getValue("eclipse.info");

        // find chosen features dependencies which need to be installed/upgraded.
        dependencies = unsatisfiedDependencies(info);

        if (dependencies.size() == 0) {
            overallProgress.setMaximum(1);
            overallProgress.setValue(1);
            overallLabel.setText("All third party plugins are up to date.");
            taskProgress.setMaximum(1);
            taskProgress.setValue(1);
            taskLabel.setText("");
        } else {
            tableModel = new DefaultTableModel();
            tableModel.addColumn("Feature");
            tableModel.addColumn("Version");
            tableModel.addColumn("Install / Upgrade");
            JTable table = new JTable(tableModel);
            table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            table.setDefaultRenderer(Object.class, new DependencyCellRenderer());
            table.getSelectionModel().addListSelectionListener(new DependencySelectionListener());

            featuresPanel = new JPanel(new BorderLayout());
            featuresPanel.setAlignmentX(0.0f);

            JPanel container = new JPanel(new BorderLayout());
            container.add(table, BorderLayout.CENTER);

            JScrollPane scrollPane = new JScrollPane(container);
            scrollPane.setAlignmentX(0.0f);

            availableFeatures = loadAvailableFeatures();
            for (Dependency dependency : dependencies) {
                String version = availableFeatures.get(dependency.getId());
                String manual = "";
                if (version == null) {
                    manual = " (Manual)";
                    version = dependency.getRequiredVersion();
                }
                tableModel.addRow(new Object[] { dependency.getId(), version,
                        (dependency.isUpgrade() ? "Upgrade" : "Install") + manual, });
            }

            JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
            buttons.setAlignmentX(0.0f);

            JButton skipButton = new JButton(new SkipPluginsAction());
            JButton installButton = new JButton(new InstallPluginsAction(skipButton));

            buttons.add(installButton);
            buttons.add(skipButton);

            featuresPanel.add(scrollPane, BorderLayout.CENTER);
            featuresPanel.add(buttons, BorderLayout.SOUTH);

            stepPanel.add(featuresPanel);
            overallProgress.setValue(0);
            overallLabel.setText("");
            taskProgress.setValue(0);
            taskLabel.setText("");
        }
    } catch (Exception e) {
        setError(e);
    } finally {
        setValid(dependencies != null && dependencies.size() == 0);
        setBusy(false);
        setPreviousEnabled(true);
        taskProgress.setIndeterminate(false);
    }
}

From source file:org.fhaes.gui.AnalysisResultsPanel.java

/**
 * Set up the AnalysisResults GUI// ww  w  . j a  v  a2s .  c  o m
 */
private void initGUI() {

    setLayout(new BorderLayout(0, 0));
    if (Platform.isOSX())
        setBackground(MainWindow.MAC_BACKGROUND_COLOR);

    ImageIcon iconMultipleTables = Builder.getImageIcon("multipletables16.png");
    ImageIcon iconTable = Builder.getImageIcon("table16.png");

    // ImageIcon iconChart = Builder.getImageIcon("chart16.png");

    // Categories
    rootNode = new FHAESCategoryTreeNode("FHAES analysis results");
    categoryGeneral = new FHAESCategoryTreeNode("Descriptive summaries",
            Builder.getImageIcon("interval16.png"));
    categoryInterval = new FHAESCategoryTreeNode("Interval analysis", Builder.getImageIcon("interval16.png"));
    categorySeasonality = new FHAESCategoryTreeNode("Seasonality", Builder.getImageIcon("seasonality16.png"));
    categoryBinarySummaryMatrices = new FHAESCategoryTreeNode("Binary summary matrices",
            Builder.getImageIcon("matrix16.png"));
    categoryBinaryMatrices = new FHAESCategoryTreeNode("Binary comparison matrices",
            Builder.getImageIcon("matrix16.png"));
    categorySimMatrices = new FHAESCategoryTreeNode("Similarity matrices",
            Builder.getImageIcon("matrix16.png"));
    categoryDisSimMatrices = new FHAESCategoryTreeNode("Dissimilarity matrices",
            Builder.getImageIcon("matrix16.png"));

    // Menu actions

    // Results

    itemJaccard = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX, iconMultipleTables);
    itemJaccard.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(SJACFile, new CSVFileFilter());
        }
    });

    itemCohen = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX, iconMultipleTables);
    itemCohen.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(SCOHFile, new CSVFileFilter());
        }
    });

    itemJaccardD = new FHAESResultTreeNode(FHAESResult.JACCARD_SIMILARITY_MATRIX_D, iconMultipleTables);
    itemJaccardD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(DSJACFile, new CSVFileFilter());
        }
    });

    itemCohenD = new FHAESResultTreeNode(FHAESResult.COHEN_SIMILARITITY_MATRIX_D, iconMultipleTables);
    itemCohenD.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(DSCOHFile, new CSVFileFilter());
        }
    });

    itemIntervalSummary = new FHAESResultTreeNode(FHAESResult.INTERVAL_SUMMARY, iconMultipleTables);
    itemIntervalSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(intervalsSummaryFile, new CSVFileFilter());
        }
    });

    itemExceedence = new FHAESResultTreeNode(FHAESResult.INTERVAL_EXCEEDENCE_TABLE, iconMultipleTables);
    itemExceedence.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(intervalsExceedenceFile, new CSVFileFilter());
        }
    });

    itemSeasonalitySummary = new FHAESResultTreeNode(FHAESResult.SEASONALITY_SUMMARY, iconMultipleTables);
    itemSeasonalitySummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(seasonalitySummaryFile, new CSVFileFilter());
        }
    });

    itemBin00 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_00, iconMultipleTables);
    itemBin00.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(bin00File, new CSVFileFilter());
        }
    });

    itemBin01 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_01, iconMultipleTables);
    itemBin01.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(bin01File, new CSVFileFilter());
        }
    });

    itemBin10 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_10, iconMultipleTables);
    itemBin10.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(bin10File, new CSVFileFilter());
        }
    });

    itemBin11 = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_11, iconMultipleTables);
    itemBin11.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(bin11File, new CSVFileFilter());
        }
    });

    itemBinSum = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SUM, iconMultipleTables);
    itemBinSum.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(binSumFile, new CSVFileFilter());
        }

    });
    itemBinSiteSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_SITE, iconMultipleTables);
    itemBinSiteSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(siteSummaryFile, new CSVFileFilter());
        }
    });
    itemBinSiteSummary.addAction(new FHAESAction("Export to shapefile", "formatshp.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            new ShapeFileDialog(App.mainFrame, fhm);

        }
    });

    itemBinTreeSummary = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_TREE, iconMultipleTables);
    itemBinTreeSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(treeSummaryFile, new CSVFileFilter());
        }
    });

    itemNTP = new FHAESResultTreeNode(FHAESResult.BINARY_MATRIX_NTP, iconMultipleTables);
    itemNTP.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(NTPFile, new CSVFileFilter());
        }
    });

    this.itemGeneralSummary = new FHAESResultTreeNode(FHAESResult.GENERAL_SUMMARY, iconMultipleTables);
    itemGeneralSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(generalSummaryFile, new CSVFileFilter());
        }

    });

    this.itemSingleFileSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_FILE_SUMMARY, iconTable);
    itemSingleFileSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(singleFileSummaryFile, new CSVFileFilter());
        }

    });

    this.itemSingleEventSummary = new FHAESResultTreeNode(FHAESResult.SINGLE_EVENT_SUMMARY, iconTable);
    itemSingleEventSummary.addAction(new FHAESAction("Save to CSV", "formatcsv.png") {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent event) {

            saveFileToDisk(singleEventSummaryFile, new CSVFileFilter());
        }

    });

    // Add results to categories
    categoryGeneral.add(itemGeneralSummary);
    categoryGeneral.add(itemSingleFileSummary);
    categoryGeneral.add(itemSingleEventSummary);
    categorySimMatrices.add(itemJaccard);
    categorySimMatrices.add(itemCohen);
    categoryDisSimMatrices.add(itemJaccardD);
    categoryDisSimMatrices.add(itemCohenD);
    categoryInterval.add(itemIntervalSummary);
    categoryInterval.add(itemExceedence);
    categorySeasonality.add(itemSeasonalitySummary);
    categoryBinaryMatrices.add(itemBin11);
    categoryBinaryMatrices.add(itemBin01);
    categoryBinaryMatrices.add(itemBin10);
    categoryBinaryMatrices.add(itemBin00);
    categoryBinaryMatrices.add(itemBinSum);
    categoryBinarySummaryMatrices.add(itemBinSiteSummary);
    categoryBinarySummaryMatrices.add(itemBinTreeSummary);
    categoryBinarySummaryMatrices.add(itemNTP);

    // Add categories to root of tree
    rootNode.add(categoryGeneral);
    rootNode.add(categoryInterval);
    rootNode.add(categorySeasonality);
    rootNode.add(categoryBinarySummaryMatrices);
    rootNode.add(categoryBinaryMatrices);
    rootNode.add(categorySimMatrices);
    rootNode.add(categoryDisSimMatrices);

    treeModel = new DefaultTreeModel(rootNode);

    splitPane = new JSplitPane();
    if (Platform.isOSX())
        splitPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR);

    splitPane.setResizeWeight(0.9);
    add(splitPane, BorderLayout.CENTER);

    JPanel panelTree = new JPanel();
    splitPane.setRightComponent(panelTree);
    panelTree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    panelTree.setLayout(new BorderLayout(0, 0));

    // Build tree
    treeResults = new JTree();
    panelTree.add(treeResults);
    treeResults.setModel(treeModel);

    treeResults.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeResults.setCellRenderer(new FHAESResultTreeRenderer());

    pickResultPanel = new PickResultPanel();
    runAnalysisPanel = new RunAnalysisPanel();

    cards = new JPanel();
    cl = new CardLayout();
    cards.setLayout(cl);
    cards.add(pickResultPanel, PICKRESULTPANEL);
    cards.add(runAnalysisPanel, RUNANALYSIS);
    cards.add(emptyPanel, EMPTYPANEL);

    splitPane.setLeftComponent(cards);

    cl.show(cards, RUNANALYSIS);

    splitPaneResult = new JSplitPane();
    splitPaneResult.setOneTouchExpandable(true);
    splitPaneResult.setOrientation(JSplitPane.VERTICAL_SPLIT);
    cards.add(splitPaneResult, RESULTSPANEL);

    panelResult = new JPanel();

    panelResult.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelResult.setLayout(new BorderLayout(0, 0));

    goldFishPanel = new GoldFishPanel();
    splitPaneResult.setRightComponent(goldFishPanel);

    // Build table
    scrollPane = new JScrollPane();

    panelResult.add(scrollPane);
    table = new JXTable();
    adapter = new JTableSpreadsheetByRowAdapter(table);

    table.setModel(new DefaultTableModel());
    table.setHorizontalScrollEnabled(true);
    scrollPane.setViewportView(table);
    splitPaneResult.setLeftComponent(panelResult);

    // OSX Style hack
    if (Platform.isOSX())
        panelResult.setBackground(MainWindow.MAC_BACKGROUND_COLOR);
    if (Platform.isOSX())
        scrollPane.setBackground(MainWindow.MAC_BACKGROUND_COLOR);

    // Expand all nodes
    for (int i = 0; i < treeResults.getRowCount(); i++) {
        treeResults.expandRow(i);
    }

    treeResults.addTreeSelectionListener(this);

    treeResults.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {

            if (SwingUtilities.isRightMouseButton(e)) {
                int x = e.getX();
                int y = e.getY();
                JTree tree = (JTree) e.getSource();
                TreePath path = tree.getPathForLocation(x, y);
                if (path == null)
                    return;
                if (!tree.isEnabled())
                    return;

                tree.setSelectionPath(path);
                Component mc = e.getComponent();

                if (path != null && path.getLastPathComponent() instanceof FHAESResultTreeNode) {
                    FHAESResultTreeNode node = (FHAESResultTreeNode) path.getLastPathComponent();

                    if (!node.isEnabled())
                        return;

                    FHAESResultPopupMenu popupMenu = new FHAESResultPopupMenu(node.getArrayOfActions());
                    popupMenu.show(mc, e.getX(), e.getY());
                }
            }
        }

        @Override
        public void mouseEntered(MouseEvent arg0) {

        }

        @Override
        public void mouseExited(MouseEvent arg0) {

        }

        @Override
        public void mousePressed(MouseEvent arg0) {

        }

        @Override
        public void mouseReleased(MouseEvent arg0) {

        }

    });

    this.splitPaneResult.setDividerLocation(10000);
    this.splitPaneResult.setDividerSize(3);
    this.splitPaneResult.setResizeWeight(1);
}

From source file:org.fhaes.gui.AnalysisResultsPanel.java

/**
 * Clear the analysis results table and show the relevant instructional card page, either 'pick analysis' or 'run analysis' depending on
 * whether we have analyses to show/*from w ww.ja  va2 s.c o m*/
 */
private void clearTable() {

    panelResult.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    table.setModel(new DefaultTableModel());

    MainWindow.getInstance().getReportPanel().actionResultsHelp.setEnabled(false);

    if (this.generalSummaryModel == null) {
        // No general sumamry model so analyses have NOT been run
        // Show 'run analysis' card
        cl.show(cards, RUNANALYSIS);
    } else {
        // If there is a general summary model then the analysis have been run.
        // Show the 'pick results' card
        cl.show(cards, PICKRESULTPANEL);
    }

    this.repaint();
}

From source file:org.fhaes.gui.AnalysisResultsPanel.java

/**
 * Clear all the results from the table and tree.
 *//*from   ww w . j a v  a 2  s .c o m*/
public void clearResults() {

    seasonalitySummaryModel = null;
    intervalsExceedenceModel = null;
    intervalsSummaryModel = null;
    bin00Model = null;
    bin10Model = null;
    bin01Model = null;
    bin11Model = null;
    binSumModel = null;
    DSCOHModel = null;
    DSJACModel = null;
    SCOHModel = null;
    siteSummaryModel = null;
    SJACModel = null;
    NTPModel = null;
    treeSummaryModel = null;
    singleFileSummaryModel = null;
    singleEventSummaryModel = null;
    generalSummaryModel = null;

    setResultsEnabled(false);
    table.setModel(new DefaultTableModel());
    areAnalysesRunAndCurrent = false;
}

From source file:org.freeplane.view.swing.features.time.mindmapmode.nodelist.NodeList.java

/**
 * Creates a table model for the new table and returns it.
 *///from  ww w. j a  v a 2 s.c o m
private DefaultTableModel updateModel() {
    final DefaultTableModel model = new DefaultTableModel() {
        /**
         *
         */
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
         */
        @Override
        public Class<?> getColumnClass(final int arg0) {
            switch (arg0) {
            case DATE_COLUMN:
            case NODE_CREATED_COLUMN:
            case NODE_MODIFIED_COLUMN:
                return Date.class;
            case NODE_TEXT_COLUMN:
            case NODE_NOTES_COLUMN:
            case NODE_DETAILS_COLUMN:
                return TextHolder.class;
            case NODE_ICON_COLUMN:
                return IconsHolder.class;
            default:
                return Object.class;
            }
        }
    };
    model.addColumn(NodeList.COLUMN_DATE);
    model.addColumn(NodeList.COLUMN_TEXT);
    model.addColumn(NodeList.COLUMN_ICONS);
    model.addColumn(NodeList.COLUMN_CREATED);
    model.addColumn(NodeList.COLUMN_MODIFIED);
    model.addColumn(NodeList.COLUMN_DETAILS);
    model.addColumn(NodeList.COLUMN_NOTES);
    if (searchInAllMaps == false) {
        final NodeModel node = Controller.getCurrentController().getMap().getRootNode();
        updateModel(model, node);
    } else {
        final Map<String, MapModel> maps = Controller.getCurrentController().getMapViewManager()
                .getMaps(MModeController.MODENAME);
        for (final MapModel map : maps.values()) {
            final NodeModel node = map.getRootNode();
            updateModel(model, node);
        }
    }
    return model;
}

From source file:org.freeplane.view.swing.features.time.mindmapmode.NodeList.java

/**
 * Creates a table model for the new table and returns it.
 *//*from  w w w.  j av  a2  s .c  o m*/
private DefaultTableModel updateModel() {
    final DefaultTableModel model = new DefaultTableModel() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        /*
         * (non-Javadoc)
         * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
         */
        @Override
        public Class<?> getColumnClass(final int arg0) {
            switch (arg0) {
            case DATE_COLUMN:
            case NODE_CREATED_COLUMN:
            case NODE_MODIFIED_COLUMN:
                return Date.class;
            case NODE_TEXT_COLUMN:
                return NodeHolder.class;
            case NODE_ICON_COLUMN:
                return IconsHolder.class;
            case NODE_NOTES_COLUMN:
                return NotesHolder.class;
            default:
                return Object.class;
            }
        }
    };
    model.addColumn(NodeList.COLUMN_DATE);
    model.addColumn(NodeList.COLUMN_TEXT);
    model.addColumn(NodeList.COLUMN_ICONS);
    model.addColumn(NodeList.COLUMN_CREATED);
    model.addColumn(NodeList.COLUMN_MODIFIED);
    model.addColumn(NodeList.COLUMN_NOTES);
    if (searchInAllMaps == false) {
        final NodeModel node = Controller.getCurrentController().getMap().getRootNode();
        updateModel(model, node);
    } else {
        final Map<String, MapModel> maps = Controller.getCurrentController().getMapViewManager()
                .getMaps(MModeController.MODENAME);
        for (final MapModel map : maps.values()) {
            final NodeModel node = map.getRootNode();
            updateModel(model, node);
        }
    }
    return model;
}

From source file:org.g_node.crawler.LKTLogbook.LKTLogCliToolControllerTest.java

/**
 * Tests the run method of the {@link LKTLogCliToolController}.
 * Will test LKTLogParser, LKTLogParserSheet and LKTLogParserEntry as well with an invalid ods sheet.
 * @throws Exception/*from  www  . j  a  v  a2  s . com*/
 */
@Test
public void runTest() throws Exception {
    final String testODSFileName = "test.ods";
    final File currODSTestFile = this.testFileFolder.resolve(testODSFileName).toFile();
    final File ods = new File(currODSTestFile.toString());
    SpreadSheet.createEmpty(new DefaultTableModel()).saveAs(ods);

    final CommandLineParser parser = new DefaultParser();
    final Options useOptions = this.logCtrl.options();
    String[] args;
    CommandLine cmd;

    // Test missing argument
    args = new String[1];
    args[0] = "-i";
    try {
        parser.parse(useOptions, args, false);
    } catch (MissingArgumentException e) {
        assertThat(e).hasMessage("Missing argument for option: i");
    }

    // Test non existent input file
    args = new String[2];
    args[0] = "-i";
    args[1] = "iDoNotExist";
    cmd = parser.parse(useOptions, args, false);
    this.logCtrl.run(cmd);

    assertThat(this.outStream.toString()).contains("Input file iDoNotExist does not exist");
    this.outStream.reset();

    // Test existing input file, unsupported file type
    args = new String[2];
    args[0] = "-i";
    args[1] = this.currTestFile.toString();
    cmd = parser.parse(useOptions, args, false);
    this.logCtrl.run(cmd);

    assertThat(this.outStream.toString()).contains(
            String.join("", "[ERROR] Input RDF file ", this.currTestFile.toString(), " cannot be read."));
    this.outStream.reset();

    // Test provide supported input file type, unsupported output RDF format
    args = new String[4];
    args[0] = "-i";
    args[1] = currODSTestFile.toString();
    args[2] = "-f";
    args[3] = "iDoNotExist";
    cmd = parser.parse(useOptions, args, false);
    this.logCtrl.run(cmd);

    assertThat(this.outStream.toString()).contains("[ERROR] Unsupported output format: 'IDONOTEXIST'");
    this.outStream.reset();

    // Test provide supported input file type, w/o proper entries.
    args = new String[2];
    args[0] = "-i";
    args[1] = currODSTestFile.toString();
    cmd = parser.parse(useOptions, args, false);
    this.logCtrl.run(cmd);

    assertThat(this.outStream.toString())
            .contains(String.join("", "[Parser] sheet 'null' does not contain valid data."));
    this.outStream.reset();

    // Test use custom invalid test file.
    final URL invODSTestFile = this.getClass().getResource("/lkt_test_invalid.ods");

    args = new String[2];
    args[0] = "-i";
    args[1] = Paths.get(invODSTestFile.toURI()).toFile().toString();

    cmd = parser.parse(useOptions, args, false);
    this.logCtrl.run(cmd);

    assertThat(this.outStream.toString())
            .contains("There are parser errors present. Please resolve them and run the program again.");
    this.outStream.reset();
}

From source file:org.isatools.isacreator.gui.formelements.SubForm.java

public void resetModel(int newSize) {
    defaultTableModel = new DefaultTableModel();
    setupTableModel(newSize);
}

From source file:org.isatools.isacreator.gui.formelements.SubForm.java

public void cleanupReferences() {
    setDataEntryEnvironment(null);/*from  w w w  . j a v  a  2  s  .  co m*/
    for (int rowIndex = 0; rowIndex < scrollTable.getRowCount(); rowIndex++) {
        if (getRowEditor().getCellEditor(rowIndex) instanceof RowEditor) {
            OntologyCellEditor editor = (OntologyCellEditor) getRowEditor().getCellEditor(rowIndex);
            editor.cleanupReferences();
        }
    }
    scrollTable.getParent().removeAll();
    scrollTable.setModel(new DefaultTableModel());
    scrollTable = null;
    lockedTable.getParent().removeAll();
    lockedTable.setModel(new DefaultTableModel());
    lockedTable = null;
    options.removeAll();
    removeRecord = null;
    defaultTableModel = null;

    excelAdaptor.setJTable(null);
    excelAdaptor = null;

    getRowEditor().removeAllCellEditors();
    setDataEntryForm(null);
    removeAll();
}