use of javax.swing.JTabbedPane in project JMRI by JMRI.
the class UserMessagePreferencesPane method newMessageTab.
private synchronized void newMessageTab() {
remove(tab);
tab = new JTabbedPane();
//might need to redo this so that it doesn't recreate everything all the time.
_comboBoxes = new HashMap<>();
_checkBoxes = new HashMap<>();
ArrayList<String> preferenceClassList = p.getPreferencesClasses();
for (String strClass : preferenceClassList) {
JPanel classholder = new JPanel();
classholder.setLayout(new BorderLayout());
HashMap<Integer, String> options;
boolean add = false;
boolean addtoindependant = false;
if (p.getPreferencesSize(strClass) > 1) {
addtoindependant = true;
}
JPanel classPanel = new JPanel();
classPanel.setLayout(new BoxLayout(classPanel, BoxLayout.Y_AXIS));
classPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
for (int j = 0; j < p.getMultipleChoiceSize(strClass); j++) {
String itemName = p.getChoiceName(strClass, j);
options = p.getChoiceOptions(strClass, itemName);
if (options != null) {
JComboBox<Object> optionBox = new JComboBox<>();
ListItems li = new ListItems(strClass, itemName);
_comboBoxes.put(optionBox, li);
li.isIncluded(addtoindependant);
optionBox.removeAllItems();
for (Object value : options.values()) {
optionBox.addItem(value);
}
int current = p.getMultipleChoiceOption(strClass, itemName);
if (options.containsKey(current)) {
optionBox.setSelectedItem(options.get(current));
}
if (addtoindependant) {
JPanel optionPanel = new JPanel();
JLabel _comboLabel = new JLabel(p.getChoiceDescription(strClass, itemName), JLabel.LEFT);
_comboLabel.setAlignmentX(0.5f);
optionPanel.add(_comboLabel);
optionPanel.add(optionBox);
add = true;
classPanel.add(optionPanel);
}
}
}
ArrayList<String> singleList = p.getPreferenceList(strClass);
if (!singleList.isEmpty()) {
for (int i = 0; i < singleList.size(); i++) {
String itemName = p.getPreferenceItemName(strClass, i);
String description = p.getPreferenceItemDescription(strClass, itemName);
if ((description != null) && (!description.isEmpty())) {
JCheckBox check = new JCheckBox(description);
check.setSelected(p.getPreferenceState(strClass, itemName));
ListItems li = new ListItems(strClass, itemName);
_checkBoxes.put(check, li);
li.isIncluded(addtoindependant);
if (addtoindependant) {
classPanel.add(check);
add = true;
}
}
}
}
if (add) {
classholder.add(classPanel, BorderLayout.NORTH);
if (p.getPreferencesSize(strClass) > 1) {
JScrollPane scrollPane = new JScrollPane(classholder);
scrollPane.setPreferredSize(new Dimension(300, 300));
scrollPane.setBorder(BorderFactory.createEmptyBorder());
tab.add(scrollPane, p.getClassDescription(strClass));
}
}
}
HashMap<String, ArrayList<ListItems>> countOfItems = new HashMap<>();
HashMap<String, ArrayList<JCheckBox>> countOfItemsCheck = new HashMap<>();
HashMap<String, ArrayList<JComboBox<Object>>> countOfItemsCombo = new HashMap<>();
for (JComboBox<Object> key : this._comboBoxes.keySet()) {
if (!_comboBoxes.get(key).isIncluded()) {
String strItem = _comboBoxes.get(key).getItem();
if (!countOfItems.containsKey(strItem)) {
countOfItems.put(strItem, new ArrayList<>());
countOfItemsCombo.put(strItem, new ArrayList<>());
}
ArrayList<ListItems> a = countOfItems.get(strItem);
a.add(_comboBoxes.get(key));
ArrayList<JComboBox<Object>> acb = countOfItemsCombo.get(strItem);
acb.add(key);
}
}
for (JCheckBox key : this._checkBoxes.keySet()) {
if (!_checkBoxes.get(key).isIncluded()) {
String strItem = _checkBoxes.get(key).getItem();
if (!countOfItems.containsKey(strItem)) {
countOfItems.put(strItem, new ArrayList<>());
countOfItemsCheck.put(strItem, new ArrayList<>());
}
ArrayList<ListItems> a = countOfItems.get(strItem);
a.add(_checkBoxes.get(key));
ArrayList<JCheckBox> acb = countOfItemsCheck.get(strItem);
acb.add(key);
}
}
JPanel miscPanel = new JPanel();
miscPanel.setLayout(new BoxLayout(miscPanel, BoxLayout.Y_AXIS));
JPanel mischolder = new JPanel();
mischolder.setLayout(new BorderLayout());
mischolder.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
for (String item : countOfItems.keySet()) {
ArrayList<ListItems> a = countOfItems.get(item);
ArrayList<JCheckBox> chb = countOfItemsCheck.get(item);
ArrayList<JComboBox<Object>> cob = countOfItemsCombo.get(item);
if (a.size() > 1) {
JPanel tableDeleteTabPanel = new JPanel();
tableDeleteTabPanel.setLayout(new BoxLayout(tableDeleteTabPanel, BoxLayout.Y_AXIS));
JLabel tableDeleteInfoLabel = new JLabel(p.getChoiceDescription(a.get(0).getClassName(), a.get(0).getItem()), JLabel.CENTER);
tableDeleteInfoLabel.setAlignmentX(0.5f);
tableDeleteTabPanel.add(tableDeleteInfoLabel);
JPanel inside = new JPanel();
if (cob != null) {
JPanel insideCombo = new JPanel();
int gridsize = (int) (Math.ceil((cob.size() / 2.0)));
insideCombo.setLayout(new jmri.util.javaworld.GridLayout2(gridsize, 2 * 2, 10, 2));
for (JComboBox<Object> combo : cob) {
JLabel _comboLabel = new JLabel(p.getClassDescription(_comboBoxes.get(combo).getClassName()), JLabel.RIGHT);
_comboBoxes.get(combo).isIncluded(true);
insideCombo.add(_comboLabel);
insideCombo.add(combo);
}
inside.add(insideCombo);
}
if (chb != null) {
JPanel insideCheck = new JPanel();
insideCheck.setLayout(new jmri.util.javaworld.GridLayout2(chb.size(), 1));
for (JCheckBox check : chb) {
JLabel _checkLabel = new JLabel(p.getClassDescription(_checkBoxes.get(check).getClassName()), JLabel.RIGHT);
_checkBoxes.get(check).isIncluded(true);
insideCheck.add(_checkLabel);
insideCheck.add(check);
}
inside.add(insideCheck);
}
tableDeleteTabPanel.add(inside);
JScrollPane scrollPane = new JScrollPane(tableDeleteTabPanel);
scrollPane.setPreferredSize(new Dimension(300, 300));
tab.add(scrollPane, item);
} else {
JPanel itemPanel = new JPanel();
JPanel subItem = new JPanel();
subItem.setLayout(new BoxLayout(subItem, BoxLayout.Y_AXIS));
subItem.add(new JLabel(p.getClassDescription(a.get(0).getClassName()), JLabel.CENTER));
if (countOfItemsCheck.containsKey(item)) {
subItem.add(countOfItemsCheck.get(item).get(0));
itemPanel.add(subItem);
miscPanel.add(itemPanel);
}
}
}
add(tab);
mischolder.add(miscPanel, BorderLayout.NORTH);
JScrollPane miscScrollPane = new JScrollPane(mischolder);
miscScrollPane.setPreferredSize(new Dimension(300, 300));
tab.add(miscScrollPane, "Misc items");
revalidate();
}
use of javax.swing.JTabbedPane in project JMRI by JMRI.
the class ControllerFilterFrame method initComponents.
@Override
public void initComponents() throws Exception {
JTabbedPane tabbedPane = new JTabbedPane();
if (InstanceManager.getNullableDefault(jmri.TurnoutManager.class) != null) {
tabbedPane.addTab(rb.getString("LabelTurnout"), null, addTurnoutPanel(), rb.getString("ToolTipTurnoutTab"));
}
if (InstanceManager.getNullableDefault(jmri.RouteManager.class) != null) {
tabbedPane.addTab(rb.getString("LabelRoute"), null, addRoutePanel(), rb.getString("ToolTipRouteTab"));
}
add(tabbedPane);
pack();
addHelpMenu("package.jmri.jmrit.withrottle.UserInterface", true);
}
use of javax.swing.JTabbedPane in project JMRI by JMRI.
the class EcosLocoTableTabAction method createModel.
@Override
protected void createModel() {
dataPanel = new JPanel();
dataTabs = new JTabbedPane();
dataPanel.setLayout(new BorderLayout());
java.util.List<EcosSystemConnectionMemo> list = jmri.InstanceManager.getList(EcosSystemConnectionMemo.class);
if (list != null) {
for (EcosSystemConnectionMemo eMemo : list) {
//We only want to add connections that have an active loco address manager
if (eMemo.getLocoAddressManager() != null) {
TabbedTableItem itemModel = new TabbedTableItem(eMemo.getUserName(), true, eMemo.getLocoAddressManager(), getNewTableAction(eMemo.getUserName(), eMemo));
tabbedTableArray.add(itemModel);
}
}
}
if (tabbedTableArray.size() == 1) {
EcosLocoTableAction table = (EcosLocoTableAction) tabbedTableArray.get(0).getAAClass();
table.addToPanel(this);
dataPanel.add(tabbedTableArray.get(0).getPanel(), BorderLayout.CENTER);
} else {
for (int x = 0; x < tabbedTableArray.size(); x++) {
EcosLocoTableAction table = (EcosLocoTableAction) tabbedTableArray.get(x).getAAClass();
table.addToPanel(this);
dataTabs.addTab(tabbedTableArray.get(x).getItemString(), null, tabbedTableArray.get(x).getPanel(), null);
}
dataTabs.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
setMenuBar(f);
}
});
dataPanel.add(dataTabs, BorderLayout.CENTER);
}
init = true;
}
use of javax.swing.JTabbedPane in project processdash by dtuma.
the class LOCDiffDialog method createTabPanel.
private Component createTabPanel(List<Panel> panels) {
tabPane = new JTabbedPane();
String prefTab = PREFS.get(SELECTED_TAB_PREF, "");
for (Panel p : panels) {
JPanel wrap = new JPanel(new BorderLayout());
wrap.add(p.getConfigPanel());
wrap.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));
tabPane.addTab(p.getShortName(), wrap);
if (p.getId().equals(prefTab))
tabPane.setSelectedIndex(tabPane.getTabCount() - 1);
}
return tabPane;
}
use of javax.swing.JTabbedPane in project JMRI by JMRI.
the class ItemPalette method buildTabPane.
/**
* Add the tabs on the the Control Panel Editor
*/
static void buildTabPane(ItemPalette palette, Editor editor) {
_tabPane = new JTabbedPane();
_tabIndex = new HashMap<String, ItemPanel>();
ItemPanel itemPanel = new TableItemPanel(palette, "Turnout", null, PickListModel.turnoutPickModelInstance(), editor);
// show panel on start
itemPanel.init();
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameTurnout"));
_tabIndex.put("Turnout", itemPanel);
itemPanel = new TableItemPanel(palette, "Sensor", null, PickListModel.sensorPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameSensor"));
_tabIndex.put("Sensor", itemPanel);
itemPanel = new SignalHeadItemPanel(palette, "SignalHead", null, PickListModel.signalHeadPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameSignalHead"));
_tabIndex.put("SignalHead", itemPanel);
itemPanel = new SignalMastItemPanel(palette, "SignalMast", null, PickListModel.signalMastPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameSignalMast"));
_tabIndex.put("SignalMast", itemPanel);
itemPanel = new MemoryItemPanel(palette, "Memory", null, PickListModel.memoryPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameMemory"));
_tabIndex.put("Memory", itemPanel);
itemPanel = new ReporterItemPanel(palette, "Reporter", null, PickListModel.reporterPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameReporter"));
_tabIndex.put("Reporter", itemPanel);
itemPanel = new TableItemPanel(palette, "Light", null, PickListModel.lightPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNameLight"));
_tabIndex.put("Light", itemPanel);
itemPanel = new MultiSensorItemPanel(palette, "MultiSensor", null, PickListModel.multiSensorPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("MultiSensor"));
_tabIndex.put("MultiSensor", itemPanel);
ItemPanel iconPanel = new IconItemPanel(palette, "Icon", editor);
_tabPane.add(new JScrollPane(iconPanel), Bundle.getMessage("Icon"));
// changed from "itemPanel"
_tabIndex.put("Icon", iconPanel);
iconPanel = new BackgroundItemPanel(palette, "Background", editor);
_tabPane.add(new JScrollPane(iconPanel), Bundle.getMessage("Background"));
_tabIndex.put("Background", iconPanel);
iconPanel = new TextItemPanel(palette, "Text", editor);
_tabPane.add(new JScrollPane(iconPanel), Bundle.getMessage("Text"));
_tabIndex.put("Text", iconPanel);
iconPanel = new RPSItemPanel(palette, "RPSReporter", null, editor);
// itemPanel.init(); // show panel on start
_tabPane.add(new JScrollPane(iconPanel), Bundle.getMessage("RPSReporter"));
_tabIndex.put("RPSReporter", iconPanel);
iconPanel = new ClockItemPanel(palette, "FastClock", editor);
_tabPane.add(new JScrollPane(iconPanel), Bundle.getMessage("FastClock"));
_tabIndex.put("FastClock", iconPanel);
itemPanel = new IndicatorItemPanel(palette, "IndicatorTrack", null, editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("IndicatorTrack"));
_tabIndex.put("IndicatorTrack", itemPanel);
itemPanel = new IndicatorTOItemPanel(palette, "IndicatorTO", null, PickListModel.turnoutPickModelInstance(), editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("IndicatorTO"));
_tabIndex.put("IndicatorTO", itemPanel);
itemPanel = new PortalItemPanel(palette, "Portal", null, editor);
_tabPane.add(new JScrollPane(itemPanel), Bundle.getMessage("BeanNamePortal"));
_tabIndex.put("Portal", itemPanel);
_tabPane.addChangeListener(palette);
// _tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
Aggregations