use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class TransitTableAction method addEditPressed.
void addEditPressed() {
pref = jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class);
if (addFrame == null) {
addFrame = new JmriJFrame(Bundle.getMessage("TitleAddTransit"));
addFrame.addHelpMenu("package.jmri.jmrit.beantable.TransitAddEdit", true);
addFrame.getContentPane().setLayout(new BoxLayout(addFrame.getContentPane(), BoxLayout.Y_AXIS));
JPanel p;
p = new JPanel();
p.setLayout(new FlowLayout());
p.add(sysNameLabel);
p.add(sysNameFixed);
p.add(sysName);
sysName.setToolTipText(rbx.getString("TransitSystemNameHint"));
p.add(new JLabel(" "));
p.add(userNameLabel);
p.add(userName);
userName.setToolTipText(rbx.getString("TransitUserNameHint"));
addFrame.getContentPane().add(p);
p = new JPanel();
((FlowLayout) p.getLayout()).setVgap(0);
p.add(_autoSystemName);
_autoSystemName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
autoSystemName();
}
});
if (pref.getSimplePreferenceState(systemNameAuto)) {
_autoSystemName.setSelected(true);
}
addFrame.getContentPane().add(p);
addFrame.getContentPane().add(new JSeparator());
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(new JLabel(rbx.getString("SectionTableMessage")));
p1.add(p11);
JPanel p12 = new JPanel();
// initialize table of sections
sectionTableModel = new SectionTableModel();
JTable sectionTable = new JTable(sectionTableModel);
sectionTable.setRowSelectionAllowed(false);
sectionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(650, 150));
TableColumnModel sectionColumnModel = sectionTable.getColumnModel();
TableColumn sequenceColumn = sectionColumnModel.getColumn(SectionTableModel.SEQUENCE_COLUMN);
sequenceColumn.setResizable(true);
sequenceColumn.setMinWidth(50);
sequenceColumn.setMaxWidth(70);
TableColumn sectionColumn = sectionColumnModel.getColumn(SectionTableModel.SECTIONNAME_COLUMN);
sectionColumn.setResizable(true);
sectionColumn.setMinWidth(150);
sectionColumn.setMaxWidth(210);
TableColumn actionColumn = sectionColumnModel.getColumn(SectionTableModel.ACTION_COLUMN);
// install button renderer and editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
sectionTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
sectionTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton(rbx.getString("AddEditActions"));
sectionTable.setRowHeight(testButton.getPreferredSize().height);
actionColumn.setResizable(false);
actionColumn.setMinWidth(testButton.getPreferredSize().width);
TableColumn alternateColumn = sectionColumnModel.getColumn(SectionTableModel.ALTERNATE_COLUMN);
alternateColumn.setResizable(true);
alternateColumn.setMinWidth(140);
alternateColumn.setMaxWidth(170);
JScrollPane sectionTableScrollPane = new JScrollPane(sectionTable);
p12.add(sectionTableScrollPane, BorderLayout.CENTER);
p1.add(p12);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(primarySectionBox);
primarySectionBox.setToolTipText(rbx.getString("PrimarySectionBoxHint"));
p13.add(addNextSection = new JButton(rbx.getString("AddPrimaryButton")));
addNextSection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addNextSectionPressed(e);
}
});
addNextSection.setToolTipText(rbx.getString("AddPrimaryButtonHint"));
p1.add(p13);
JPanel p14 = new JPanel();
p14.setLayout(new FlowLayout());
p14.add(alternateSectionBox);
alternateSectionBox.setToolTipText(rbx.getString("AlternateSectionBoxHint"));
p14.add(addAlternateSection = new JButton(rbx.getString("AddAlternateButton")));
addAlternateSection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addAlternateSectionPressed(e);
}
});
addAlternateSection.setToolTipText(rbx.getString("AddAlternateButtonHint"));
p14.add(new JLabel(" "));
p14.add(insertAtBeginningBox);
insertAtBeginningBox.setToolTipText(rbx.getString("InsertAtBeginningBoxHint"));
p14.add(insertAtBeginning = new JButton(rbx.getString("InsertAtBeginningButton")));
insertAtBeginning.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
insertAtBeginningPressed(e);
}
});
insertAtBeginning.setToolTipText(rbx.getString("InsertAtBeginningButtonHint"));
p1.add(p14);
p1.add(new JSeparator());
JPanel p15 = new JPanel();
p15.setLayout(new FlowLayout());
p15.add(deleteSections = new JButton(rbx.getString("DeleteSectionsButton")));
deleteSections.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteAllSections(e);
}
});
deleteSections.setToolTipText(rbx.getString("DeleteSectionsButtonHint"));
p15.add(new JLabel(" "));
p15.add(removeLastSection = new JButton(rbx.getString("RemoveLastButton")));
removeLastSection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeLastSectionPressed(e);
}
});
removeLastSection.setToolTipText(rbx.getString("RemoveLastButtonHint"));
p15.add(new JLabel(" "));
p15.add(removeFirstSection = new JButton(rbx.getString("RemoveFirstButton")));
removeFirstSection.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeFirstSectionPressed(e);
}
});
removeFirstSection.setToolTipText(rbx.getString("RemoveFirstButtonHint"));
p1.add(p15);
JPanel p16 = new JPanel();
p16.setLayout(new FlowLayout());
p16.add(seqNumLabel);
p16.add(new JLabel(" "));
p16.add(seqNum);
seqNum.setToolTipText(rbx.getString("SeqNumHint"));
p1.add(p16);
JPanel p17 = new JPanel();
p17.setLayout(new FlowLayout());
p17.add(replacePrimaryForSequence = new JButton(rbx.getString("ReplacePrimaryForSeqButton")));
replacePrimaryForSequence.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
replacePrimaryForSeqPressed(e);
}
});
replacePrimaryForSequence.setToolTipText(rbx.getString("ReplacePrimaryForSeqButtonHint"));
p17.add(new JLabel(" "));
p17.add(deleteAlternateForSequence = new JButton(rbx.getString("DeleteAlternateForSeqButton")));
deleteAlternateForSequence.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deleteAlternateForSeqPressed(e);
}
});
deleteAlternateForSequence.setToolTipText(rbx.getString("DeleteAlternateForSeqButtonHint"));
p17.add(new JLabel(" "));
p17.add(addAlternateForSequence = new JButton(rbx.getString("AddAlternateForSeqButton")));
addAlternateForSequence.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addAlternateForSeqPressed(e);
}
});
addAlternateForSequence.setToolTipText(rbx.getString("AddAlternateForSeqButtonHint"));
p1.add(p17);
addFrame.getContentPane().add(p1);
// set up bottom buttons
addFrame.getContentPane().add(new JSeparator());
JButton cancel = null;
JPanel pb = new JPanel();
pb.setLayout(new FlowLayout());
pb.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
cancelPressed(e);
}
});
cancel.setToolTipText(rbx.getString("CancelButtonHint"));
pb.add(create = new JButton(Bundle.getMessage("ButtonCreate")));
create.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
createPressed(e);
}
});
create.setToolTipText(rbx.getString("SectionCreateButtonHint"));
pb.add(update = new JButton(Bundle.getMessage("ButtonUpdate")));
update.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updatePressed(e);
}
});
update.setToolTipText(rbx.getString("SectionUpdateButtonHint"));
addFrame.getContentPane().add(pb);
}
if (editMode) {
// setup for edit window
_autoSystemName.setVisible(false);
sysNameLabel.setEnabled(true);
create.setVisible(false);
update.setVisible(true);
sysName.setVisible(false);
sysNameFixed.setVisible(true);
initializeEditInformation();
} else {
// setup for create window
_autoSystemName.setVisible(true);
_autoSystemName.setEnabled(true);
autoSystemName();
create.setVisible(true);
create.setEnabled(true);
update.setVisible(false);
sysName.setVisible(true);
sysNameFixed.setVisible(false);
if (duplicateMode) {
// setup with information from previous Transit
initializeEditInformation();
sysName.setText(curTransit.getSystemName());
curTransit = null;
} else {
deleteAllSections(null);
}
}
initializeSectionCombos();
addFrame.pack();
addFrame.setVisible(true);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class LocationsTableModel method initTable.
void initTable(LocationsTableFrame frame, JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(ACTIONCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(ACTIONCOLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDITCOLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDITCOLUMN).setCellEditor(buttonEditor);
// set column preferred widths
table.getColumnModel().getColumn(IDCOLUMN).setPreferredWidth(40);
table.getColumnModel().getColumn(NAMECOLUMN).setPreferredWidth(200);
table.getColumnModel().getColumn(TRACKCOLUMN).setPreferredWidth(Math.max(60, new JLabel(Bundle.getMessage("Class/Interchange") + Bundle.getMessage("Spurs") + Bundle.getMessage("Yards")).getPreferredSize().width + 20));
table.getColumnModel().getColumn(LENGTHCOLUMN).setPreferredWidth(Math.max(60, new JLabel(getColumnName(LENGTHCOLUMN)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(USEDLENGTHCOLUMN).setPreferredWidth(60);
table.getColumnModel().getColumn(ROLLINGSTOCK).setPreferredWidth(Math.max(80, new JLabel(getColumnName(ROLLINGSTOCK)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(PICKUPS).setPreferredWidth(Math.max(60, new JLabel(getColumnName(PICKUPS)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(DROPS).setPreferredWidth(Math.max(60, new JLabel(getColumnName(DROPS)).getPreferredSize().width + 10));
table.getColumnModel().getColumn(ACTIONCOLUMN).setPreferredWidth(Math.max(80, new JLabel(Bundle.getMessage("Yardmaster")).getPreferredSize().width + 40));
table.getColumnModel().getColumn(EDITCOLUMN).setPreferredWidth(80);
frame.loadTableDetails(table);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class CarsTableModel method initTable.
void initTable() {
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
_table.setColumnModel(tcm);
_table.createDefaultColumnsFromModel();
// Install the button handlers
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(SET_COLUMN).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(SET_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
// set column preferred widths
for (int i = 0; i < tcm.getColumnCount(); i++) {
tcm.getColumn(i).setPreferredWidth(tableColumnWidths[i]);
}
_frame.loadTableDetails(_table);
// turn off columns
tcm.setColumnVisible(tcm.getColumnByModelIndex(SELECT_COLUMN), isSelectVisible);
tcm.setColumnVisible(tcm.getColumnByModelIndex(COLOR_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(FINAL_DESTINATION_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RWE_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RWE_LOAD_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(BUILT_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(OWNER_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(VALUE_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHEN_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(RFID_WHERE_LAST_SEEN_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(WAIT_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(PICKUP_COLUMN), false);
tcm.setColumnVisible(tcm.getColumnByModelIndex(LAST_COLUMN), false);
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class RouteEditTableModel method initTable.
private void initTable(JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(COMMENT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(COMMENT_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(UP_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(UP_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(DOWN_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(DOWN_COLUMN).setCellEditor(buttonEditor);
tcm.getColumn(DELETE_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(DELETE_COLUMN).setCellEditor(buttonEditor);
table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
// set column preferred widths
table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(40);
table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(150);
table.getColumnModel().getColumn(TRAIN_DIRECTION_COLUMN).setPreferredWidth(95);
table.getColumnModel().getColumn(MAXMOVES_COLUMN).setPreferredWidth(50);
table.getColumnModel().getColumn(RANDOM_CONTROL_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(PICKUP_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(DROP_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(WAIT_COLUMN).setPreferredWidth(65);
table.getColumnModel().getColumn(MAXLENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(GRADE).setPreferredWidth(50);
table.getColumnModel().getColumn(TRAINICONX).setPreferredWidth(35);
table.getColumnModel().getColumn(TRAINICONY).setPreferredWidth(35);
table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(UP_COLUMN).setPreferredWidth(60);
table.getColumnModel().getColumn(DOWN_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(DELETE_COLUMN).setPreferredWidth(70);
_frame.loadTableDetails(table);
// does not use a table sorter
table.setRowSorter(null);
updateList();
}
use of jmri.util.table.ButtonEditor in project JMRI by JMRI.
the class RoutesTableModel method initTable.
void initTable(RoutesTableFrame frame, JTable table) {
// Install the button handlers
TableColumnModel tcm = table.getColumnModel();
ButtonRenderer buttonRenderer = new ButtonRenderer();
TableCellEditor buttonEditor = new ButtonEditor(new javax.swing.JButton());
tcm.getColumn(EDIT_COLUMN).setCellRenderer(buttonRenderer);
tcm.getColumn(EDIT_COLUMN).setCellEditor(buttonEditor);
// set column preferred widths
table.getColumnModel().getColumn(ID_COLUMN).setPreferredWidth(30);
table.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(220);
table.getColumnModel().getColumn(COMMENT_COLUMN).setPreferredWidth(380);
table.getColumnModel().getColumn(STATUS_COLUMN).setPreferredWidth(70);
table.getColumnModel().getColumn(MIN_LENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(MAX_LENGTH_COLUMN).setPreferredWidth(75);
table.getColumnModel().getColumn(EDIT_COLUMN).setPreferredWidth(80);
frame.loadTableDetails(table);
}
Aggregations