Search in sources :

Example 1 with SchedulerType

use of CCDD.CcddConstants.SchedulerType in project CCDD by nasa.

the class CcddSchedulerHandler method autoFill.

/**
 ********************************************************************************************
 * Automatically fill the variables/applications in messages/time slots corresponding to their
 * rate
 ********************************************************************************************
 */
protected void autoFill() {
    canceled = false;
    cancelDialog = new HaltDialog();
    progBar = new JProgressBar();
    progress = 0;
    // Create the panel to contain the progress/cancellation dialog components
    final JPanel dialogPnl = new JPanel(new GridBagLayout());
    // Get the scheduler dialog type
    final SchedulerType schedulerType = getSchedulerOption();
    // Get the text that describes the type of object being assigned
    final String variableType = schedulerType == SchedulerType.TELEMETRY_SCHEDULER ? "variables" : (schedulerType == SchedulerType.APPLICATION_SCHEDULER ? "applications" : "unknown");
    // Create a thread to perform the auto-fill operation in the background
    final Thread progressThread = new Thread(new Runnable() {

        /**
         ************************************************************************************
         * Auto-fill the telemetry messages (if this is the telemetry scheduler) or application
         * time slots (if this is the application scheduler). Note that in the comments below
         * 'variable' is used to describe the object being assigned, which is accurate for the
         * telemetry scheduler. For the application scheduler substitute 'application' for
         * 'variable'
         ************************************************************************************
         */
        @Override
        public void run() {
            int numVariables = 0;
            int unassigned = 0;
            // Get an array of the available rates
            String[] availableRates = schedulerInput.getAvailableRates();
            // variables at each rate until no more rates are available
            for (String rate : availableRates) {
                // out using HTML tags
                if (!rate.startsWith("<html>")) {
                    // Check if this is a telemetry scheduler
                    if (schedulerType == SchedulerType.TELEMETRY_SCHEDULER) {
                        // Get the reference to the variable tree in order to shorten the
                        // subsequent call
                        CcddTableTreeHandler variableTree = ((CcddTelemetrySchedulerInput) schedulerInput).getVariableTree();
                        // Add the number of unassigned variables at the given rate.
                        // getVariablesAtRate() could be used, but it performs other operations
                        // associated with links and is slower
                        numVariables += variableTree.getPrimitiveVariablePaths(variableTree.getRootNode(), true).size();
                    } else // Check if this is an application scheduler
                    if (schedulerType == SchedulerType.APPLICATION_SCHEDULER) {
                        // Add the number of unassigned applications at the given rate
                        numVariables += schedulerInput.getVariablesAtRate(rate).size();
                    }
                }
            }
            // Check if there are any variables to assign
            if (numVariables != 0) {
                // Update the progress bar now that the number of variables is known
                progBar.setMaximum(numVariables);
                progBar.setIndeterminate(false);
                // Total size of the variable or link
                int totalSize;
                // Message option to which the variable or link will be added
                String option;
                // Variable that will be added
                Variable variable;
                // Variables that will be removed from the remaining list
                List<Variable> removedVars = new ArrayList<Variable>();
                // List of variables at a given rate
                List<Variable> varList;
                // List of the variables to exclude from the Variables tree. This should be all
                // of the variables unless there are any that can't be assigned
                List<String> excludedVars = new ArrayList<String>();
                // variables at each rate until no more rates are available
                for (String rate : availableRates) {
                    // Check if the user canceled auto-fill
                    if (canceled) {
                        break;
                    }
                    // grayed out using HTML tags
                    if (!rate.startsWith("<html>")) {
                        // Show the current rate being processed in the progress bar
                        progBar.setString("Assigning " + rate + " Hz " + variableType);
                        // Get the rate as a floating point value
                        float rateVal = CcddUtilities.convertStringToFloat(rate);
                        // Get a list of all variables at the given rate (ones already assigned
                        // are not included)
                        varList = schedulerInput.getVariablesAtRate(rate);
                        // Sort the list from largest to smallest
                        Collections.sort(varList);
                        // Loop through the list of variables until all are removed
                        while (!varList.isEmpty()) {
                            // Check if the user canceled padding adjustment
                            if (canceled) {
                                break;
                            }
                            // Total size of the variable or link
                            totalSize = 0;
                            // Set to the first variable in the list
                            variable = varList.get(0);
                            // Check if the variable is linked
                            if (variable.getLink() != null) {
                                // Step through each variable in the variable list
                                for (Variable linkVar : varList) {
                                    // variable
                                    if (linkVar.getLink() != null && linkVar.getLink().equals(variable.getLink())) {
                                        // Add the variable's size to the total size
                                        totalSize += variable.getSize();
                                        // Add the variable to the list of removed variables
                                        removedVars.add(linkVar);
                                    }
                                }
                            } else // The variable is unlinked
                            {
                                // Check if this is a telemetry scheduler
                                if (schedulerType == SchedulerType.TELEMETRY_SCHEDULER) {
                                    // Set total size to the given variable's size
                                    totalSize = variable.getSize();
                                    // Get the total size (in bytes) and the list of the
                                    // variable, or variables if this variable is associated
                                    // with others due to bit-packing or string membership and
                                    // therefore must be placed together in a message
                                    AssociatedVariable associates = ((CcddTelemetrySchedulerInput) schedulerInput).getAssociatedVariables(varList);
                                    // Set the total size to that of the associated variable(s)
                                    // and add the variable(s) to the list of those to be
                                    // removed
                                    totalSize = associates.getTotalSize();
                                    removedVars.addAll(associates.getAssociates());
                                } else // This is an application (or unknown type of) scheduler
                                {
                                    // Set total size to the given variable's size
                                    totalSize = variable.getSize();
                                    // Add the variable to the list of removed variables
                                    removedVars.add(variable);
                                }
                            }
                            // Find the option with the most room
                            option = getMessageWithRoom(rateVal, totalSize);
                            // Check to make sure there is an option
                            if (option != null) {
                                // Parse the option string to extract the sub-index (if this is
                                // a sub-option) and the message indices
                                Object[] parsedIndices = parseOption(option);
                                // Add the variable to the given message. If a sub-index is not
                                // given it will be set to -1. Add the list of added variables
                                // to the list of those to exclude in the Variables tree
                                excludedVars.addAll(addVariableToMessage(removedVars, (Integer[]) parsedIndices[1], (int) parsedIndices[0]));
                            } else // No option is available
                            {
                                // Increment the unplaced variable counter
                                unassigned++;
                            }
                            // Remove all the variables in removed variables list. This
                            // includes variables that did not fit into the telemetry table
                            varList.removeAll(removedVars);
                            // Clear the removed variables list
                            removedVars.clear();
                            // Update the auto-fill progress
                            progBar.setValue(progress);
                            progress++;
                        }
                    }
                }
                // Check if the auto-fill operation wasn't canceled by the user
                if (!canceled) {
                    // Close the auto-fill progress/cancellation dialog
                    cancelDialog.closeDialog(CANCEL_BUTTON);
                }
                // Perform any updates needed following adding variables to messages
                updateAfterVariableAdded();
                // Set the variable tree to exclude the variable(s)
                setVariableUnavailable(excludedVars);
                // Display the originally selected rate's variable tree
                schedulerInput.updateVariableTree(rateFilter.getSelectedItem().toString());
                // Update the remaining bytes column values
                schedulerEditor.updateRemainingBytesColumn();
                // Update the unused bytes/time field
                setUnusedField();
                // Update the assigned variables/applications list panel
                schedulerEditor.updateAssignmentList();
                // Update the scheduler dialog's change indicator
                getSchedulerDialog().updateChangeIndicator();
                // Check if there are items that are not assigned
                if (unassigned != 0) {
                    // Inform the user if there are items that are not assigned
                    new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b> Auto-fill unable to assign " + unassigned + " " + variableType, "Auto-fill", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                }
            } else // There are no unassigned variables
            {
                // user
                if (!canceled) {
                    // Close the auto-fill progress/cancellation dialog
                    cancelDialog.closeDialog(CANCEL_BUTTON);
                }
                new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b>All " + variableType + " with a rate are already assigned", "Auto-fill", JOptionPane.INFORMATION_MESSAGE, DialogOption.OK_OPTION);
            }
        }
    });
    // Execute the command in the background
    CcddBackgroundCommand.executeInBackground(ccddMain, schedulerDlg.getDialog(), new BackgroundCommand() {

        /**
         ************************************************************************************
         * Build and display the auto-fill progress/cancellation dialog. This is done as a
         * background operation so that the
         ************************************************************************************
         */
        @Override
        protected void execute() {
            // Set the initial layout manager characteristics
            GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing(), 0, ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing()), 0, 0);
            // Build the progress/cancellation dialog
            dialogPnl.setBorder(BorderFactory.createEmptyBorder());
            JLabel textLbl = new JLabel("<html><b>Assigning " + variableType + "...</b><br><br>", SwingConstants.LEFT);
            textLbl.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
            gbc.gridy++;
            dialogPnl.add(textLbl, gbc);
            JLabel textLbl2 = new JLabel("<html><b>" + CcddUtilities.colorHTMLText("*** Press </i>Halt<i> " + "to terminate auto-fill ***", Color.RED) + "</b><br><br>", SwingConstants.CENTER);
            textLbl2.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
            gbc.gridy++;
            dialogPnl.add(textLbl2, gbc);
            // Add a progress bar to the dialog
            progBar.setIndeterminate(true);
            progBar.setMinimum(0);
            progBar.setValue(0);
            progBar.setString("Calculating number of variables");
            progBar.setStringPainted(true);
            progBar.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
            gbc.insets.left = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
            gbc.insets.right = ModifiableSpacingInfo.LABEL_HORIZONTAL_SPACING.getSpacing() * 2;
            gbc.insets.bottom = 0;
            gbc.gridy++;
            dialogPnl.add(progBar, gbc);
            // the dialog if there are no variables to assign
            if (!canceled) {
                // Display the auto-fill progress/cancellation dialog
                cancelDialog.showOptionsDialog(schedulerDlg.getDialog(), dialogPnl, "Auto-fill " + (schedulerType == SchedulerType.TELEMETRY_SCHEDULER ? "Telemetry Messages" : (schedulerType == SchedulerType.APPLICATION_SCHEDULER ? "Time Slots" : "")), DialogOption.HALT_OPTION, false, true);
            }
        }
    });
    // Perform the auto-fill operation in a background thread
    progressThread.start();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JProgressBar(javax.swing.JProgressBar) AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) JLabel(javax.swing.JLabel) SchedulerType(CCDD.CcddConstants.SchedulerType) ArrayList(java.util.ArrayList) JList(javax.swing.JList) List(java.util.List) BackgroundCommand(CCDD.CcddBackgroundCommand.BackgroundCommand)

Example 2 with SchedulerType

use of CCDD.CcddConstants.SchedulerType in project CCDD by nasa.

the class CcddSchedulerHandler method getVariableList.

/**
 ********************************************************************************************
 * Get the list of variables for the data stream
 *
 * @return List of variables; null if the scheduler dialog type is not recognized
 ********************************************************************************************
 */
protected List<Variable> getVariableList() {
    List<Variable> variables = null;
    // Get the scheduler dialog type
    SchedulerType option = getSchedulerOption();
    // Check if this is a telemetry scheduler
    if (option == SchedulerType.TELEMETRY_SCHEDULER) {
        variables = schedulerDb.getVariableList(rateHandler.getRateInformationIndexByRateName(rateName));
    } else // Check if this is an application scheduler
    if (option == SchedulerType.APPLICATION_SCHEDULER) {
        variables = schedulerDb.getVariableList(Integer.valueOf(rateName));
    }
    return variables;
}
Also used : AssociatedVariable(CCDD.CcddClassesDataTable.AssociatedVariable) Variable(CCDD.CcddClassesDataTable.Variable) SchedulerType(CCDD.CcddConstants.SchedulerType)

Example 3 with SchedulerType

use of CCDD.CcddConstants.SchedulerType in project CCDD by nasa.

the class CcddSchedulerHandler method createArrowButtonPanel.

/**
 ********************************************************************************************
 * Create a panel to contain a pair of arrow buttons. Make all but the button icons transparent
 *
 * @return JPanel containing the arrow buttons in a vertical layout
 ********************************************************************************************
 */
private JPanel createArrowButtonPanel() {
    // Create the left and right arrow buttons
    leftArrowBtn = new JButton();
    rightArrowBtn = new JButton();
    // Create a panel to hold the buttons
    JPanel buttonPnl = new JPanel(new GridBagLayout());
    // Create the 'remove item' button
    leftArrowBtn.setIcon(new ImageIcon(getClass().getResource(LEFT_ICON)));
    leftArrowBtn.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    // Create a listener for the remove item button
    leftArrowBtn.addActionListener(new ActionListener() {

        /**
         ************************************************************************************
         * Remove the selected variable(s) from the message
         ************************************************************************************
         */
        @Override
        public void actionPerformed(ActionEvent ae) {
            // Remove the selected variable(s) and get the variable name(s)
            List<String> varName = schedulerEditor.removeSelectedVariable();
            // Check if a variable is selected
            if (varName != null) {
                // Set the variable to be available
                makeVariableAvailable(varName);
                // Set the unused bytes/time field
                setUnusedField();
            }
        }
    });
    // Create the 'add item' button
    rightArrowBtn.setIcon(new ImageIcon(getClass().getResource(RIGHT_ICON)));
    rightArrowBtn.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    // Create a listener for the add item button
    rightArrowBtn.addActionListener(new ActionListener() {

        /**
         ************************************************************************************
         * Add the the selected variable(s) to the message
         ************************************************************************************
         */
        @Override
        public void actionPerformed(ActionEvent ae) {
            // Get the current selected option value
            String selectedValue = optionList.getSelectedValue();
            // Check if an option is selected
            if (selectedValue != null) {
                // Get the selected variables
                List<Variable> variables = schedulerInput.getSelectedVariable();
                // Check if a variable is selected
                if (!variables.isEmpty()) {
                    // Parse the option string to extract the sub-index (if this is a
                    // sub-option) and the message indices
                    Object[] parsedIndices = parseOption(selectedValue.toString());
                    int parentIndex = (int) parsedIndices[0];
                    Integer[] indices = (Integer[]) parsedIndices[1];
                    // Check if the message has a slot available of the specified size
                    if (checkSlotAvailability(indices, variables.size())) {
                        // Assign the variable to the message. The sub-index is -1 if not a
                        // sub-message
                        List<String> excludedVars = addVariableToMessage(variables, indices, parentIndex);
                        // Perform any updates needed following adding variables to messages
                        updateAfterVariableAdded();
                        // Exclude the variable from the variable tree
                        setVariableUnavailable(excludedVars);
                        // Check if it is not a sub-message
                        if (parentIndex == -1) {
                            // Set sub-index to the last message assigned
                            parentIndex = indices[indices.length - 1];
                        }
                        // Select the message
                        schedulerEditor.setSelectedRow(parentIndex);
                        // Update the package list with the new variables
                        schedulerEditor.updateAssignmentList();
                    } else // No slot is available
                    {
                        // Get the scheduler dialog type
                        SchedulerType option = getSchedulerOption();
                        // Check if this is a telemetry scheduler
                        if (option == SchedulerType.TELEMETRY_SCHEDULER) {
                            // Inform the user that the variable can not be added
                            new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b>Cannot assign variable to a message", "Assign Fail", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                        } else // Check if this is an application scheduler
                        if (option == SchedulerType.APPLICATION_SCHEDULER) {
                            // Inform the user that the application can not be added
                            new CcddDialogHandler().showMessageDialog(schedulerDlg.getDialog(), "<html><b>Cannot assign application to a time slot", "Over-scheduled Time Slot", JOptionPane.WARNING_MESSAGE, DialogOption.OK_OPTION);
                        }
                    }
                    // Reset the Scheduler table names to normal
                    schedulerEditor.resetMessageAvailability();
                    // Update the unused bytes/time field
                    setUnusedField();
                }
            }
        }
    });
    // Set the layout manager characteristics
    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
    // Set the border
    buttonPnl.setBorder(BorderFactory.createEmptyBorder());
    // Hide everything but the arrow button icons
    rightArrowBtn.setOpaque(false);
    rightArrowBtn.setContentAreaFilled(false);
    rightArrowBtn.setBorderPainted(false);
    leftArrowBtn.setOpaque(false);
    leftArrowBtn.setContentAreaFilled(false);
    leftArrowBtn.setBorderPainted(false);
    // Add the buttons to the panel
    buttonPnl.add(rightArrowBtn, gbc);
    gbc.insets.bottom = (getSchedulerOption() == SchedulerType.TELEMETRY_SCHEDULER ? 15 : 0);
    gbc.gridy++;
    buttonPnl.add(leftArrowBtn, gbc);
    return buttonPnl;
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) SchedulerType(CCDD.CcddConstants.SchedulerType) ActionListener(java.awt.event.ActionListener) ArrayList(java.util.ArrayList) JList(javax.swing.JList) List(java.util.List)

Example 4 with SchedulerType

use of CCDD.CcddConstants.SchedulerType in project CCDD by nasa.

the class CcddSchedulerHandler method createDualScrollPanelwithButtons.

/**
 ********************************************************************************************
 * Create dual scroll panels
 *
 * @return Split pane containing the dual panels
 ********************************************************************************************
 */
@SuppressWarnings("serial")
private JSplitPane createDualScrollPanelwithButtons() {
    // Create an empty border
    Border emptyBorder = BorderFactory.createEmptyBorder();
    // Set the initial layout manager characteristics
    GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing() / 2, 0), 0, 0);
    // Create the scheduler input (variables or applications) handler
    schedulerInput = schedulerDlg.createSchedulerInput(rateName);
    int totalMsgs = 0;
    int totalBytes = 0;
    int msgsPerSec = 0;
    // Get the scheduler dialog type
    SchedulerType option = getSchedulerOption();
    // Check if this is the telemetry scheduler
    if (option == SchedulerType.TELEMETRY_SCHEDULER) {
        // Get the information for the rate
        RateInformation info = rateHandler.getRateInformationByRateName(rateName);
        // Get the rate parameters
        totalMsgs = info.getMaxMsgsPerCycle();
        totalBytes = info.getMaxBytesPerSec();
        msgsPerSec = rateHandler.getMaxMsgsPerSecond();
    } else // Check if this is an application scheduler
    if (option == SchedulerType.APPLICATION_SCHEDULER) {
        // Set the total number of messages to the largest rate
        totalMsgs = appHandler.getMsgsPerCycle();
        // Set messages per second to highest to ensure the cycle time is 1 second
        msgsPerSec = appHandler.getMaxMsgsPerSecond();
        totalBytes = (int) ((Float.valueOf(totalMsgs) / Float.valueOf(msgsPerSec)) * 1000);
    }
    // Create the scheduler editor handler
    schedulerEditor = new CcddSchedulerEditorHandler(ccddMain, this, totalMsgs, totalBytes, msgsPerSec);
    // Create the options model
    optionModel = new DefaultListModel<String>();
    // Set the cycle value label to the period
    cycleFld.setText(String.valueOf(Float.valueOf(totalMsgs) / Float.valueOf(msgsPerSec)));
    // Create panels to hold the components
    JPanel packPnl = new JPanel(new GridBagLayout());
    JPanel rateSelectPnl = new JPanel(new GridBagLayout());
    JPanel optionPnl = new JPanel(new GridBagLayout());
    packPnl.setBorder(emptyBorder);
    rateSelectPnl.setBorder(emptyBorder);
    optionPnl.setBorder(emptyBorder);
    // Create the options label and add it to the rate panel
    JLabel optionLbl = new JLabel("Options");
    optionLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    optionLbl.setForeground(ModifiableColorInfo.SPECIAL_LABEL_TEXT.getColor());
    optionPnl.add(optionLbl, gbc);
    // Create the rate label and add it to the rate panel
    JLabel rateSelectLbl = new JLabel("Rate Filter ");
    rateSelectLbl.setFont(ModifiableFontInfo.LABEL_BOLD.getFont());
    rateSelectLbl.setForeground(ModifiableColorInfo.LABEL_TEXT.getColor());
    gbc.weighty = 1.0;
    gbc.gridx++;
    gbc.insets.top = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
    gbc.insets.bottom = ModifiableSpacingInfo.LABEL_VERTICAL_SPACING.getSpacing();
    rateSelectPnl.add(rateSelectLbl, gbc);
    // Create the combo box that displays the variable rates
    rateFilter = new PaddedComboBox(schedulerInput.getAvailableRates(), ModifiableFontInfo.INPUT_TEXT.getFont()) {

        /**
         ************************************************************************************
         * Override so that items flagged as disabled (grayed out) can't be selected. Only the
         * telemetry scheduler makes use of this; it has no effect on the application scheduler
         ************************************************************************************
         */
        @Override
        public void setSelectedItem(Object anObject) {
            // Check if the item isn't flagged as disabled
            if (!anObject.toString().startsWith(DISABLED_TEXT_COLOR)) {
                // Set the selected item to the specified item, if it exists in the list
                super.setSelectedItem(anObject);
            }
        }
    };
    rateFilter.setBorder(emptyBorder);
    rateFilter.setSelectedItem(schedulerInput.getSelectedRate());
    // Add a listener for rate filter selection changes
    rateFilter.addActionListener(new ActionListener() {

        /**
         ************************************************************************************
         * Rebuild the table tree using the selected rate filter
         ************************************************************************************
         */
        @Override
        public void actionPerformed(ActionEvent ae) {
            // Get the rate selected in the combo box
            String rate = ((JComboBox<?>) ae.getSource()).getSelectedItem().toString();
            // Update the variable tree to display variables with the given rate
            schedulerInput.updateVariableTree(rate);
            // Set the options panel to display the options for the selected rate
            getTelemetryOptions();
        }
    });
    // Add the rate filter to the rate panel
    gbc.gridx++;
    rateSelectPnl.add(rateFilter, gbc);
    // Create a list that will contain all the telemetry options for a variable
    optionList = new JList<String>(optionModel);
    optionList.setFont(ModifiableFontInfo.LABEL_PLAIN.getFont());
    optionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // Add a listener to set the message availability given the selected option
    optionList.addListSelectionListener(new ListSelectionListener() {

        /**
         ************************************************************************************
         * Handle a selection change
         ************************************************************************************
         */
        @Override
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            // Update the scheduler table text highlighting
            updateSchedulerTableHighlight();
        }
    });
    // Add the list to a scroll pane that will be placed next to the variable list
    JScrollPane optionScroll = new JScrollPane(optionList);
    optionScroll.setBorder(border);
    // Set the preferred width of the tree's scroll pane
    optionScroll.setPreferredSize(new Dimension(Math.min(Math.max(optionScroll.getPreferredSize().width, 200), 200), optionScroll.getPreferredSize().height));
    // Set the minimum size to the preferred size
    optionScroll.setMinimumSize(optionScroll.getPreferredSize());
    // Add the option scroll pane to the option panel
    gbc.insets.top = 0;
    gbc.insets.bottom = 0;
    gbc.gridx = 0;
    gbc.gridy++;
    optionPnl.add(optionScroll, gbc);
    // Add the rate selection panel to the option panel
    gbc.gridy++;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    optionPnl.add(rateSelectPnl, gbc);
    // Add the option panel to the pack panel
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 0;
    gbc.gridx++;
    packPnl.add(optionPnl, gbc);
    // Create the split pane containing the input tree and options panel
    JSplitPane leftSpltPn = new CustomSplitPane(schedulerInput.getInputPanel(), packPnl, null, JSplitPane.HORIZONTAL_SPLIT);
    // Create the split pane containing the left split pane and the split pane containing the
    // scheduler and assignment tree/list. Use the arrow button panel as the split pane divider
    JSplitPane allSpltPn = new CustomSplitPane(leftSpltPn, schedulerEditor.getSchedulerAndAssignPanel(), createArrowButtonPanel(), JSplitPane.HORIZONTAL_SPLIT);
    // Set the options list to display the starting rate value
    getTelemetryOptions();
    return allSpltPn;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RateInformation(CCDD.CcddClassesDataTable.RateInformation) CustomSplitPane(CCDD.CcddClassesComponent.CustomSplitPane) PaddedComboBox(CCDD.CcddClassesComponent.PaddedComboBox) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) SchedulerType(CCDD.CcddConstants.SchedulerType) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) Border(javax.swing.border.Border) BevelBorder(javax.swing.border.BevelBorder)

Example 5 with SchedulerType

use of CCDD.CcddConstants.SchedulerType in project CCDD by nasa.

the class CcddSchedulerHandler method getStoredData.

/**
 ********************************************************************************************
 * Get the list of messages stored in the database
 *
 * @return List of messages for the data stream stored in the database; null if the scheduler
 *         dialog type is not recognized
 ********************************************************************************************
 */
protected List<Message> getStoredData() {
    List<Message> messages = null;
    // Get the scheduler dialog type
    SchedulerType option = getSchedulerOption();
    // Check if this is a telemetry scheduler
    if (option == SchedulerType.TELEMETRY_SCHEDULER) {
        // Get the variable message assignments for the current data stream
        messages = schedulerDb.getStoredData(rateHandler.getRateInformationIndexByRateName(rateName));
        // Set the link name for the variables in the messages
        ((CcddTelemetrySchedulerInput) schedulerInput).setLinks(messages, rateName);
    } else // Check if this is an application scheduler
    if (option == SchedulerType.APPLICATION_SCHEDULER) {
        // Get the application time slot assignments
        messages = schedulerDb.getStoredData(Integer.valueOf(rateName));
    }
    return messages;
}
Also used : Message(CCDD.CcddClassesDataTable.Message) SchedulerType(CCDD.CcddConstants.SchedulerType)

Aggregations

SchedulerType (CCDD.CcddConstants.SchedulerType)5 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 JPanel (javax.swing.JPanel)3 AssociatedVariable (CCDD.CcddClassesDataTable.AssociatedVariable)2 Variable (CCDD.CcddClassesDataTable.Variable)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JLabel (javax.swing.JLabel)2 JList (javax.swing.JList)2 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)1 CustomSplitPane (CCDD.CcddClassesComponent.CustomSplitPane)1 PaddedComboBox (CCDD.CcddClassesComponent.PaddedComboBox)1 Message (CCDD.CcddClassesDataTable.Message)1 RateInformation (CCDD.CcddClassesDataTable.RateInformation)1 Dimension (java.awt.Dimension)1 ImageIcon (javax.swing.ImageIcon)1