use of CCDD.CcddClassesComponent.PaddedComboBox 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;
}
use of CCDD.CcddClassesComponent.PaddedComboBox in project CCDD by nasa.
the class CcddTableTypeEditorHandler method setUpInputTypeColumn.
/**
********************************************************************************************
* Set up the combo box containing the available table type input data types for display in the
* table's Input Type cells
********************************************************************************************
*/
private void setUpInputTypeColumn() {
// Create a combo box for displaying table type input types
comboBox = new PaddedComboBox(getInputTypeNames(), InputDataType.getDescriptions(true), ModifiableFontInfo.DATA_TABLE_CELL.getFont()) {
/**
************************************************************************************
* Override so that items flagged as disabled (grayed out) are correctly identified and
* selected
************************************************************************************
*/
@Override
public void setSelectedItem(Object anObject) {
// list
if (getIndexOfItem(DISABLED_TEXT_COLOR + anObject.toString()) != -1) {
// Update the specified item to include the disable tag
anObject = DISABLED_TEXT_COLOR + anObject;
}
// Set the selected item to the specified item, if it exists in the list
super.setSelectedItem(anObject);
}
};
// Add a listener to the combo box for focus changes
comboBox.addFocusListener(new FocusAdapter() {
/**
************************************************************************************
* Handle a focus gained event so that the combo box automatically expands when
* selected
************************************************************************************
*/
@Override
public void focusGained(FocusEvent fe) {
comboBox.showPopup();
}
});
// Get the index of the input data type column in view coordinates
inputTypeIndex = table.convertColumnIndexToView(TableTypeEditorColumnInfo.INPUT_TYPE.ordinal());
// Set the column table editor to the combo box
table.getColumnModel().getColumn(inputTypeIndex).setCellEditor(new DefaultCellEditor(comboBox));
// Set the default selected type
comboBox.setSelectedItem(InputDataType.TEXT.getInputName());
}
Aggregations