Search in sources :

Example 1 with Message

use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.

the class CcddSchedulerEditorHandler method updateAssignedVariablesTabs.

/**
 ********************************************************************************************
 * Update the tabs in the assigned variables tabbed pane based on the currently selected
 * message
 ********************************************************************************************
 */
private void updateAssignedVariablesTabs() {
    // Check if this is the telemetry scheduler
    if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
        // Get the currently selected message
        Message message = getSelectedMessage();
        // Check if a message is selected
        if (message != null) {
            int subMsgIndex = 0;
            // Set the flag indicating a tabbed pane update is in progress. This flag is used
            // to inhibit tab selection changes while the tabbed pane is updated
            isTabUpdate = true;
            // Check if a sub-message is selected
            if (message.getParentMessage() != null) {
                // Get the index of the selected sub-message
                subMsgIndex = message.getParentMessage().getSubMessages().indexOf(message) + 1;
                // Change the reference to the sub-messages parent message
                message = message.getParentMessage();
            }
            // Set the first tab's title to the message name
            tabbedPane.setTitleAt(0, message.getName());
            // Step backwards through the sub-message tabs, if any
            for (int index = tabbedPane.getTabCount() - 1; index > 0; index--) {
                // Remove the sub-message tab
                tabbedPane.remove(index);
            }
            // sub-message is added
            if (message.getNumberOfSubMessages() > 1) {
                // Step through each sub-message
                for (int index = 1; index <= message.getNumberOfSubMessages(); index++) {
                    // Add a tab for the sub-message
                    tabbedPane.insertTab(getSubHeaderOrTabName(index), null, null, null, index);
                }
            }
            // Select the tab associated with the selected (sub-)message
            tabbedPane.setSelectedIndex(subMsgIndex);
            // Reenable tab selection changes
            isTabUpdate = false;
        } else // No message is selected
        {
            // Set the first tab's title to indicate no selection
            tabbedPane.setTitleAt(0, "<html><i>No message selected");
        }
    }
}
Also used : Message(CCDD.CcddClassesDataTable.Message)

Example 2 with Message

use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.

the class CcddSchedulerEditorHandler method clearVariablesFromMessages.

/**
 ********************************************************************************************
 * Remove the variables (applications) assigned to the messages (time slots)
 *
 * @param rateFilter
 *            rate of the variables to removed from the telemetry messages; null to remove all
 *            variables. Not used for the application scheduler
 ********************************************************************************************
 */
protected void clearVariablesFromMessages(String rateFilter) {
    String type;
    String text;
    // Check if this is the telemetry scheduler
    if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
        type = "Variables";
        text = rateFilter == null ? "all variables from messages" : "variables of rate " + rateFilter + " from messages";
    } else // This is the application scheduler
    {
        type = "Applications";
        text = "all applications from time slots";
    }
    boolean isVariable = false;
    // Step through each message (time slot) in the stream
    for (Message msg : getCurrentMessages()) {
        // Check if a variable (application) exists in the message
        if (!msg.getAllVariables().isEmpty()) {
            // Set the flag indicating a variable (application)exists and stop searching
            isVariable = true;
            break;
        }
    }
    // resetting the messages (time slots)
    if (isVariable && new CcddDialogHandler().showMessageDialog(schedulerHndlr.getSchedulerDialog().getDialog(), "<html><b>Remove " + text + "?", "Remove " + type, JOptionPane.QUESTION_MESSAGE, DialogOption.OK_CANCEL_OPTION) == OK_BUTTON) {
        // Create lists for the variables and the variables that are removed
        List<Variable> allVarsRemoved = new ArrayList<Variable>();
        List<Variable> msgVarsRemoved = new ArrayList<Variable>();
        float rate = 0;
        // Check if a rate filter is to be applied
        if (rateFilter != null) {
            // Convert the rate to a floating point value
            rate = CcddUtilities.convertStringToFloat(rateFilter);
        }
        // Step through each message
        for (int msgIndex = 0; msgIndex < messages.size(); msgIndex++) {
            // Step through each variable assigned to this message
            for (Variable variable : messages.get(msgIndex).getAllVariables()) {
                // variable's rate matches the rate filter
                if (rateFilter == null || rate == variable.getRate()) {
                    // Add the variable to the list of those to be removed from the message
                    msgVarsRemoved.add(variable);
                }
            }
            // Remove the variables from the messages
            removeVariablesFromMessages(msgVarsRemoved, msgIndex);
            // Add the message's removed variables to the list of all removed variables
            allVarsRemoved.addAll(msgVarsRemoved);
            // Clear the removed variables list for the next pass
            msgVarsRemoved.clear();
        }
        // Check if this is a telemetry scheduler
        if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
            // Update the assignment definition list for when the assignment tree is rebuilt
            assignmentTree.updateAssignmentDefinitions(messages, schedulerHndlr.getRateName());
        }
        // Calculate the bytes remaining in the messages
        calculateTotalBytesRemaining();
        // Update the remaining bytes column values
        updateRemainingBytesColumn();
        // Update the assignment tree/list
        updateAssignmentList();
        // Create an included variables (applications) list
        List<String> includedVars = new ArrayList<String>();
        // Step through each variable (application) in the removed variable (application) list
        for (Variable variable : allVarsRemoved) {
            // Add each name to the list of included variables (applications)
            includedVars.add(variable.getFullName());
        }
        // Include the variables (applications) back in the variable (application) tree
        schedulerHndlr.makeVariableAvailable(includedVars);
        // Set the unused bytes field
        schedulerHndlr.setUnusedField();
        // Update the scheduler dialog's change indicator
        schedulerHndlr.getSchedulerDialog().updateChangeIndicator();
    }
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) ArrayList(java.util.ArrayList)

Example 3 with Message

use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.

the class CcddSchedulerEditorHandler method addVariableToMessage.

/**
 ********************************************************************************************
 * Add a variable to the specified (sub-)message. Update the message and table with the new
 * values
 *
 * @param variable
 *            variable that will be added
 *
 * @param messageIndex
 *            message index if the variable is not assigned to a sub-message; sub-message index
 *            if the message is assigned to a sub-message
 *
 * @param subMsgIndex
 *            message index if the variable is assigned to a sub-message, -1 if not
 ********************************************************************************************
 */
protected void addVariableToMessage(Variable variable, int messageIndex, int subMsgIndex) {
    int index = -1;
    Message targetMsg;
    // Check if the variable should be assigned to a sub-message
    if (subMsgIndex >= 0) {
        // Get the reference to the sub-message
        targetMsg = messages.get(subMsgIndex).getSubMessage(messageIndex);
    } else // Variable will be assigned to the general message
    {
        // Get the reference to the message
        targetMsg = messages.get(messageIndex);
    }
    // Get the index at which the variable/application should be inserted in the message
    index = schedulerHndlr.getSchedulerInput().getVariableRelativeIndex(variable, targetMsg.getVariables());
    // Check that the variable isn't already in the message
    if (index != -2) {
        // Add the variable to the (sub-)message
        targetMsg.addVariable(variable, index);
    }
}
Also used : Message(CCDD.CcddClassesDataTable.Message)

Example 4 with Message

use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.

the class CcddSchedulerEditorHandler method initialize.

/**
 ********************************************************************************************
 * Create a telemetry table
 ********************************************************************************************
 */
@SuppressWarnings("serial")
private void initialize() {
    // Create a border for the table and list panes, and an empty border
    Border 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();
    // Initialize the layout constraints
    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0);
    // Initialize the telemetry scheduler
    initializeSchedulerTable();
    // Initialize the scheduler table object
    schedulerTable = new CcddJTableHandler(5) {

        /**
         ************************************************************************************
         * Allow multiple line display in the specified column only
         ************************************************************************************
         */
        @Override
        protected boolean isColumnMultiLine(int column) {
            return column == SchedulerColumn.NAME.ordinal();
        }

        /**
         ************************************************************************************
         * Allow resizing of the specified column only
         ************************************************************************************
         */
        @Override
        protected boolean isColumnResizable(int column) {
            return column == SchedulerColumn.NAME.ordinal();
        }

        /**
         ************************************************************************************
         * Allow editing of the table cells in the specified columns only
         ************************************************************************************
         */
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == SchedulerColumn.NAME.ordinal() || (column == SchedulerColumn.ID.ordinal() && messages.get(row).getNumberOfSubMessages() <= 1) || (column > SchedulerColumn.ID.ordinal() && messages.get(row).getNumberOfSubMessages() > 1 && column <= SchedulerColumn.ID.ordinal() + messages.get(row).getNumberOfSubMessages());
        }

        /**
         ************************************************************************************
         * Validate changes to the data field value cells; e.g., verify cell content and, if
         * found invalid, revert to the original value
         *
         * @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
         *            unused
         *
         * @param isMultiple
         *            unused
         *
         * @return Value of ShowMessage
         ***********************************************************************************
         */
        @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 this is the name column
                if (column == SchedulerColumn.NAME.ordinal()) {
                    // Check if the value name is blank
                    if (newValueS.isEmpty()) {
                        // Inform the user that the message name cannot be blank
                        throw new CCDDException("Message name must be entered");
                    }
                    // Check if the message name is an alphanumeric
                    if (!newValueS.matches(InputDataType.ALPHANUMERIC.getInputMatch())) {
                        // Inform the user that the message name contains invalid characters
                        throw new CCDDException("Invalid characters in message name");
                    }
                    // Step through each message
                    for (Message message : messages) {
                        // Check if the new name matches an existing one
                        if (messages.indexOf(message) != row && message.getName().equals(newValueS)) {
                            // Inform the user that the message name already is in use
                            throw new CCDDException("Message name is already in use");
                        }
                    }
                    // Store the new message name
                    messages.get(row).setName(newValueS);
                    // Update the assigned variables tab and options list with the new name
                    tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), newValueS);
                    schedulerHndlr.getTelemetryOptions();
                    // Change references to the original message name to the new name in the
                    // assignment tree so that the tree builds correctly
                    assignmentTree.updateMessageName(oldValue.toString(), newValueS);
                } else // Check if this is an ID column
                if (column >= SchedulerColumn.ID.ordinal()) {
                    // Check if the message ID is a hexadecimal
                    if (!newValueS.matches(InputDataType.HEXADECIMAL.getInputMatch())) {
                        // Inform the user that the message name contains invalid characters
                        throw new CCDDException("Invalid characters in message ID");
                    }
                    // Format the hexadecimal value
                    newValueS = InputDataType.HEXADECIMAL.formatInput(newValueS);
                    // Check that the new value isn't a blank
                    if (!newValueS.isEmpty()) {
                        // Convert the ID to an integer
                        int id = Integer.decode(newValueS);
                        // Step through each row in the table
                        for (int checkRow = 0; checkRow < tableData.size(); checkRow++) {
                            // Step through each column containing an ID
                            for (int checkCol = SchedulerColumn.ID.ordinal(); checkCol < tableData.get(checkRow).length; checkCol++) {
                                // updated, and that the new ID matches that in another ID cell
                                if (!(row == checkRow && column == checkCol) && !tableData.get(checkRow)[checkCol].toString().isEmpty() && id == Integer.decode(tableData.get(checkRow)[checkCol].toString())) {
                                    // Inform the user that the message name already is in use
                                    throw new CCDDException("Message ID is already in use");
                                }
                            }
                        }
                    }
                    // Update the table with the formatted value
                    tableData.get(row)[column] = newValueS;
                    // Check if this is the parent message's ID
                    if (column == SchedulerColumn.ID.ordinal()) {
                        // Store the new message ID
                        messages.get(row).setID(newValueS);
                    } else // This is a sub-message ID
                    {
                        // Store the new sub-message ID
                        messages.get(row).getSubMessage(column - SchedulerColumn.ID.ordinal() - 1).setID(newValueS);
                    }
                }
            } catch (CCDDException ce) {
                // Set the flag that indicates the last edited cell's content is invalid
                setLastCellValid(false);
                // Inform the user that the input value is invalid
                new CcddDialogHandler().showMessageDialog(schedulerHndlr.getSchedulerDialog().getDialog(), "<html><b>" + ce.getMessage(), "Invalid Input", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                // Restore the cell contents to its original value
                tableData.get(row)[column] = oldValue;
                getUndoManager().undoRemoveEdit();
            }
            return showMessage;
        }

        /**
         ************************************************************************************
         * 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, getColumnNames(), null, null, 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);
            // color
            if (comp.getBackground() != ModifiableColorInfo.FOCUS_BACK.getColor() && comp.getBackground() != ModifiableColorInfo.SELECTED_BACK.getColor() && !isCellEditable(row, column)) {
                // Shade the cell's foreground and background colors
                comp.setForeground(getValueAt(row, column).toString().startsWith("-") ? ModifiableColorInfo.INVALID_TEXT.getColor() : ModifiableColorInfo.PROTECTED_TEXT.getColor());
                comp.setBackground(ModifiableColorInfo.PROTECTED_BACK.getColor());
            }
            return comp;
        }

        /**
         ************************************************************************************
         * Override the CcddJTableHandler method to handle sorting the Size column
         ************************************************************************************
         */
        @Override
        protected void setTableSortable() {
            // Remove the current sorter, if present. The number of columns may have changed
            // (due to adding/removing sub-messages) so the sorter must be rebuilt
            setRowSorter(null);
            super.setTableSortable();
            // Create a runnable object to be executed
            SwingUtilities.invokeLater(new Runnable() {

                /**
                 ****************************************************************************
                 * Execute after all pending Swing events are finished. This allows the number
                 * of viewable columns to catch up with the column model when a column is added
                 * or removed
                 ****************************************************************************
                 */
                @Override
                public void run() {
                    // Get the table's row sorter
                    TableRowSorter<?> sorter = (TableRowSorter<?>) getRowSorter();
                    // Check if the table has a sorter (i.e., has at least one row)
                    if (sorter != null) {
                        // the telemetry scheduler)
                        for (int column = SchedulerColumn.ID.ordinal(); column < getModel().getColumnCount(); column++) {
                            // Add a hexadecimal sort comparator
                            sorter.setComparator(column, new Comparator<String>() {

                                /**
                                 ************************************************************
                                 * Override the comparison when sorting columns with a
                                 * hexadecimal input type format
                                 ************************************************************
                                 */
                                @Override
                                public int compare(String cell1, String cell2) {
                                    int result;
                                    // Check if either cell is empty
                                    if (cell1.isEmpty() || cell2.isEmpty()) {
                                        // Compare as text (alphabetically)
                                        result = cell1.compareTo(cell2);
                                    } else // Neither cell is empty
                                    {
                                        // Get the hexadecimal cell values and convert them to
                                        // base 10 integers for comparison
                                        result = Integer.compare(Integer.decode(cell1), Integer.decode(cell2));
                                    }
                                    return result;
                                }
                            });
                        }
                    }
                }
            });
        }
    };
    // Create a listener for scheduler table row and column selection changes
    ListSelectionListener rowColListener = new ListSelectionListener() {

        /**
         ************************************************************************************
         * Handle a scheduler table row or column selection change
         ************************************************************************************
         */
        @Override
        public void valueChanged(ListSelectionEvent lse) {
            // Check if this is the last of the series of changes
            if (!lse.getValueIsAdjusting() && (schedulerTable.getSelectedRow() != previousRow || schedulerTable.getSelectedColumn() != previousColumn)) {
                // Update the tabbed pane for the selected message
                updateAssignedVariablesTabs();
                // Update the assignment tree/list
                updateAssignmentList();
                // Store the selected row and column indices for comparison when another cell
                // is selected
                previousRow = schedulerTable.getSelectedRow();
                previousColumn = schedulerTable.getSelectedColumn();
            }
        }
    };
    // Add a listener for changes to the table's row selection
    schedulerTable.getSelectionModel().addListSelectionListener(rowColListener);
    // Add a listener for changes to the table's column selection
    schedulerTable.getColumnModel().getSelectionModel().addListSelectionListener(rowColListener);
    // Place the table into a scroll pane
    JScrollPane schedulerScrollPane = new JScrollPane(schedulerTable);
    schedulerScrollPane.setBorder(border);
    // Set common table parameters and characteristics
    schedulerTable.setFixedCharacteristics(schedulerScrollPane, false, ListSelectionModel.SINGLE_SELECTION, TableSelectionMode.SELECT_BY_CELL, false, ModifiableColorInfo.TABLE_BACK.getColor(), true, true, ModifiableFontInfo.DATA_TABLE_CELL.getFont(), true);
    // Get the table model and undo manager to shorten later calls
    schTableModel = (UndoableTableModel) schedulerTable.getModel();
    // Create a scroll pane to contain the assignment tree/list
    JScrollPane assignScrollPane = null;
    // Check if this is the telemetry scheduler
    if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
        // Get a reference to the telemetry scheduler input to shorten subsequent calls
        CcddTelemetrySchedulerInput tlmInput = (CcddTelemetrySchedulerInput) schedulerHndlr.getSchedulerInput();
        // Create an assignment tree specifying a null rate & message so the tree is initially
        // empty
        assignmentTree = new CcddAssignmentTreeHandler(ccddMain, null, tlmInput.getLinkTree().getLinkHandler(), tlmInput.getVariableTree().getTableTreePathList(null, tlmInput.getVariableTree().getNodeByNodeName(UNLINKED_VARIABLES_NODE_NAME), -1), ccddMain.getMainFrame());
    } else // Check if this is the application scheduler
    if (schedulerHndlr.getSchedulerOption() == APPLICATION_SCHEDULER) {
        // Initialize the assignment list and add it to a scroll pane that will be placed next
        // to the variable list
        assignmentList = new JList<String>();
        assignmentList.setModel(new DefaultListModel<String>());
        assignmentList.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
        assignScrollPane = new JScrollPane(assignmentList);
        assignScrollPane.setBorder(border);
        // Set the size of the assignment scroll pane
        assignScrollPane.setPreferredSize(new Dimension(Math.min(Math.max(assignScrollPane.getPreferredSize().width, 150), 250), assignScrollPane.getPreferredSize().height));
        assignScrollPane.setMinimumSize(assignScrollPane.getPreferredSize());
    }
    // Create panels to hold the components tablePnl = new JPanel(new GridBagLayout());
    JPanel schedulerPnl = new JPanel(new GridBagLayout());
    JPanel assignmentPnl = new JPanel(new GridBagLayout());
    schedulerPnl.setBorder(emptyBorder);
    assignmentPnl.setBorder(emptyBorder);
    // Set the scheduler panel size so that the panel can't be resized in width less than that
    // needed to display the default columns
    int[] colWidths = schedulerTable.getColumnWidths();
    int prefWidth = 8 + colWidths[0] + colWidths[1] + (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER ? colWidths[2] : 0);
    schedulerScrollPane.setPreferredSize(new Dimension(prefWidth, schedulerScrollPane.getPreferredSize().height));
    schedulerPnl.setMinimumSize(schedulerScrollPane.getPreferredSize());
    // Create the scheduler table label
    JLabel schedulerLbl = new JLabel("Scheduler");
    schedulerLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    schedulerLbl.setForeground(ModifiableColorInfo.SPECIAL_LABEL_TEXT.getColor());
    // Add the scheduler label and scroll pane to the panel
    schedulerPnl.add(schedulerLbl, gbc);
    gbc.weighty = 1.0;
    gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
    gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2;
    gbc.gridy++;
    schedulerPnl.add(schedulerScrollPane, gbc);
    // Create the assignment list label and add it to the panel
    JLabel assignmentLbl = new JLabel("");
    assignmentLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    assignmentLbl.setForeground(ModifiableColorInfo.SPECIAL_LABEL_TEXT.getColor());
    gbc.insets.top = 0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    assignmentPnl.add(assignmentLbl, gbc);
    gbc.weighty = 1.0;
    gbc.gridy = 1;
    // Check if this is the telemetry scheduler
    if (schedulerHndlr.getSchedulerOption() == TELEMETRY_SCHEDULER) {
        // Adjust the tab area's insets so that the scheduler and tabs are aligned. Note that
        // the Nimbus L&F has hard-coded insets, so can't be changed;
        UIManager.getDefaults().put("TabbedPane.tabAreaInsets", new Insets(0, 0, 0, 0));
        UIManager.getDefaults().put("TabbedPane.tabsOverlapBorder", true);
        // Create a tabbed pane to contain the variable tree for the message and any
        // sub-messages
        tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        tabbedPane.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
        // Listen for tab selection changes
        tabbedPane.addChangeListener(new ChangeListener() {

            /**
             ********************************************************************************
             * Handle tab selection change
             ********************************************************************************
             */
            @Override
            public void stateChanged(ChangeEvent ce) {
                // update the assignment tree
                if (!isTabUpdate) {
                    // Get the currently selected tab index
                    int tabIndex = tabbedPane.getSelectedIndex();
                    // Check if a tab is selected
                    if (tabIndex != -1) {
                        // Get the currently selected message in the scheduler table
                        Message message = getSelectedMessage();
                        // Check if a message is selected
                        if (message != null) {
                            // Select the row and column in the scheduler table corresponding
                            // to the selected message tab
                            schedulerTable.changeSelection(schedulerTable.getSelectedRow(), SchedulerColumn.ID.ordinal() + tabIndex, false, false);
                        }
                    }
                    // Update the assignment tree/list
                    updateAssignmentList();
                }
            }
        });
        // Set the assignment tree title
        assignmentLbl.setText("Assigned Variables");
        // Create the assignment tree and place it within the tabbed pane
        tabbedPane.insertTab("<html><i>No message selected", null, assignmentTree.createTreePanel(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION), null, 0);
        // Add the tabbed pane to the panel
        assignmentPnl.add(tabbedPane, gbc);
    } else // Check if this is the application scheduler
    if (schedulerHndlr.getSchedulerOption() == APPLICATION_SCHEDULER) {
        // Set the assignment list title
        assignmentLbl.setText("Assigned Applications");
        // Add the assignment list to the panel
        gbc.insets.top = 0;
        assignmentPnl.add(assignScrollPane, gbc);
        // Set the tabbed pane to null so that the application scheduler ignores it
        tabbedPane = null;
    }
    // Add the scheduler table and assignment tree/list to the split pane
    tableSpltPn = new CustomSplitPane(schedulerPnl, assignmentPnl, null, JSplitPane.HORIZONTAL_SPLIT);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) CCDDException(CCDD.CcddClassesDataTable.CCDDException) Message(CCDD.CcddClassesDataTable.Message) GridBagLayout(java.awt.GridBagLayout) JTabbedPane(javax.swing.JTabbedPane) ListSelectionEvent(javax.swing.event.ListSelectionEvent) DefaultListModel(javax.swing.DefaultListModel) CustomSplitPane(CCDD.CcddClassesComponent.CustomSplitPane) ChangeListener(javax.swing.event.ChangeListener) Component(java.awt.Component) JComponent(javax.swing.JComponent) TableRowSorter(javax.swing.table.TableRowSorter) JScrollPane(javax.swing.JScrollPane) TableCellRenderer(javax.swing.table.TableCellRenderer) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ChangeEvent(javax.swing.event.ChangeEvent) Border(javax.swing.border.Border) BevelBorder(javax.swing.border.BevelBorder) JList(javax.swing.JList)

Example 5 with Message

use of CCDD.CcddClassesDataTable.Message in project CCDD by nasa.

the class CcddCopyTableHandler method createCopyTable.

/**
 ********************************************************************************************
 * Create a copy table based on the message definitions
 *
 * @param fieldHandler
 *            field handler reference
 *
 * @param linkHandler
 *            link handler reference
 *
 * @param dataStreamName
 *            data stream name
 *
 * @param headerSize
 *            size of the packet header in bytes
 *
 * @param messageIDNameField
 *            name of the structure table data field containing the message ID name. If
 *            provided this is used instead of the tlmMessageIDs list
 *
 * @param tlmMessageIDs
 *            list containing string array entries giving the structure table path+name and the
 *            table's associated message ID name. Used if messageIDNameField is null
 *
 * @param optimize
 *            true to create copy table with memory copies optimized
 *
 * @param expandMacros
 *            true to expand any macro within the variable names
 *
 * @return Array containing the copy table entries
 ********************************************************************************************
 */
protected String[][] createCopyTable(CcddFieldHandler fieldHandler, CcddLinkHandler linkHandler, String dataStreamName, int headerSize, String messageIDNameField, ArrayListMultiple tlmMessageIDs, boolean optimize, boolean expandMacros) {
    List<String[]> messageTable = new ArrayList<String[]>();
    // Empty the copy table in case a previous one exists
    copyTable.clear();
    // Step through each message for the specified rate
    for (Message message : getStoredMessages(dataStreamName)) {
        // Step through the message's sub-messages
        for (Message subMsg : message.getSubMessages()) {
            // Step through each packet definition
            for (Variable variable : subMsg.getVariablesWithParent()) {
                String tlmMsgID = null;
                // Split the packet definition's variable string into the parent structure name
                // and variable reference string
                String[] parentAndPath = variable.getFullName().split(",", 2);
                // Check if macro in the variable names are to be expanded
                if (expandMacros) {
                    // Replace any macros with their corresponding values
                    parentAndPath[1] = macroHandler.getMacroExpansion(parentAndPath[1]);
                }
                // Get the offset in the root structure of the variable indicated by the packet
                // definition
                int structureOffset = variableHandler.getVariableOffset(variable.getFullName());
                // Check if the message ID name field name is provided
                if (messageIDNameField != null) {
                    // Get the field information for the message ID name field
                    FieldInformation msgIDNameFieldInfo = fieldHandler.getFieldInformationByName(parentAndPath[0], messageIDNameField);
                    // Check that the message ID name field exists for the specified table
                    if (msgIDNameFieldInfo != null) {
                        // Get the message ID name associated with the table
                        tlmMsgID = msgIDNameFieldInfo.getValue();
                    }
                } else // Check if the telemetry message ID names list is provided
                if (tlmMessageIDs != null) {
                    // Get the index of the table in the list provided
                    int index = tlmMessageIDs.indexOf(parentAndPath[0]);
                    // Check if the table exists in the list
                    if (index != -1) {
                        // Get the message ID name associated with the table
                        tlmMsgID = tlmMessageIDs.get(index)[1];
                    }
                }
                if (tlmMsgID != null) {
                    // Build the copy table entry array for this variable. The fields are:
                    // Input message ID name, input offset, output message ID name (the
                    // sub-message separator character, a period, is replaced with an
                    // underscore), output offset (initialized to a blank; the value is
                    // computed later), variable size, variable root table, and variable path
                    messageTable.add(new String[] { tlmMsgID, String.valueOf(structureOffset), subMsg.getName().replace(".", "_"), "", String.valueOf(variable.getSize()), parentAndPath[0], parentAndPath[1] });
                }
            }
            // Consolidate the bit-packed variables
            combineBitPackedVariables(messageTable);
            // Check if this copy table should be optimized
            if (optimize) {
                // Combine consecutive memory copies
                combineMemoryCopies(messageTable);
            }
            // Add the input and output offset to the list
            addInputAndOutputOffset(messageTable, headerSize);
            // Add this message's copy table entries to the list of all copy table entries
            copyTable.addAll(messageTable);
            // Clear out this message's entries to allow storage for the next message
            messageTable.clear();
        }
    }
    return copyTable.toArray(new String[0][0]);
}
Also used : Variable(CCDD.CcddClassesDataTable.Variable) Message(CCDD.CcddClassesDataTable.Message) ArrayList(java.util.ArrayList) FieldInformation(CCDD.CcddClassesDataTable.FieldInformation)

Aggregations

Message (CCDD.CcddClassesDataTable.Message)24 Variable (CCDD.CcddClassesDataTable.Variable)8 ArrayList (java.util.ArrayList)8 ApplicationData (CCDD.CcddClassesDataTable.ApplicationData)3 DataStream (CCDD.CcddClassesDataTable.DataStream)2 DefaultListModel (javax.swing.DefaultListModel)2 CustomSplitPane (CCDD.CcddClassesComponent.CustomSplitPane)1 CCDDException (CCDD.CcddClassesDataTable.CCDDException)1 FieldInformation (CCDD.CcddClassesDataTable.FieldInformation)1 RateInformation (CCDD.CcddClassesDataTable.RateInformation)1 TelemetryData (CCDD.CcddClassesDataTable.TelemetryData)1 SchedulerType (CCDD.CcddConstants.SchedulerType)1 TypeDefinition (CCDD.CcddTableTypeHandler.TypeDefinition)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1