Search in sources :

Example 1 with ValidateCellActionListener

use of CCDD.CcddClassesComponent.ValidateCellActionListener in project CCDD by nasa.

the class CcddTableEditorDialog method initialize.

/**
 ********************************************************************************************
 * Create the data table editor dialog
 *
 * @param tableInformation
 *            list containing information for each table
 *
 * @param editor
 *            reference to an existing table editor
 ********************************************************************************************
 */
private void initialize(List<TableInformation> tableInformation, CcddTableEditorHandler editor) {
    // Menu ///////////////////////////////////////////////////////////////////////////////////
    // Create the data table menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    // Create the File menu and menu items
    JMenu mnFile = ccddMain.createMenu(menuBar, "File", KeyEvent.VK_F, 1, null);
    mntmOpen = ccddMain.createMenuItem(mnFile, "Edit table(s)", KeyEvent.VK_E, 1, "Open one or more data tables for editing");
    mntmOpenPrototype = ccddMain.createMenuItem(mnFile, "Edit prototype", KeyEvent.VK_T, 2, "Open the prototype for the current table");
    mnFile.addSeparator();
    mntmStore = ccddMain.createMenuItem(mnFile, "Store current", KeyEvent.VK_U, 1, "Store changes to the current editor table");
    mntmStoreAll = ccddMain.createMenuItem(mnFile, "Store all", KeyEvent.VK_L, 1, "Store the changes to all tables in this editor");
    mnFile.addSeparator();
    mntmImport = ccddMain.createMenuItem(mnFile, "Import data", KeyEvent.VK_I, 1, "Import data from a CSV, EDS XML, JSON, or XTCE XML file into the current editor table");
    JMenu mnExport = ccddMain.createSubMenu(mnFile, "Export table", KeyEvent.VK_X, 1, null);
    mntmExportCSV = ccddMain.createMenuItem(mnExport, "CSV", KeyEvent.VK_C, 1, "Export the current editor table in CSV format");
    mntmExportEDS = ccddMain.createMenuItem(mnExport, "EDS", KeyEvent.VK_E, 1, "Export the current editor table in EDS XML format");
    mntmExportJSON = ccddMain.createMenuItem(mnExport, "JSON", KeyEvent.VK_J, 1, "Export the current editor table in JSON format");
    mntmExportXTCE = ccddMain.createMenuItem(mnExport, "XTCE", KeyEvent.VK_X, 1, "Export the current editor table in XTCE XML format");
    mnFile.addSeparator();
    mntmPrint = ccddMain.createMenuItem(mnFile, "Print current", KeyEvent.VK_P, 1, "Print the current editor table information");
    mntmSearchTable = ccddMain.createMenuItem(mnFile, "Search tables", KeyEvent.VK_S, 1, "Search the project database tables");
    mnFile.addSeparator();
    mntmCloseActive = ccddMain.createMenuItem(mnFile, "Close current", KeyEvent.VK_C, 2, "Close the current editor table");
    mntmCloseAll = ccddMain.createMenuItem(mnFile, "Close all", KeyEvent.VK_A, 1, "Close all tables in this editor");
    // Create the Edit menu and menu items
    JMenu mnEdit = ccddMain.createMenu(menuBar, "Edit", KeyEvent.VK_E, 1, null);
    mntmCopy = ccddMain.createMenuItem(mnEdit, "Copy", KeyEvent.VK_C, 1, "Copy the selected cell(s) to the clipboard");
    mntmPaste = ccddMain.createMenuItem(mnEdit, "Paste (Ctrl-V)", KeyEvent.VK_V, 1, "Paste the clipboard contents at the current focus location");
    mntmInsert = ccddMain.createMenuItem(mnEdit, "Insert", KeyEvent.VK_I, 1, "Insert the clipboard contents at the current focus location");
    mnEdit.addSeparator();
    mntmUndo = ccddMain.createMenuItem(mnEdit, "Undo (Ctrl-Z)", KeyEvent.VK_Z, 1, "Undo the last edit operation");
    mntmRedo = ccddMain.createMenuItem(mnEdit, "Redo (Ctrl-Y)", KeyEvent.VK_Y, 1, "Redo the last undone edit operation");
    mnEdit.addSeparator();
    mntmInsertMacro = ccddMain.createMenuItem(mnEdit, "Insert macro", KeyEvent.VK_M, 1, "Insert a macro selected from the pop-up list");
    mntmShowMacros = ccddMain.createCheckBoxMenuItem(mnEdit, "Show macros", KeyEvent.VK_S, 1, "Temporarily replace macro(s) with the corresponding value(s)", false);
    mnEdit.addSeparator();
    JMenu mnClearSelected = ccddMain.createSubMenu(mnEdit, "Replace selected", KeyEvent.VK_L, 1, null);
    mntmWithBlanks = ccddMain.createMenuItem(mnClearSelected, "With blank", KeyEvent.VK_B, 1, "Replace the values in the selected cells with blanks");
    mntmWithPrototype = ccddMain.createMenuItem(mnClearSelected, "With prototype", KeyEvent.VK_P, 1, "Replace the values in the selected cells with the prototype's values");
    // Create the Row menu and menu items
    JMenu mnRow = ccddMain.createMenu(menuBar, "Row", KeyEvent.VK_R, 1, null);
    mntmInsertRow = ccddMain.createMenuItem(mnRow, "Insert row", KeyEvent.VK_I, 1, "Insert a row below the current focus location");
    mntmDeleteRow = ccddMain.createMenuItem(mnRow, "Delete row(s)", KeyEvent.VK_D, 1, "Delete the currently selected row(s)");
    mnRow.addSeparator();
    mntmMoveUp = ccddMain.createMenuItem(mnRow, "Move up", KeyEvent.VK_U, 1, "Move the currently selected row(s) up one row");
    mntmMoveDown = ccddMain.createMenuItem(mnRow, "Move down", KeyEvent.VK_N, 1, "Move the currently selected row(s) down one row");
    mnRow.addSeparator();
    mntmExpColArray = ccddMain.createCheckBoxMenuItem(mnRow, "Expand arrays", KeyEvent.VK_E, 1, "Expand/collapse display of array members", false);
    JMenu mnOverwrite = ccddMain.createSubMenu(mnRow, "Array overwrite", KeyEvent.VK_O, 1, null);
    mntmOverwriteAll = ccddMain.createRadioButtonMenuItem(mnOverwrite, "Overwrite all", KeyEvent.VK_A, 1, "Copy array definition value change to all members", true);
    mntmOverwriteEmpty = ccddMain.createRadioButtonMenuItem(mnOverwrite, "Overwrite empty", KeyEvent.VK_E, 3, "Copy array definition value change only to empty members", false);
    mntmOverwriteNone = ccddMain.createRadioButtonMenuItem(mnOverwrite, "Overwrite none", KeyEvent.VK_N, 1, "Do not copy definition value change to members", false);
    ButtonGroup rbtnGroup = new ButtonGroup();
    rbtnGroup.add(mntmOverwriteAll);
    rbtnGroup.add(mntmOverwriteEmpty);
    rbtnGroup.add(mntmOverwriteNone);
    // Create the Column menu and menu items
    JMenu mnColumn = ccddMain.createMenu(menuBar, "Column", KeyEvent.VK_M, 1, null);
    mntmMoveLeft = ccddMain.createMenuItem(mnColumn, "Move left", KeyEvent.VK_L, 1, "Move the currently selected column(s) left one column");
    mntmMoveRight = ccddMain.createMenuItem(mnColumn, "Move right", KeyEvent.VK_R, 1, "Move the currently selected column(s) right one column");
    mntmResetOrder = ccddMain.createMenuItem(mnColumn, "Reset order", KeyEvent.VK_O, 1, "Reset the column order to the default");
    // Create the Field menu and menu items
    JMenu mnField = ccddMain.createMenu(menuBar, "Field", KeyEvent.VK_L, 1, null);
    mntmManageFields = ccddMain.createMenuItem(mnField, "Manage fields", KeyEvent.VK_M, 1, "Open the data field manager");
    mntmClearValues = ccddMain.createMenuItem(mnField, "Clear values", KeyEvent.VK_C, 1, "Clear the data field values");
    // Add a listener for the Open Table command
    mntmOpen.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Open a table in this editor dialog
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Open a table and add it to the tabbed pane. This calls TableSelectDialog, but
            // doesn't spawn a separate editor
            new CcddTableManagerDialog(ccddMain, ManagerDialogType.EDIT, CcddTableEditorDialog.this);
        }
    });
    // Add a listener for the Open Prototype Table command
    mntmOpenPrototype.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Open the currently displayed table's prototype table in this editor dialog
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Open the active table's prototype table
            dbTable.loadTableDataInBackground(activeEditor.getTableInformation().getPrototypeName(), CcddTableEditorDialog.this);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Import command
    mntmImport.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Import a file into the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fileIOHandler.importSelectedFileIntoTable(activeEditor);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Export - CSV command
    mntmExportCSV.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Export the table to a file in CSV format
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            new CcddTableManagerDialog(ccddMain, ManagerDialogType.EXPORT_CSV, CcddTableEditorDialog.this);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Export - EDS command
    mntmExportEDS.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Export the table to a file in EDS XML format
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            new CcddTableManagerDialog(ccddMain, ManagerDialogType.EXPORT_EDS, CcddTableEditorDialog.this);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Export - JSON command
    mntmExportJSON.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Export the table to a file in JSON format
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            new CcddTableManagerDialog(ccddMain, ManagerDialogType.EXPORT_JSON, CcddTableEditorDialog.this);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Export - XTCE command
    mntmExportXTCE.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Export the table to a file in XTCE XML format
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            new CcddTableManagerDialog(ccddMain, ManagerDialogType.EXPORT_XTCE, CcddTableEditorDialog.this);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Print command
    mntmPrint.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Output the table to the printer
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Print the table
            activeEditor.getTable().printTable("Table: " + activeEditor.getOwnerName(), activeEditor.getFieldHandler(), CcddTableEditorDialog.this, PageFormat.LANDSCAPE);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Search tables menu item
    mntmSearchTable.addActionListener(new ActionListener() {

        /**
         ************************************************************************************
         * Display the search tables dialog
         ************************************************************************************
         */
        @Override
        public void actionPerformed(ActionEvent ae) {
            ccddMain.showSearchDialog(SearchDialogType.TABLES, CcddTableEditorDialog.this);
        }
    });
    // Add a listener for the Copy command
    mntmCopy.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Copy the selected table cell(s) contents into the clipboard
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Send a Ctrl-C key press
            controlKeyAction(KeyEvent.VK_C);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Paste command
    mntmPaste.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Paste the clipboard contents in the table, overwriting any existing data in the
         * target cells and adding new rows at the end of the table if needed
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Send a Ctrl-V key press
            controlKeyAction(KeyEvent.VK_V);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Insert command
    mntmInsert.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Insert the clipboard contents in the table, creating new rows to contain the data
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Send a ctrl-I key press
            controlKeyAction(KeyEvent.VK_I);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Clear selected | With blanks command
    mntmWithBlanks.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Erase the data in the selected cell(s)
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Check if there are any rows to clear
            if (activeEditor.getTableModel().getRowCount() != 0) {
                // Clear the selected cell(s)
                activeEditor.getTable().deleteCell(false);
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Clear selected | With prototype command
    mntmWithPrototype.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Erase the data in the selected cell(s) and the corresponding entry(s) in the custom
         * values table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Check if there are any rows to clear
            if (activeEditor.getTableModel().getRowCount() != 0) {
                // Clear the selected cell(s)
                activeEditor.getTable().deleteCell(true);
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the insert macro command
    mntmInsertMacro.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Insert the macro chosen from the pop-up list into the current cell
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // and end values are valid
            if (getTable().getLastSelectionStart() != -1 && getTable().getLastSelectionEnd() != -1) {
                // Initiate editing in the selected cell
                getTable().editCellAt(getTable().getSelectedRow(), getTable().getSelectedColumn());
                // Get the cell's component
                final Component comp = getTable().getEditorComponent();
                // Check if the cell represents a text component (text area, text field, etc.)
                if (comp instanceof JTextComponent) {
                    // Set the focus to the cell
                    comp.requestFocusInWindow();
                    // Execute the event after any pending events
                    EventQueue.invokeLater(new Runnable() {

                        /**
                         ********************************************************************
                         * Set the selected text start and end positions
                         ********************************************************************
                         */
                        @Override
                        public void run() {
                            // Set the text selected text to the last known positions
                            ((JTextComponent) comp).setSelectionStart(getTable().getLastSelectionStart());
                            ((JTextComponent) comp).setSelectionEnd(getTable().getLastSelectionEnd());
                        }
                    });
                }
                // Send a Ctrl-M key press to display the insert macro pop-up
                controlKeyAction(KeyEvent.VK_M);
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Show macros command
    mntmShowMacros.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Temporarily replace any macros with the corresponding values
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // If the check box is selected then disable the controls that are not allowed
            // while macros are shown, else enable the controls
            setControlsEnabled(!mntmShowMacros.isSelected());
            // Step through each table opened in the editor dialog
            for (CcddTableEditorHandler editor : tableEditors) {
                // Expand all macros in the table if the check box is selected and disable
                // editing for the table, else restore all macros and enable editing
                editor.expandMacros(mntmShowMacros.isSelected(), false);
                editor.setTableEditEnable(!mntmShowMacros.isSelected());
            }
            // Redraw the visible table
            activeEditor.getTable().repaint();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Store All command
    mntmStoreAll.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Store the changes to all open table contents, if any, in the database
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // action
            if (isTablesChanged() && new CcddDialogHandler().showMessageDialog(CcddTableEditorDialog.this, "<html><b>Store changes for all?", "Store Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                // Update the database for every table that has changes
                storeAllChanges();
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Reset Order command
    mntmResetOrder.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Reset the column order to the default
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.resetColumnOrder();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Manage Fields command
    mntmManageFields.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Manage the data fields
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Create the field editor dialog showing the fields for this table
            new CcddFieldEditorDialog(ccddMain, activeEditor, activeEditor.getTableInformation().getTablePath(), (activeEditor.getTableTypeDefinition().isStructure() && !activeEditor.getTableInformation().getTablePath().contains(",")), MIN_WINDOW_WIDTH);
            // Enable/disable the Clear values command depending on if any data fields remain
            mntmClearValues.setEnabled(!activeEditor.getFieldHandler().getFieldInformation().isEmpty());
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add a listener for the Clear values command
    mntmClearValues.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Clear the table data field values
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Check if there are any data fields to clear
            if (!activeEditor.getFieldHandler().getFieldInformation().isEmpty()) {
                // Remove all of the data field values from the table
                activeEditor.getInputFieldPanelHandler().clearFieldValues();
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Create the lower (button) panel
    JPanel buttonPnl = new JPanel();
    // Define the buttons for the lower panel: New button
    btnInsertRow = CcddButtonPanelHandler.createButton("Ins Row", INSERT_ICON, KeyEvent.VK_I, "Insert a new row into the table");
    // Create a listener for the Insert Row command
    ActionListener insertAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Insert a new row into the table at the selected location
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().insertEmptyRow(true);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the insert listener to the Insert Row button and menu command
    btnInsertRow.addActionListener(insertAction);
    mntmInsertRow.addActionListener(insertAction);
    // Delete button
    btnDeleteRow = CcddButtonPanelHandler.createButton("Del Row", DELETE_ICON, KeyEvent.VK_D, "Delete the selected row(s) from the table");
    // Create a listener for the Delete Row command
    ActionListener deleteAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Delete the selected row(s) from the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().deleteRow(true);
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the delete listener to the Delete Row button and menu command
    btnDeleteRow.addActionListener(deleteAction);
    mntmDeleteRow.addActionListener(deleteAction);
    // Create a listener for the Expand arrays command
    mntmExpColArray.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Expand or collapse the array members
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // Toggle between showing and hiding the array member rows
            activeEditor.showHideArrayMembers();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Move Up button
    btnMoveUp = CcddButtonPanelHandler.createButton("Up", UP_ICON, KeyEvent.VK_U, "Move the selected row(s) up");
    // Create a listener for the Move Up command
    ActionListener moveUpAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Move the selected row(s) up in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().moveRowUp();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the move up listener to the Move Up button and menu command
    btnMoveUp.addActionListener(moveUpAction);
    mntmMoveUp.addActionListener(moveUpAction);
    // Move Down button
    btnMoveDown = CcddButtonPanelHandler.createButton("Down", DOWN_ICON, KeyEvent.VK_N, "Move the selected row(s) down");
    // Create a listener for the Move Down command
    ActionListener moveDownAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Move the selected row(s) down in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().moveRowDown();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the move down listener to the Move Down button and menu command
    btnMoveDown.addActionListener(moveDownAction);
    mntmMoveDown.addActionListener(moveDownAction);
    // Move Left button
    btnMoveLeft = CcddButtonPanelHandler.createButton("Left", LEFT_ICON, KeyEvent.VK_L, "Move the selected column(s) left");
    // Create a listener for the Move Left command
    ActionListener moveLeftAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Move the selected column(s) left in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().moveColumnLeft();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the move left listener to the Move Left button and menu command
    btnMoveLeft.addActionListener(moveLeftAction);
    mntmMoveLeft.addActionListener(moveLeftAction);
    // Move Right button
    btnMoveRight = CcddButtonPanelHandler.createButton("Right", RIGHT_ICON, KeyEvent.VK_R, "Move the selected column(s) right");
    // Create a listener for the Move Right command
    ActionListener moveRightAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Move the selected column(s) right in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getTable().moveColumnRight();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the move right listener to the Move Right button and menu command
    btnMoveRight.addActionListener(moveRightAction);
    mntmMoveRight.addActionListener(moveRightAction);
    // Undo button
    btnUndo = CcddButtonPanelHandler.createButton("Undo", UNDO_ICON, KeyEvent.VK_Z, "Undo the last edit action");
    // Create a listener for the Undo command
    ActionListener undoAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Undo the last cell edit
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getFieldPanelUndoManager().undo();
            // Update the data field background colors
            activeEditor.getInputFieldPanelHandler().setFieldBackgound();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the undo listener to the Undo button and menu command
    mntmUndo.addActionListener(undoAction);
    btnUndo.addActionListener(undoAction);
    // Redo button
    btnRedo = CcddButtonPanelHandler.createButton("Redo", REDO_ICON, KeyEvent.VK_Y, "Redo the last undone edit action");
    // Create a listener for the Redo command
    ActionListener redoAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Redo the last cell edit that was undone
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            activeEditor.getFieldPanelUndoManager().redo();
            // Update the data field background colors
            activeEditor.getInputFieldPanelHandler().setFieldBackgound();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the redo listener to the Redo button and menu command
    mntmRedo.addActionListener(redoAction);
    btnRedo.addActionListener(redoAction);
    // Store button
    btnStore = CcddButtonPanelHandler.createButton("Store", STORE_ICON, KeyEvent.VK_S, "Store the table updates in the database");
    // Create a listener for the Store command
    ActionListener storeAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Store the changes to the table contents, if any, in the database
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // required columns are empty, and the user confirms the action
            if (activeEditor.isTableChanged() && !activeEditor.checkForMissingColumns() && new CcddDialogHandler().showMessageDialog(CcddTableEditorDialog.this, "<html><b>Store changes in project database?", "Store Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                // Store the changes for the currently displayed editor in the database
                storeChanges(activeEditor);
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the store listener to the Store button and menu command
    btnStore.addActionListener(storeAction);
    mntmStore.addActionListener(storeAction);
    // Close button
    btnCloseActive = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the table editor");
    // Add a listener for the Close active table command
    ActionListener closeAction = new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Close the active editor
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // confirm discarding the changes
            if (activeEditor.getTable().isLastCellValid() && (!activeEditor.isTableChanged() || new CcddDialogHandler().showMessageDialog(CcddTableEditorDialog.this, "<html><b>Discard changes?", "Discard Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON)) {
                // Close the active table. If this is the only table in the editor then close
                // the editor
                closeTableEditor(activeEditor.getOwnerName());
            }
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    };
    // Add the close listener to the Close button and menu command
    btnCloseActive.addActionListener(closeAction);
    mntmCloseActive.addActionListener(closeAction);
    // Create a listener for the Close All menu command
    mntmCloseAll.addActionListener(new ValidateCellActionListener() {

        /**
         ************************************************************************************
         * Close the table editor
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            windowCloseButtonAction();
        }

        /**
         ************************************************************************************
         * Get the reference to the currently displayed table
         ************************************************************************************
         */
        @Override
        protected CcddJTableHandler getTable() {
            return activeEditor.getTable();
        }
    });
    // Add buttons in the order in which they'll appear (left to right, top to bottom)
    buttonPnl.add(btnInsertRow);
    buttonPnl.add(btnMoveUp);
    buttonPnl.add(btnMoveLeft);
    buttonPnl.add(btnUndo);
    buttonPnl.add(btnStore);
    buttonPnl.add(btnDeleteRow);
    buttonPnl.add(btnMoveDown);
    buttonPnl.add(btnMoveRight);
    buttonPnl.add(btnRedo);
    buttonPnl.add(btnCloseActive);
    // Distribute the buttons across two rows
    setButtonRows(2);
    // Table Editors //////////////////////////////////////////////////////////////////////////
    // Create a tabbed pane for the editors to appear in
    tabbedPane = new DnDTabbedPane(JTabbedPane.TOP, CcddTableEditorDialog.class, true) {

        /**
         ************************************************************************************
         * Update the table editor list order following a tab move
         ************************************************************************************
         */
        @Override
        protected Object tabMoveCleanup(int oldTabIndex, int newTabIndex, Object tabContents) {
            CcddTableEditorHandler editor = (CcddTableEditorHandler) tabContents;
            // Check if the tab originated in the editor dialog
            if (oldTabIndex != -1) {
                // Get the reference to the moved tab's original location in the list
                editor = tableEditors.get(oldTabIndex);
                // Remove the table editor reference associated with the tab
                tableEditors.remove(oldTabIndex);
            } else // The tab originated in another editor dialog
            {
                // Bring the editor dialog to the foreground
                CcddTableEditorDialog.this.toFront();
            }
            // Check if the tab is to be placed within this editor
            if (newTabIndex != -1) {
                // Update the editor's reference to the dialog that owns it to this editor
                // dialog
                editor.setEditorDialog(CcddTableEditorDialog.this);
                // Add the table editor reference at the specified location
                tableEditors.add(newTabIndex - (oldTabIndex != -1 && newTabIndex > oldTabIndex ? 1 : 0), editor);
            }
            // Check if the last editor was removed from the dialog
            if (tableEditors.isEmpty()) {
                // Close the editor dialog
                CcddTableEditorDialog.this.closeFrame();
            } else // An editor remains in the dialog
            {
                // Update the active tab pointer
                activeEditor = tableEditors.get(tabbedPane.getSelectedIndex());
            }
            return editor;
        }

        /**
         ************************************************************************************
         * Move the specified tab's table to a new table editor dialog
         ************************************************************************************
         */
        @Override
        protected void spawnContainer(int tabIndex, Object tabContents) {
            // Create a new table editor dialog and place the editor from the other dialog into
            // it
            ccddMain.getTableEditorDialogs().add(new CcddTableEditorDialog(ccddMain, (CcddTableEditorHandler) tabContents));
        }
    };
    tabbedPane.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    // Listen for tab selection changes
    tabbedPane.addChangeListener(new ChangeListener() {

        /**
         ************************************************************************************
         * Update the editor to the one associated with the selected tab
         ************************************************************************************
         */
        @Override
        public void stateChanged(ChangeEvent ce) {
            // Check if the tab index is within bounds
            if (tabbedPane.getSelectedIndex() >= 0 && tabbedPane.getSelectedIndex() < tableEditors.size()) {
                // Set the active editor to the selected tab
                activeEditor = tableEditors.get(tabbedPane.getSelectedIndex());
                // Change the dialog's title to the active table's name
                (CcddTableEditorDialog.this).setTitle(activeEditor.getOwnerName());
                // Update the expand/collapse arrays check box
                updateExpandArrayCheckBox();
                // Check if the Show macros command is not in effect
                if (!mntmShowMacros.isSelected()) {
                    // Update the editor controls state
                    setControlsEnabled(true);
                }
            }
        }
    });
    // Add each table as a tab in the editor dialog tabbed pane
    addTablePanes(tableInformation, editor);
    // Set the first tab as the active editor
    activeEditor = tableEditors.get(0);
    // Display the table editor dialog
    createFrame(ccddMain.getMainFrame(), tabbedPane, buttonPnl, null, activeEditor.getOwnerName(), null);
    // Enable the editor controls
    setControlsEnabled(true);
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JTextComponent(javax.swing.text.JTextComponent) DnDTabbedPane(CCDD.CcddClassesComponent.DnDTabbedPane) ActionListener(java.awt.event.ActionListener) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) ChangeListener(javax.swing.event.ChangeListener) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 2 with ValidateCellActionListener

use of CCDD.CcddClassesComponent.ValidateCellActionListener in project CCDD by nasa.

the class CcddDataTypeEditorDialog method initialize.

/**
 ********************************************************************************************
 * Create the data type editor dialog. This is executed in a separate thread since it can take
 * a noticeable amount time to complete, and by using a separate thread the GUI is allowed to
 * continue to update. The GUI menu commands, however, are disabled until the telemetry
 * scheduler initialization completes execution
 ********************************************************************************************
 */
private void initialize() {
    // Build the data type editor dialog in the background
    CcddBackgroundCommand.executeInBackground(ccddMain, new BackgroundCommand() {

        // Create panels to hold the components of the dialog
        JPanel editorPnl = new JPanel(new GridBagLayout());

        JPanel buttonPnl = new JPanel();

        JButton btnClose;

        /**
         ************************************************************************************
         * Build the data type editor dialog
         ************************************************************************************
         */
        @Override
        protected void execute() {
            modifications = new ArrayList<TableModification>();
            loadedReferences = new ArrayList<DataTypeReference>();
            // Set the initial layout manager characteristics
            GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
            // Create a copy of the data type data so it can be used to determine if changes
            // are made
            committedData = dataTypeHandler.getDataTypeDataArray();
            // Define the panel to contain the table and place it in the editor
            JPanel tablePnl = new JPanel();
            tablePnl.setLayout(new BoxLayout(tablePnl, BoxLayout.X_AXIS));
            tablePnl.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
            tablePnl.add(createDataTypeTable());
            editorPnl.add(tablePnl, gbc);
            editorPnl.setBorder(BorderFactory.createEmptyBorder());
            // Create the cell editor for base data types
            createBasePrimitiveTypeCellEditor();
            // Set the modal undo manager and table references in the keyboard handler while
            // the data type editor is active
            ccddMain.getKeyboardHandler().setModalDialogReference(dataTypeTable.getUndoManager(), dataTypeTable);
            // New button
            JButton btnInsertRow = CcddButtonPanelHandler.createButton("Ins Row", INSERT_ICON, KeyEvent.VK_I, "Insert a new row into the table");
            // Create a listener for the Insert Row button
            btnInsertRow.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Insert a new row into the table at the selected location
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    dataTypeTable.insertEmptyRow(true);
                }
            });
            // Delete button
            JButton btnDeleteRow = CcddButtonPanelHandler.createButton("Del Row", DELETE_ICON, KeyEvent.VK_D, "Delete the selected row(s) from the table");
            // Create a listener for the Delete row button
            btnDeleteRow.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Delete the selected row(s) from the table
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    // Step through each row selected for deletion
                    for (int row : dataTypeTable.getSelectedRows()) {
                        // Get the data type name
                        String dataType = CcddDataTypeHandler.getDataTypeName(dataTypeTable.getValueAt(row, DataTypesColumn.USER_NAME.ordinal()).toString(), dataTypeTable.getValueAt(row, DataTypesColumn.C_NAME.ordinal()).toString());
                        // Check if the data type name is present
                        if (!dataType.isEmpty()) {
                            boolean isInUse = false;
                            // type, and not just text matching the data type's name
                            for (String dataTypeRef : getDataTypeReferences(dataType).getReferences()) {
                                // Split the reference into table name, column name, table
                                // type, and context
                                String[] tblColDescAndCntxt = dataTypeRef.split(TABLE_DESCRIPTION_SEPARATOR, 4);
                                String refComment = tblColDescAndCntxt[SearchResultsQueryColumn.COMMENT.ordinal()];
                                // Check if the match is within a sizeof() call
                                if (CcddVariableSizeAndConversionHandler.hasSizeof(tblColDescAndCntxt[SearchResultsQueryColumn.CONTEXT.ordinal()], dataType)) {
                                    // Set the flag to indicate the reference is to the data
                                    // type, and stop searching
                                    isInUse = true;
                                    break;
                                }
                                // Extract the viewable name and type of the table, and the
                                // name of the column containing the data type, Separate the
                                // column string into the individual column values
                                String[] refNameAndType = refComment.split(",");
                                String[] refColumns = CcddUtilities.splitAndRemoveQuotes(tblColDescAndCntxt[SearchResultsQueryColumn.CONTEXT.ordinal()]);
                                // Use the type and column to get the column's input data type
                                TypeDefinition typeDefn = ccddMain.getTableTypeHandler().getTypeDefinition(refNameAndType[1]);
                                // Get the indices for all columns that can reference a data
                                // type
                                List<Integer> primColumns = typeDefn.getColumnIndicesByInputType(InputDataType.PRIMITIVE);
                                primColumns.addAll(typeDefn.getColumnIndicesByInputType(InputDataType.PRIM_AND_STRUCT));
                                // Step through each of the data type columns
                                for (int column : primColumns) {
                                    // Check if the column contents matches the data type name
                                    if (refColumns[column].equals(dataType)) {
                                        // Set the flag to indicate the reference is to the
                                        // data type, and stop searching
                                        isInUse = true;
                                        break;
                                    }
                                }
                                // Check if the data type has a valid reference
                                if (isInUse) {
                                    // Stop searching
                                    break;
                                }
                            }
                            // Check if the data type is in use by a data table
                            if (isInUse) {
                                // Deselect the data type
                                dataTypeTable.removeRowSelectionInterval(row, row);
                                // Inform the user that the data type can't be deleted
                                new CcddDialogHandler().showMessageDialog(CcddDataTypeEditorDialog.this, "<html><b>Cannot delete data type '" + dataType + "'; data type is referenced by a data table", "Delete Data Type", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_OPTION);
                            }
                        }
                    }
                    dataTypeTable.deleteRow(true);
                }
            });
            // Move Up button
            JButton btnMoveUp = CcddButtonPanelHandler.createButton("Up", UP_ICON, KeyEvent.VK_U, "Move the selected row(s) up");
            // Create a listener for the Move Up button
            btnMoveUp.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Move the selected row(s) up in the table
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    dataTypeTable.moveRowUp();
                }
            });
            // Move Down button
            JButton btnMoveDown = CcddButtonPanelHandler.createButton("Down", DOWN_ICON, KeyEvent.VK_W, "Move the selected row(s) down");
            // Create a listener for the Move Down button
            btnMoveDown.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Move the selected row(s) down in the table
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    dataTypeTable.moveRowDown();
                }
            });
            // Undo button
            JButton btnUndo = CcddButtonPanelHandler.createButton("Undo", UNDO_ICON, KeyEvent.VK_Z, "Undo the last edit");
            // Create a listener for the Undo button
            btnUndo.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Undo the last cell edit
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    dataTypeTable.getUndoManager().undo();
                }
            });
            // Redo button
            JButton btnRedo = CcddButtonPanelHandler.createButton("Redo", REDO_ICON, KeyEvent.VK_Y, "Redo the last undone edit");
            // Create a listener for the Redo button
            btnRedo.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Redo the last cell edit that was undone
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    dataTypeTable.getUndoManager().redo();
                }
            });
            // Store the data types button
            JButton btnStore = CcddButtonPanelHandler.createButton("Store", STORE_ICON, KeyEvent.VK_S, "Store the data type(s)");
            // Create a listener for the Store button
            btnStore.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Store the data types
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    // the action
                    if (dataTypeTable.isTableChanged(committedData) && !checkForMissingColumns() && new CcddDialogHandler().showMessageDialog(CcddDataTypeEditorDialog.this, "<html><b>Store changes in project database?", "Store Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                        // Get a list of the data type modifications
                        buildUpdates();
                        // Update the tables affected by the changes to the data type(s)
                        dbTable.modifyTablePerDataTypeOrMacroChanges(modifications, getUpdatedData(), CcddDataTypeEditorDialog.this);
                    }
                }
            });
            // Close button
            btnClose = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the data type editor");
            // Create a listener for the Close button
            btnClose.addActionListener(new ValidateCellActionListener(dataTypeTable) {

                /**
                 ****************************************************************************
                 * Close the data type editor dialog
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    windowCloseButtonAction();
                }
            });
            // Add buttons in the order in which they'll appear (left to right, top to bottom)
            buttonPnl.add(btnInsertRow);
            buttonPnl.add(btnMoveUp);
            buttonPnl.add(btnUndo);
            buttonPnl.add(btnStore);
            buttonPnl.add(btnDeleteRow);
            buttonPnl.add(btnMoveDown);
            buttonPnl.add(btnRedo);
            buttonPnl.add(btnClose);
            // Distribute the buttons across two rows
            setButtonRows(2);
        }

        /**
         ************************************************************************************
         * Data type editor dialog creation complete
         ************************************************************************************
         */
        @Override
        protected void complete() {
            // Display the data type editor dialog
            showOptionsDialog(ccddMain.getMainFrame(), editorPnl, buttonPnl, btnClose, DIALOG_TITLE, true);
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) ArrayList(java.util.ArrayList) TypeDefinition(CCDD.CcddTableTypeHandler.TypeDefinition) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) BackgroundCommand(CCDD.CcddBackgroundCommand.BackgroundCommand)

Example 3 with ValidateCellActionListener

use of CCDD.CcddClassesComponent.ValidateCellActionListener in project CCDD by nasa.

the class CcddScriptManagerDialog method initialize.

/**
 ********************************************************************************************
 * Create the script association manager dialog. This is executed in a separate thread since it
 * can take a noticeable amount time to complete, and by using a separate thread the GUI is
 * allowed to continue to update. The GUI menu commands, however, are disabled until the
 * telemetry scheduler initialization completes execution
 ********************************************************************************************
 */
private void initialize() {
    // user confirms ignoring the changes
    if (ccddMain.ignoreUncommittedChanges("Script Manager", "Ignore changes?", false, null, CcddScriptManagerDialog.this)) {
        // Build the script association manager dialog in the background
        CcddBackgroundCommand.executeInBackground(ccddMain, new BackgroundCommand() {

            // Create panels to hold the components of the dialog
            JPanel dialogPnl = new JPanel(new GridBagLayout());

            JPanel buttonPnl = new JPanel();

            /**
             ********************************************************************************
             * Build the script association manager dialog
             ********************************************************************************
             */
            @Override
            protected void execute() {
                isNodeSelectionChanging = false;
                // Create borders for the input fields
                border = BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, Color.GRAY), BorderFactory.createEmptyBorder(ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing(), ModifiableSpacingInfo.INPUT_FIELD_PADDING.getSpacing()));
                Border emptyBorder = BorderFactory.createEmptyBorder();
                // Set the initial layout manager characteristics
                GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing(), ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing()), 0, 0);
                dialogPnl.setBorder(emptyBorder);
                // Create a panel to contain the script file name, association name, and
                // association description labels and fields
                JPanel inputPnl = new JPanel(new GridBagLayout());
                // Add the script file selection components to the input panel
                inputPnl.add(createScriptSelectionPanel(), gbc);
                // Create the name label and field, and add these to the input panel
                JLabel nameLbl = new JLabel("Script association name");
                nameLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
                gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
                gbc.gridy++;
                inputPnl.add(nameLbl, gbc);
                nameFld = new JTextField("", 1);
                nameFld.setFont(ModifiableFontInfo.INPUT_TEXT.getFont());
                nameFld.setEditable(true);
                nameFld.setForeground(ModifiableColorInfo.INPUT_TEXT.getColor());
                nameFld.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
                nameFld.setBorder(border);
                gbc.insets.top = 0;
                gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing();
                gbc.weightx = 1.0;
                gbc.gridy++;
                inputPnl.add(nameFld, gbc);
                // Create the description label and field, and add these to the input panel
                JLabel descriptionLbl = new JLabel("Script association description");
                descriptionLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
                gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
                gbc.insets.left = 0;
                gbc.weightx = 0.0;
                gbc.gridy++;
                inputPnl.add(descriptionLbl, gbc);
                descriptionFld = new JTextArea("", 3, 1);
                descriptionFld.setFont(ModifiableFontInfo.INPUT_TEXT.getFont());
                descriptionFld.setEditable(true);
                descriptionFld.setWrapStyleWord(true);
                descriptionFld.setLineWrap(true);
                descriptionFld.setForeground(ModifiableColorInfo.INPUT_TEXT.getColor());
                descriptionFld.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
                descriptionFld.setBorder(emptyBorder);
                JScrollPane scrollPane = new JScrollPane(descriptionFld);
                scrollPane.setBackground(ModifiableColorInfo.INPUT_BACK.getColor());
                scrollPane.setBorder(emptyBorder);
                scrollPane.setViewportBorder(border);
                scrollPane.setMinimumSize(scrollPane.getPreferredSize());
                gbc.insets.top = 0;
                gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing();
                gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() * 2;
                gbc.gridwidth = GridBagConstraints.REMAINDER;
                gbc.weightx = 1.0;
                gbc.weighty = 1.0;
                gbc.gridy++;
                inputPnl.add(scrollPane, gbc);
                // Add the input panel and the table selection components to the inputs pane
                // within a horizontally split pane. Use a separator to denote the split pane's
                // drag component
                JSeparator inputSep = new JSeparator(SwingConstants.VERTICAL);
                inputSep.setForeground(dialogPnl.getBackground().darker());
                CustomSplitPane inputsPane = new CustomSplitPane(inputPnl, createSelectionPanel("Select associated tables", TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION), inputSep, JSplitPane.HORIZONTAL_SPLIT);
                // Add the inputs pane and the script association table components to the
                // dialog within a vertically split pane. Use a separator to denote the split
                // pane's drag component
                JSeparator assnSep = new JSeparator();
                assnSep.setForeground(dialogPnl.getBackground().darker());
                gbc.weighty = 1.0;
                gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
                gbc.insets.bottom = 0;
                gbc.gridy = 0;
                dialogPnl.add(new CustomSplitPane(inputsPane, scriptHandler.getAssociationsPanel("Script Associations", true, CcddScriptManagerDialog.this), assnSep, JSplitPane.VERTICAL_SPLIT), gbc);
                // Get a reference to the script associations table to shorten subsequent calls
                assnsTable = scriptHandler.getAssociationsTable();
                // Store the initial table data
                doAssnUpdatesComplete(false);
                // Add a listener for script association table row selection changes
                assnsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

                    /**
                     ************************************************************************
                     * Handle a table row selection change. Populate the script description
                     * field, file field, and table tree based on the first selected
                     * associations table row
                     ************************************************************************
                     */
                    @Override
                    public void valueChanged(ListSelectionEvent lse) {
                        // for a keyboard input this returns false)
                        if (!lse.getValueIsAdjusting()) {
                            // Get the first selected table row
                            int row = assnsTable.getSelectedRow();
                            // Check if a table row item is selected
                            if (row != -1) {
                                // Store the association name in the the name field
                                nameFld.setText(assnsTable.getValueAt(row, assnsTable.convertColumnIndexToView(AssociationsTableColumnInfo.NAME.ordinal())).toString());
                                // Store the association description in the the description
                                // field
                                descriptionFld.setText(assnsTable.getValueAt(row, assnsTable.convertColumnIndexToView(AssociationsTableColumnInfo.DESCRIPTION.ordinal())).toString());
                                // Store the script file name with path in the the script file
                                // field
                                scriptFld.setText(assnsTable.getValueAt(row, assnsTable.convertColumnIndexToView(AssociationsTableColumnInfo.SCRIPT_FILE.ordinal())).toString());
                                // Separate the table member portion into the individual table
                                // names. The line breaks used for HTML formatting must be
                                // replaced by line feed characters so that the split is made
                                // correctly
                                String[] tableNames = CcddUtilities.removeHTMLTags(assnsTable.getValueAt(row, assnsTable.convertColumnIndexToView(AssociationsTableColumnInfo.MEMBERS.ordinal())).toString().replaceAll("<br>", "\n")).split(Pattern.quote(ASSN_TABLE_SEPARATOR));
                                List<TreePath> paths = new ArrayList<>();
                                // Step through each table name
                                for (String tableName : tableNames) {
                                    ToolTipTreeNode node;
                                    // Check if the name refers to a group
                                    if (tableName.startsWith(GROUP_DATA_FIELD_IDENT)) {
                                        // Get the node in the table tree for this group
                                        node = tableTree.getNodeByNodeName(tableName.substring(GROUP_DATA_FIELD_IDENT.length()));
                                    } else // The name refers to a table
                                    {
                                        // Get the node in the table tree for this table name
                                        node = tableTree.getNodeByNodePath(tableName);
                                    }
                                    // Check if the table name is in the tree
                                    if (node != null) {
                                        // Add the path to the list
                                        paths.add(CcddCommonTreeHandler.getPathFromNode(node));
                                    }
                                }
                                // Select the associated tables in the table tree
                                tableTree.setSelectionPaths(paths.toArray(new TreePath[0]));
                            }
                        }
                    }
                });
                // Define the buttons for the lower panel: Add association button
                JButton btnAddAssn = CcddButtonPanelHandler.createButton("Add", INSERT_ICON, KeyEvent.VK_A, "Add the currently defined script association");
                // Add a listener for the Add button
                btnAddAssn.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Add a new script association
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        // Check that a script is specified
                        if (!scriptFld.getText().trim().isEmpty()) {
                            addAssociation(TableInsertionPoint.START);
                        } else // The script file field is blank
                        {
                            // Inform the user that a script must be selected
                            new CcddDialogHandler().showMessageDialog(ccddMain.getMainFrame(), "<html><b>Must enter or select a script", "Script Missing", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                        }
                    }
                });
                // Remove script association(s) button
                JButton btnRemoveAssn = CcddButtonPanelHandler.createButton("Remove", DELETE_ICON, KeyEvent.VK_R, "Remove the selected script association(s)");
                // Add a listener for the Remove button
                btnRemoveAssn.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Remove the selected script association(s)
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        removeAssociations();
                    }
                });
                // Replace script association(s) button
                JButton btnReplaceAssn = CcddButtonPanelHandler.createButton("Replace", REPLACE_ICON, KeyEvent.VK_P, "Replace the selected script association");
                // Add a listener for the Replace button
                btnReplaceAssn.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Replace the selected script association
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        replaceAssociation();
                    }
                });
                // Move Up button
                JButton btnMoveUp = CcddButtonPanelHandler.createButton("Up", UP_ICON, KeyEvent.VK_U, "Move the selected row(s) up");
                // Create a listener for the Move Up command
                btnMoveUp.addActionListener(new ValidateCellActionListener() {

                    /**
                     ************************************************************************
                     * Move the selected row(s) up in the table
                     ************************************************************************
                     */
                    @Override
                    protected void performAction(ActionEvent ae) {
                        assnsTable.moveRowUp();
                    }

                    /**
                     ************************************************************************
                     * Get the reference to the currently displayed table
                     ************************************************************************
                     */
                    @Override
                    protected CcddJTableHandler getTable() {
                        return assnsTable;
                    }
                });
                // Move Down button
                JButton btnMoveDown = CcddButtonPanelHandler.createButton("Down", DOWN_ICON, KeyEvent.VK_W, "Move the selected row(s) down");
                // Create a listener for the Move Down command
                btnMoveDown.addActionListener(new ValidateCellActionListener() {

                    /**
                     ************************************************************************
                     * Move the selected row(s) down in the table
                     ************************************************************************
                     */
                    @Override
                    protected void performAction(ActionEvent ae) {
                        assnsTable.moveRowDown();
                    }

                    /**
                     ************************************************************************
                     * Get the reference to the currently displayed table
                     ************************************************************************
                     */
                    @Override
                    protected CcddJTableHandler getTable() {
                        return assnsTable;
                    }
                });
                // Undo button
                JButton btnUndo = CcddButtonPanelHandler.createButton("Undo", UNDO_ICON, KeyEvent.VK_Z, "Undo the last edit action");
                // Create a listener for the Undo command
                btnUndo.addActionListener(new ValidateCellActionListener() {

                    /**
                     ************************************************************************
                     * Undo the last addition to the script association table
                     ************************************************************************
                     */
                    @Override
                    protected void performAction(ActionEvent ae) {
                        assnsTable.getUndoManager().undo();
                    }

                    /**
                     ************************************************************************
                     * Get the reference to the currently displayed table
                     ************************************************************************
                     */
                    @Override
                    protected CcddJTableHandler getTable() {
                        return assnsTable;
                    }
                });
                // Redo button
                JButton btnRedo = CcddButtonPanelHandler.createButton("Redo", REDO_ICON, KeyEvent.VK_Y, "Redo the last undone edit action");
                // Create a listener for the Redo command
                btnRedo.addActionListener(new ValidateCellActionListener() {

                    /**
                     ************************************************************************
                     * Redo the last addition to the script association table that was undone
                     ************************************************************************
                     */
                    @Override
                    protected void performAction(ActionEvent ae) {
                        assnsTable.getUndoManager().redo();
                    }

                    /**
                     ************************************************************************************
                     * Get the reference to the currently displayed table
                     ************************************************************************************
                     */
                    @Override
                    protected CcddJTableHandler getTable() {
                        return assnsTable;
                    }
                });
                // Script execution button
                btnExecute = CcddButtonPanelHandler.createButton("Execute", EXECUTE_ICON, KeyEvent.VK_E, "Execute the selected script association(s)");
                // Add a listener for the Execute button
                btnExecute.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Execute the selected script association(s)
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        // Execute the selected associations
                        scriptHandler.executeScriptAssociations(tableTree, CcddScriptManagerDialog.this);
                    }
                });
                // Store script associations button
                JButton btnStoreAssns = CcddButtonPanelHandler.createButton("Store", STORE_ICON, KeyEvent.VK_S, "Store the updated script associations to the database");
                // Add a listener for the Store button
                btnStoreAssns.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Store the script associations in the database
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        // associations
                        if (assnsTable.isTableChanged(committedAssnsData, Arrays.asList(new Integer[] { AssociationsTableColumnInfo.AVAILABLE.ordinal() })) && new CcddDialogHandler().showMessageDialog(CcddScriptManagerDialog.this, "<html><b>Store script associations?", "Store Associations", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                            // Disable the dialog buttons until the updates complete
                            setControlsEnabled(false);
                            // Store the script associations list into the database
                            dbTable.storeInformationTableInBackground(InternalTable.ASSOCIATIONS, createAssociationsFromTable(), null, CcddScriptManagerDialog.this);
                        }
                    }
                });
                // Close button
                JButton btnClose = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the script association manager");
                // Add a listener for the Close button
                btnClose.addActionListener(new ActionListener() {

                    /**
                     ************************************************************************
                     * Close the script association dialog
                     ************************************************************************
                     */
                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        // user elects to discard the changes
                        if (!isAssociationsChanged() || new CcddDialogHandler().showMessageDialog(CcddScriptManagerDialog.this, "<html><b>Discard changes?", "Discard Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                            // Reset the reference to the script associations manager in the
                            // script handler since the handler remains active)
                            scriptHandler.setScriptDialog(null);
                            // Close the dialog
                            closeFrame();
                        }
                    }
                });
                // Add buttons in the order in which they'll appear (left to right, top to
                // bottom)
                buttonPnl.add(btnAddAssn);
                buttonPnl.add(btnReplaceAssn);
                buttonPnl.add(btnMoveUp);
                buttonPnl.add(btnUndo);
                buttonPnl.add(btnStoreAssns);
                buttonPnl.add(btnRemoveAssn);
                buttonPnl.add(btnExecute);
                buttonPnl.add(btnMoveDown);
                buttonPnl.add(btnRedo);
                buttonPnl.add(btnClose);
                // Distribute the buttons across two rows
                setButtonRows(2);
            }

            /**
             ********************************************************************************
             * Script association manager dialog creation complete
             ********************************************************************************
             */
            @Override
            protected void complete() {
                // Display the script association management dialog
                createFrame(ccddMain.getMainFrame(), dialogPnl, buttonPnl, btnExecute, DIALOG_TITLE, null);
            }
        });
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) CustomSplitPane(CCDD.CcddClassesComponent.CustomSplitPane) JSeparator(javax.swing.JSeparator) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) ToolTipTreeNode(CCDD.CcddClassesComponent.ToolTipTreeNode) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) TableInsertionPoint(CCDD.CcddConstants.TableInsertionPoint) ListSelectionListener(javax.swing.event.ListSelectionListener) TreePath(javax.swing.tree.TreePath) ActionListener(java.awt.event.ActionListener) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) BackgroundCommand(CCDD.CcddBackgroundCommand.BackgroundCommand) Border(javax.swing.border.Border) BevelBorder(javax.swing.border.BevelBorder)

Example 4 with ValidateCellActionListener

use of CCDD.CcddClassesComponent.ValidateCellActionListener in project CCDD by nasa.

the class CcddTelemetrySchedulerDialog method initialize.

/**
 ********************************************************************************************
 * Create the telemetry scheduler dialog. This is executed in a separate thread since it can
 * take a noticeable amount time to complete, and by using a separate thread the GUI is allowed
 * to continue to update. The GUI menu commands, however, are disabled until the telemetry
 * scheduler initialization completes execution
 ********************************************************************************************
 */
private void initialize() {
    // Build the telemetry scheduler dialog in the background
    CcddBackgroundCommand.executeInBackground(ccddMain, new BackgroundCommand() {

        // Create a button panel
        JPanel buttonPnl = new JPanel();

        /**
         ************************************************************************************
         * Build the telemetry scheduler dialog
         ************************************************************************************
         */
        @Override
        protected void execute() {
            // Create a tree containing all of the variables. This is used for determining
            // bit-packing and variable relative position
            allVariableTree = new CcddTableTreeHandler(ccddMain, TableTreeType.INSTANCE_STRUCTURES_WITH_PRIMITIVES_AND_RATES, ccddMain.getMainFrame());
            // Expand the tree so that all nodes are 'visible'
            allVariableTree.setTreeExpansion(true);
            allVariableTreePaths = new ArrayList<String>();
            // Step through all of the nodes in the variable tree
            for (Enumeration<?> element = allVariableTree.getRootNode().preorderEnumeration(); element.hasMoreElements(); ) {
                // Convert the variable path to a string and add it to the list
                allVariableTreePaths.add(allVariableTree.getFullVariablePath(((ToolTipTreeNode) element.nextElement()).getPath()));
            }
            // Load the stored telemetry scheduler data from the project database
            schedulerDb.loadStoredData();
            // Auto-fill button
            btnAutoFill = CcddButtonPanelHandler.createButton("Auto-fill", AUTO_CREATE_ICON, KeyEvent.VK_F, "Auto-fill the message table with the variables");
            // Create a listener for the Auto-fill button
            btnAutoFill.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Auto-fill the variables into the telemetry scheduler for the currently
                 * selected data stream
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    // Run auto-fill
                    activeSchHandler.autoFill();
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Clear Rate button
            btnClearRate = CcddButtonPanelHandler.createButton("Clear Rate", UNDO_ICON, KeyEvent.VK_R, "Remove the variables of the currently selected rate from all messages");
            // Add a listener for the Clear Rate button
            btnClearRate.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Remove the variables of the currently selected rate from all messages in the
                 * currently selected data stream
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    activeSchHandler.getSchedulerEditor().clearVariablesFromMessages(activeSchHandler.getSchedulerInput().getSelectedRate());
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Clear Msgs button
            btnClear = CcddButtonPanelHandler.createButton("Clear Msgs", UNDO_ICON, KeyEvent.VK_R, "Remove the variables from all messages");
            // Add a listener for the Clear Msgs button
            btnClear.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Remove the variables from all messages in the currently selected data stream
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    activeSchHandler.getSchedulerEditor().clearVariablesFromMessages(null);
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Add Sub-msg button
            btnAddSubMessage = CcddButtonPanelHandler.createButton("Add Sub-msg", INSERT_ICON, KeyEvent.VK_A, "Add a sub-message to the currently selected message");
            // Create a listener for the Add Sub-msg button
            btnAddSubMessage.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Add a sub-message to the current message
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    activeSchHandler.getSchedulerEditor().addSubMessage();
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Del Sub-msg button
            btnDeleteSubMessage = CcddButtonPanelHandler.createButton("Del Sub-msg", DELETE_ICON, KeyEvent.VK_D, "Delete the currently selected sub-message");
            // Create a listener for the Del Sub-msg button
            btnDeleteSubMessage.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Delete the current sub-message
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    activeSchHandler.getSchedulerEditor().deleteSubMessage();
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Assign message names and IDs button
            btnAssign = CcddButtonPanelHandler.createButton("Assign Msgs", AUTO_CREATE_ICON, KeyEvent.VK_M, "Automatically assign message names and/or IDs to the messages and sub-messages");
            // Add a listener for the Assign Msgs button
            btnAssign.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Automatically assign names and/or IDs to the telemetry messages and
                 * sub-messages
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    new CcddAssignMessageIDDialog(ccddMain, activeSchHandler.getCurrentMessages(), CcddTelemetrySchedulerDialog.this);
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Store button
            btnStore = CcddButtonPanelHandler.createButton("Store", STORE_ICON, KeyEvent.VK_S, "Store the message updates in the project database");
            // Add a listener for the Store button
            btnStore.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Store the data from the various data streams into the database
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    // storing the changes
                    if (isChanges() && new CcddDialogHandler().showMessageDialog(CcddTelemetrySchedulerDialog.this, "<html><b>Store changes?", "Store Changes", JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
                        // Store the messages in the project database
                        storeData();
                    }
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Create a button to close the dialog
            btnClose = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the telemetry scheduler");
            // Add a listener for the Close button
            btnClose.addActionListener(new ValidateCellActionListener() {

                /**
                 ****************************************************************************
                 * Close the telemetry scheduler dialog
                 ****************************************************************************
                 */
                @Override
                protected void performAction(ActionEvent ae) {
                    windowCloseButtonAction();
                }

                /**
                 ****************************************************************************
                 * Get the reference to the currently displayed table
                 ****************************************************************************
                 */
                @Override
                protected CcddJTableHandler getTable() {
                    return activeSchHandler.getSchedulerEditor().getTable();
                }
            });
            // Add buttons in the order in which they'll appear (left to right, top to bottom)
            buttonPnl.add(btnAutoFill);
            buttonPnl.add(btnClearRate);
            buttonPnl.add(btnAddSubMessage);
            buttonPnl.add(btnStore);
            buttonPnl.add(btnAssign);
            buttonPnl.add(btnClear);
            buttonPnl.add(btnDeleteSubMessage);
            buttonPnl.add(btnClose);
            // Create two rows of buttons
            setButtonRows(2);
            // Create a tabbed pane in which to place the scheduler handlers
            tabbedPane = new DnDTabbedPane(SwingConstants.TOP) {

                /**
                 ****************************************************************************
                 * Update the scheduler list order following a tab move
                 ****************************************************************************
                 */
                @Override
                protected Object tabMoveCleanup(int oldTabIndex, int newTabIndex, Object tabContents) {
                    // Adjust the new tab index if moving the tab to a higher index
                    newTabIndex -= newTabIndex > oldTabIndex ? 1 : 0;
                    // Re-order the rate information based on the new tab order
                    // Re-order the rate information based on the new tab order
                    RateInformation[] rateInfoArray = rateHandler.getRateInformation().toArray(new RateInformation[0]);
                    rateInfoArray = (RateInformation[]) CcddUtilities.moveArrayMember(rateInfoArray, oldTabIndex, newTabIndex);
                    List<RateInformation> rateInfoList = new ArrayList<RateInformation>(rateInfoArray.length);
                    rateInfoList.addAll(Arrays.asList(rateInfoArray));
                    rateHandler.setRateInformation(rateInfoList);
                    // Get the reference to the moved tab's original location in the list
                    CcddSchedulerHandler editor = schHandlers.get(oldTabIndex);
                    // Remove the tab
                    schHandlers.remove(oldTabIndex);
                    // Add the tab at its new location
                    schHandlers.add(newTabIndex, editor);
                    // Update the active tab pointer to the moved tab
                    activeSchHandler = schHandlers.get(tabbedPane.getSelectedIndex());
                    return editor;
                }
            };
            tabbedPane.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
            // Listen for tab selection changes
            tabbedPane.addChangeListener(new ChangeListener() {

                /**
                 ****************************************************************************
                 * Update the editor to the one associated with the selected tab
                 ****************************************************************************
                 */
                @Override
                public void stateChanged(ChangeEvent ce) {
                    // Set the active editor to the one indicated by the currently selected tab
                    activeSchHandler = schHandlers.get(tabbedPane.getSelectedIndex());
                }
            });
            // Add the scheduler handlers to the tabbed pane
            addDataStreams();
            // Set the first tab as the active editor
            activeSchHandler = schHandlers.get(0);
        }

        /**
         ************************************************************************************
         * Telemetry scheduler dialog creation complete
         ************************************************************************************
         */
        @Override
        protected void complete() {
            // Display the telemetry scheduler dialog
            showOptionsDialog(ccddMain.getMainFrame(), tabbedPane, buttonPnl, btnClose, "Telemetry Scheduler", true);
        }
    });
}
Also used : JPanel(javax.swing.JPanel) Enumeration(java.util.Enumeration) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) RateInformation(CCDD.CcddClassesDataTable.RateInformation) DnDTabbedPane(CCDD.CcddClassesComponent.DnDTabbedPane) ChangeEvent(javax.swing.event.ChangeEvent) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) ChangeListener(javax.swing.event.ChangeListener) BackgroundCommand(CCDD.CcddBackgroundCommand.BackgroundCommand)

Example 5 with ValidateCellActionListener

use of CCDD.CcddClassesComponent.ValidateCellActionListener in project CCDD by nasa.

the class CcddFieldEditorDialog method initialize.

/**
 ********************************************************************************************
 * Create the data field editor dialog
 *
 * @param minimumWidth
 *            minimum pixel width of the caller
 ********************************************************************************************
 */
private void initialize(final int minimumWidth) {
    // Store the field information
    currentData = fieldPnlHndlr.getFieldHandler().getFieldEditorDefinition();
    // Define the table data field editor JTable
    fieldTable = new CcddJTableHandler() {

        /**
         ************************************************************************************
         * Allow resizing of all columns except the Size, Required, and Applicability columns
         ************************************************************************************
         */
        @Override
        protected boolean isColumnResizable(int column) {
            return column != FieldEditorColumnInfo.REQUIRED.ordinal() && column != FieldEditorColumnInfo.SIZE.ordinal() && column != FieldEditorColumnInfo.APPLICABILITY.ordinal();
        }

        /**
         ************************************************************************************
         * Allow multiple line display in all but the Required, Size, and Applicability columns
         ************************************************************************************
         */
        @Override
        protected boolean isColumnMultiLine(int column) {
            return column != FieldEditorColumnInfo.REQUIRED.ordinal() && column != FieldEditorColumnInfo.SIZE.ordinal() && column != FieldEditorColumnInfo.APPLICABILITY.ordinal();
        }

        /**
         ************************************************************************************
         * Hide the specified column(s)
         ************************************************************************************
         */
        @Override
        protected boolean isColumnHidden(int column) {
            return column == FieldEditorColumnInfo.VALUE.ordinal() || (!includeApplicability && column == FieldEditorColumnInfo.APPLICABILITY.ordinal());
        }

        /**
         ************************************************************************************
         * Display the specified column(s) as check boxes
         ************************************************************************************
         */
        @Override
        protected boolean isColumnBoolean(int column) {
            return column == FieldEditorColumnInfo.REQUIRED.ordinal();
        }

        /**
         ************************************************************************************
         * Override isCellEditable so that all columns except the line separators and breaks
         * can be edited
         ************************************************************************************
         */
        @Override
        public boolean isCellEditable(int row, int column) {
            boolean isEditable = true;
            // Check that the table has rows
            if (fieldTable.getRowCount() != 0) {
                // Get the text in the input type column
                String cellValue = fieldTable.getValueAt(row, inputTypeIndex).toString();
                // Check if the row represents a separator or line break
                if (cellValue.equals(InputDataType.SEPARATOR.getInputName()) || cellValue.equals(InputDataType.BREAK.getInputName())) {
                    // Set the flag to indicate this cell is not editable
                    isEditable = false;
                }
            }
            return isEditable;
        }

        /**
         ************************************************************************************
         * Allow pasting data into the data field cells
         ************************************************************************************
         */
        @Override
        protected boolean isDataAlterable(Object[] rowData, int row, int column) {
            return isCellEditable(convertRowIndexToView(row), convertColumnIndexToView(column));
        }

        /**
         ************************************************************************************
         * Override the CcddJTableHandler method to prevent deleting the contents of the cell
         * at the specified row and column
         *
         * @param row
         *            table row index in view coordinates
         *
         * @param column
         *            table column index in view coordinates
         *
         * @return false if the cell contains a combo box; true otherwise
         ************************************************************************************
         */
        @Override
        protected boolean isCellBlankable(int row, int column) {
            // Convert the column index to model coordinates
            column = convertColumnIndexToModel(column);
            return column != FieldEditorColumnInfo.INPUT_TYPE.ordinal() && column != FieldEditorColumnInfo.APPLICABILITY.ordinal();
        }

        /**
         ************************************************************************************
         * Validate changes to the editable cells
         *
         * @param tableData
         *            list containing the table data row arrays
         *
         * @param row
         *            table model row number
         *
         * @param column
         *            table model column number
         *
         * @param oldValue
         *            original cell contents
         *
         * @param newValue
         *            new cell contents
         *
         * @param showMessage
         *            true to display the invalid input dialog, if applicable
         *
         * @param isMultiple
         *            true if this is one of multiple cells to be entered and checked; false if
         *            only a single input is being entered
         *
         * @return Always returns false
         ***********************************************************************************
         */
        @Override
        protected Boolean validateCellContent(List<Object[]> tableData, int row, int column, Object oldValue, Object newValue, Boolean showMessage, boolean isMultiple) {
            // Reset the flag that indicates the last edited cell's content is invalid
            setLastCellValid(true);
            // Create a string version of the new value
            String newValueS = newValue.toString();
            try {
                // Check if the field name has been changed and if the name isn't blank
                if (column == FieldEditorColumnInfo.NAME.ordinal() && !newValueS.isEmpty()) {
                    // creating a duplicate
                    for (int otherRow = 0; otherRow < getRowCount(); otherRow++) {
                        // matches the one being added (case insensitive)
                        if (otherRow != row && newValueS.equalsIgnoreCase(tableData.get(otherRow)[column].toString())) {
                            throw new CCDDException("Field name '" + newValueS + "' already in use");
                        }
                    }
                } else // Check if this is the field size column
                if (column == FieldEditorColumnInfo.SIZE.ordinal()) {
                    // Check if the field size is not a positive integer
                    if (!newValueS.matches(InputDataType.INT_POSITIVE.getInputMatch())) {
                        throw new CCDDException("Field size must be a positive integer");
                    }
                    // the interface unusable
                    if (Integer.valueOf(newValueS) > ModifiableSizeInfo.MAX_DATA_FIELD_CHAR_WIDTH.getSize()) {
                        throw new CCDDException("Field size must be less than or equal to " + ModifiableSizeInfo.MAX_DATA_FIELD_CHAR_WIDTH.getSize());
                    }
                    // Remove any unneeded characters and store the cleaned number
                    tableData.get(row)[column] = Integer.valueOf(newValueS.replaceAll(InputDataType.INT_POSITIVE.getInputMatch(), "$1"));
                }
            } catch (CCDDException ce) {
                // Set the flag that indicates the last edited cell's content is invalid
                setLastCellValid(false);
                // Check if the input error dialog should be displayed
                if (showMessage) {
                    // Inform the user that the input value is invalid
                    new CcddDialogHandler().showMessageDialog(CcddFieldEditorDialog.this, "<html><b>" + ce.getMessage(), "Invalid Input", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                }
                // Restore the column name to its original value and set the error message
                tableData.get(row)[column] = oldValue;
            }
            return false;
        }

        /**
         ************************************************************************************
         * Load the table data field definition values into the table and format the table
         * cells
         ************************************************************************************
         */
        @Override
        protected void loadAndFormatData() {
            // Place the data into the table model along with the column names, set up the
            // editors and renderers for the table cells, set up the table grid lines, and
            // calculate the minimum width required to display the table information
            setUpdatableCharacteristics(currentData, FieldEditorColumnInfo.getColumnNames(), null, FieldEditorColumnInfo.getToolTips(), true, true, true);
        }

        /**
         ************************************************************************************
         * Override prepareRenderer to allow adjusting the background colors of table cells
         ************************************************************************************
         */
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            JComponent comp = (JComponent) super.prepareRenderer(renderer, row, column);
            // invalid highlighting, if applicable)
            if (!(isFocusOwner() && isRowSelected(row) && (isColumnSelected(column) || !getColumnSelectionAllowed()))) {
                boolean found = true;
                // Check if the cell is required and is empty
                if (FieldEditorColumnInfo.values()[fieldTable.convertColumnIndexToModel(column)].isRequired() && fieldTable.getValueAt(row, column).toString().isEmpty()) {
                    // Set the flag indicating that the cell value is invalid
                    found = false;
                } else // Check if this is the input type column
                if (column == inputTypeIndex && inputTypeCbox != null) {
                    found = false;
                    // Check if the type is a separator or line break
                    if (fieldTable.getValueAt(row, column).equals(InputDataType.SEPARATOR.getInputName()) || fieldTable.getValueAt(row, column).equals(InputDataType.BREAK.getInputName())) {
                        found = true;
                    } else // The type is not a separator or line break
                    {
                        // Step through each combo box item
                        for (int index = 0; index < inputTypeCbox.getItemCount() && !found; index++) {
                            // Check if the cell matches the combo box item
                            if (inputTypeCbox.getItemAt(index).equals(fieldTable.getValueAt(row, column).toString())) {
                                // Set the flag indicating that the cell value is valid
                                found = true;
                            }
                        }
                    }
                }
                // Check if the cell value is invalid
                if (!found) {
                    // Change the cell's background color
                    comp.setBackground(ModifiableColorInfo.REQUIRED_BACK.getColor());
                }
            }
            return comp;
        }

        /**
         ************************************************************************************
         * Override the CcddJTableHandler method to produce an array containing empty values
         * for a new row in this table
         *
         * @return Array containing blank cell values for a new row
         ************************************************************************************
         */
        @Override
        protected Object[] getEmptyRow() {
            return FieldEditorColumnInfo.getEmptyRow();
        }

        /**
         ************************************************************************************
         * Handle a change to the table's content
         ************************************************************************************
         */
        @Override
        protected void processTableContentChange() {
            // Add or remove the change indicator based on whether or not any unstored changes
            // exist
            setTitle(DIALOG_TITLE + ": " + ownerName + (fieldTable.isTableChanged(currentData) ? "*" : ""));
            // Force the table to redraw so that changes to the cells are displayed
            repaint();
        }
    };
    // Place the table into a scroll pane
    JScrollPane scrollPane = new JScrollPane(fieldTable);
    // Disable storage of edit operations during table creation
    fieldTable.getUndoHandler().setAllowUndo(false);
    // Set common table parameters and characteristics
    fieldTable.setFixedCharacteristics(scrollPane, true, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, TableSelectionMode.SELECT_BY_CELL, false, ModifiableColorInfo.TABLE_BACK.getColor(), true, true, ModifiableFontInfo.DATA_TABLE_CELL.getFont(), true);
    // Create a drop-down combo box to display the available field input data types
    setUpInputTypeColumn();
    // Create a drop-down combo box to display the available field applicability types
    setUpApplicabilityColumn();
    // Re-enable storage of edit operations
    fieldTable.getUndoHandler().setAllowUndo(true);
    // Define the editor panel to contain the table
    JPanel editorPanel = new JPanel();
    editorPanel.setLayout(new BoxLayout(editorPanel, BoxLayout.X_AXIS));
    editorPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    editorPanel.add(scrollPane);
    // Set the initial layout manager characteristics
    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
    // Create an outer panel to put the editor panel in (the border doesn't appear without
    // this)
    outerPanel = new JPanel(new GridBagLayout());
    outerPanel.add(editorPanel, gbc);
    outerPanel.setBorder(BorderFactory.createEmptyBorder());
    // Create the lower (button) panel
    JPanel buttonPnl = new JPanel();
    // Insert button
    btnInsertRow = CcddButtonPanelHandler.createButton("Ins Row", INSERT_ICON, KeyEvent.VK_I, "Insert a new row into the table");
    // Create a listener for the Insert Row button
    btnInsertRow.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Insert a new row into the table at the selected location
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.insertEmptyRow(true);
        }
    });
    // Delete button
    btnDeleteRow = CcddButtonPanelHandler.createButton("Del Row", DELETE_ICON, KeyEvent.VK_D, "Delete the selected row(s) from the table");
    // Create a listener for the Delete row button
    btnDeleteRow.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Delete the selected row(s) from the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.deleteRow(true);
        }
    });
    // Move Up button
    btnMoveUp = CcddButtonPanelHandler.createButton("Up", UP_ICON, KeyEvent.VK_U, "Move the selected row(s) up");
    // Create a listener for the Move Up button
    btnMoveUp.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Move the selected row(s) up in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.moveRowUp();
        }
    });
    // Move Down button
    btnMoveDown = CcddButtonPanelHandler.createButton("Down", DOWN_ICON, KeyEvent.VK_W, "Move the selected row(s) down");
    // Create a listener for the Move Down button
    btnMoveDown.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Move the selected row(s) down in the table
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.moveRowDown();
        }
    });
    // Separator button
    btnSeparator = CcddButtonPanelHandler.createButton("Separator", SEPARATOR_ICON, KeyEvent.VK_S, "Insert a horizontal separator");
    // Create a listener for the Separator button
    btnSeparator.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Insert a line separator
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.insertRow(true, TableInsertionPoint.SELECTION, new Object[] { InputDataType.SEPARATOR.getInputName(), "Line separator", 0, InputDataType.SEPARATOR.getInputName(), false, "", "" });
        }
    });
    // Break button
    btnBreak = CcddButtonPanelHandler.createButton("Break", BREAK_ICON, KeyEvent.VK_B, "Insert a line break");
    // Create a listener for the Move Down button
    btnBreak.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Insert a line break
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.insertRow(true, TableInsertionPoint.SELECTION, new Object[] { InputDataType.BREAK.getInputName(), "Line break", 0, InputDataType.BREAK.getInputName(), false, "", "" });
        }
    });
    // Undo button
    btnUndo = CcddButtonPanelHandler.createButton("Undo", UNDO_ICON, KeyEvent.VK_Z, "Undo the last edit");
    // Create a listener for the Undo button
    btnUndo.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Undo the last cell edit
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.getUndoManager().undo();
        }
    });
    // Redo button
    btnRedo = CcddButtonPanelHandler.createButton("Redo", REDO_ICON, KeyEvent.VK_Y, "Redo the last undone edit");
    // Create a listener for the Redo button
    btnRedo.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Redo the last cell edit that was undone
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            fieldTable.getUndoManager().redo();
        }
    });
    // Update the data fields button
    btnUpdate = CcddButtonPanelHandler.createButton("Update", STORE_ICON, KeyEvent.VK_U, "Update the table data field(s)");
    // Create a listener for the Update button
    btnUpdate.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Update the table data fields
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            // valid (if a cell is being edited), and that there are changes to update
            if (!checkForMissingColumns() && fieldTable.isLastCellValid() && fieldTable.isTableChanged(currentData)) {
                // Rebuild the data field panel in the table editor using the current text
                // field contents
                recreateDataFieldPanel(minimumWidth);
            }
        }
    });
    // Close button
    btnClose = CcddButtonPanelHandler.createButton("Close", CLOSE_ICON, KeyEvent.VK_C, "Close the data field editor");
    // Create a listener for the Close button
    btnClose.addActionListener(new ValidateCellActionListener(fieldTable) {

        /**
         ************************************************************************************
         * Close the data field editor dialog
         ************************************************************************************
         */
        @Override
        protected void performAction(ActionEvent ae) {
            windowCloseButtonAction();
        }
    });
    // Add buttons in the order in which they'll appear (left to right, top to bottom)
    buttonPnl.add(btnInsertRow);
    buttonPnl.add(btnMoveUp);
    buttonPnl.add(btnSeparator);
    buttonPnl.add(btnUndo);
    buttonPnl.add(btnUpdate);
    buttonPnl.add(btnDeleteRow);
    buttonPnl.add(btnMoveDown);
    buttonPnl.add(btnBreak);
    buttonPnl.add(btnRedo);
    buttonPnl.add(btnClose);
    // Distribute the buttons across two rows
    setButtonRows(2);
    // Set the modal undo manager and table references in the keyboard handler while the data
    // field editor is active
    keyboardHandler.setModalDialogReference(fieldTable.getUndoManager(), fieldTable);
    // Display the table data field editor dialog
    showOptionsDialog(fieldPnlHndlr.getOwner(), outerPanel, buttonPnl, btnClose, DIALOG_TITLE + ": " + ownerName, true);
    // Clear the modal dialog references in the keyboard handler since the data field editor is
    // no longer active. The component that called this editor, if a modal dialog, must set
    // these parameters again once control is returned to it from this editor
    keyboardHandler.setModalDialogReference(null, null);
}
Also used : JScrollPane(javax.swing.JScrollPane) TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) CCDDException(CCDD.CcddClassesDataTable.CCDDException) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) TableInsertionPoint(CCDD.CcddConstants.TableInsertionPoint) ValidateCellActionListener(CCDD.CcddClassesComponent.ValidateCellActionListener) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Aggregations

ValidateCellActionListener (CCDD.CcddClassesComponent.ValidateCellActionListener)8 ActionEvent (java.awt.event.ActionEvent)8 JPanel (javax.swing.JPanel)8 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)6 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 Insets (java.awt.Insets)5 JButton (javax.swing.JButton)5 ActionListener (java.awt.event.ActionListener)4 ArrayList (java.util.ArrayList)4 BoxLayout (javax.swing.BoxLayout)4 DnDTabbedPane (CCDD.CcddClassesComponent.DnDTabbedPane)3 TableInsertionPoint (CCDD.CcddConstants.TableInsertionPoint)3 ChangeEvent (javax.swing.event.ChangeEvent)3 ChangeListener (javax.swing.event.ChangeListener)3 Component (java.awt.Component)2 JLabel (javax.swing.JLabel)2 JMenu (javax.swing.JMenu)2 JMenuBar (javax.swing.JMenuBar)2 JScrollPane (javax.swing.JScrollPane)2