use of javax.swing.JSeparator in project jabref by JabRef.
the class MergeEntries method initialize.
/**
* Main function for building the merge entry JPanel
*/
private void initialize() {
doneBuilding = false;
setupFields();
fillDiffModes();
// Create main layout
String colSpecMain = "left:pref, 5px, center:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, center:3cm:grow";
String colSpecMerge = "left:pref, 5px, fill:3cm:grow, 5px, center:pref, 3px, center:pref, 3px, center:pref, 5px, fill:3cm:grow";
String rowSpec = "pref, pref, 10px, fill:5cm:grow, 10px, pref, 10px, fill:3cm:grow";
StringBuilder rowBuilder = new StringBuilder("");
for (int i = 0; i < allFields.size(); i++) {
rowBuilder.append("pref, 2dlu, ");
}
rowBuilder.append("pref");
JPanel mergePanel = new JPanel();
FormLayout mainLayout = new FormLayout(colSpecMain, rowSpec);
FormLayout mergeLayout = new FormLayout(colSpecMerge, rowBuilder.toString());
mainPanel.setLayout(mainLayout);
mergePanel.setLayout(mergeLayout);
setupHeadingRows();
mainPanel.add(new JSeparator(), CELL_CONSTRAINTS.xyw(1, 3, 11));
setupEntryTypeRow(mergePanel);
int maxLabelWidth = setupFieldRows(mergePanel);
// Create and add scrollpane
scrollPane = new JScrollPane(mergePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder());
updateTextPanes(allFields);
mainPanel.add(scrollPane, CELL_CONSTRAINTS.xyw(1, 4, 11));
mainPanel.add(new JSeparator(), CELL_CONSTRAINTS.xyw(1, 5, 11));
synchronizeColumnWidths(mainLayout, mergeLayout, maxLabelWidth);
// Setup a PreviewPanel and a Bibtex source box for the merged entry
mainPanel.add(boldFontLabel(Localization.lang("Merged entry")), CELL_CONSTRAINTS.xyw(1, 6, 6));
entryPreview = new PreviewPanel(null, mergedEntry, null);
mainPanel.add(entryPreview, CELL_CONSTRAINTS.xyw(1, 8, 6));
mainPanel.add(boldFontLabel(Localization.lang("Merged BibTeX source code")), CELL_CONSTRAINTS.xyw(8, 6, 4));
sourceView = new JTextArea();
sourceView.setLineWrap(true);
sourceView.setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
mainPanel.add(new JScrollPane(sourceView), CELL_CONSTRAINTS.xyw(8, 8, 4));
sourceView.setEditable(false);
// Add some margin around the layout
mainLayout.appendRow(RowSpec.decode(MARGIN));
mainLayout.appendColumn(ColumnSpec.decode(MARGIN));
mainLayout.insertRow(1, RowSpec.decode(MARGIN));
mainLayout.insertColumn(1, ColumnSpec.decode(MARGIN));
// Everything done, allow any action to actually update the merged entry
doneBuilding = true;
updateAll();
// Show what we've got
mainPanel.setVisible(true);
SwingUtilities.invokeLater(() -> scrollPane.getVerticalScrollBar().setValue(0));
}
use of javax.swing.JSeparator in project jabref by JabRef.
the class MergeEntriesDialog method init.
/**
* Sets up the dialog
*
* @param selected Selected BibtexEntries
*/
private void init(List<BibEntry> selected) {
// Check if there are two entries selected
if (selected.size() != 2) {
// None selected. Inform the user to select entries first.
JOptionPane.showMessageDialog(panel.frame(), Localization.lang("You have to choose exactly two entries to merge."), MERGE_ENTRIES, JOptionPane.INFORMATION_MESSAGE);
this.dispose();
return;
}
// Store the two entries
BibEntry one = selected.get(0);
BibEntry two = selected.get(1);
MergeEntries mergeEntries = new MergeEntries(one, two, panel.getBibDatabaseContext().getMode());
// Create undo-compound
NamedCompound ce = new NamedCompound(MERGE_ENTRIES);
FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
this.setLayout(layout);
this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
this.add(new JSeparator(), cc.xy(1, 3));
// Create buttons
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
JButton cancel = new JButton(Localization.lang("Cancel"));
cancel.setActionCommand("cancel");
cancel.addActionListener(e -> {
panel.output(Localization.lang("Canceled merging entries"));
dispose();
});
JButton replaceentries = new JButton(MERGE_ENTRIES);
replaceentries.setActionCommand("replace");
replaceentries.addActionListener(e -> {
BibEntry mergedEntry = mergeEntries.getMergeEntry();
panel.insertEntry(mergedEntry);
ce.addEdit(new UndoableInsertEntry(panel.getDatabase(), mergedEntry, panel));
ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), one, panel));
panel.getDatabase().removeEntry(one);
ce.addEdit(new UndoableRemoveEntry(panel.getDatabase(), two, panel));
panel.getDatabase().removeEntry(two);
ce.end();
panel.getUndoManager().addEdit(ce);
panel.output(Localization.lang("Merged entries"));
dispose();
});
bb.addButton(new JButton[] { replaceentries, cancel });
this.add(bb.getPanel(), cc.xy(1, 5));
// Add some margin around the layout
layout.appendRow(RowSpec.decode(MARGIN));
layout.appendColumn(ColumnSpec.decode(MARGIN));
layout.insertRow(1, RowSpec.decode(MARGIN));
layout.insertColumn(1, ColumnSpec.decode(MARGIN));
WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
pw.displayWindowAtStoredLocation();
// Show what we've got
setVisible(true);
}
use of javax.swing.JSeparator in project jabref by JabRef.
the class MergeFetchedEntryDialog method init.
/**
* Sets up the dialog
*/
private void init() {
mergeEntries = new MergeEntries(this.originalEntry, this.fetchedEntry, Localization.lang("Original entry"), Localization.lang("Entry from %0", type), panel.getBibDatabaseContext().getMode());
// Create undo-compound
ce = new NamedCompound(Localization.lang("Merge entry with %0 information", type));
FormLayout layout = new FormLayout("fill:700px:grow", "fill:400px:grow, 4px, p, 5px, p");
this.setLayout(layout);
this.add(mergeEntries.getMergeEntryPanel(), cc.xy(1, 1));
this.add(new JSeparator(), cc.xy(1, 3));
// Create buttons
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
JButton cancel = new JButton(new CancelAction());
JButton replaceEntry = new JButton(new ReplaceAction());
bb.addButton(replaceEntry, cancel);
this.add(bb.getPanel(), cc.xy(1, 5));
// Add some margin around the layout
layout.appendRow(RowSpec.decode(MARGIN));
layout.appendColumn(ColumnSpec.decode(MARGIN));
layout.insertRow(1, RowSpec.decode(MARGIN));
layout.insertColumn(1, ColumnSpec.decode(MARGIN));
WindowLocation pw = new WindowLocation(this, JabRefPreferences.MERGEENTRIES_POS_X, JabRefPreferences.MERGEENTRIES_POS_Y, JabRefPreferences.MERGEENTRIES_SIZE_X, JabRefPreferences.MERGEENTRIES_SIZE_Y);
pw.displayWindowAtStoredLocation();
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class DispatcherFrame method openDispatcherWindow.
void openDispatcherWindow() {
if (dispatcherFrame == null) {
dispatcherFrame = this;
dispatcherFrame.setTitle(Bundle.getMessage("TitleDispatcher"));
JMenuBar menuBar = new JMenuBar();
optionsMenu = new OptionsMenu(this);
menuBar.add(optionsMenu);
setJMenuBar(menuBar);
dispatcherFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Dispatcher", true);
contentPane = dispatcherFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// set up active trains table
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(new JLabel(Bundle.getMessage("ActiveTrainTableTitle")));
contentPane.add(p11);
JPanel p12 = new JPanel();
p12.setLayout(new FlowLayout());
activeTrainsTableModel = new ActiveTrainsTableModel();
JTable activeTrainsTable = new JTable(activeTrainsTableModel);
activeTrainsTable.setRowSelectionAllowed(false);
activeTrainsTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 160));
TableColumnModel activeTrainsColumnModel = activeTrainsTable.getColumnModel();
TableColumn transitColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRANSIT_COLUMN);
transitColumn.setResizable(true);
transitColumn.setMinWidth(140);
transitColumn.setMaxWidth(220);
TableColumn trainColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRAIN_COLUMN);
trainColumn.setResizable(true);
trainColumn.setMinWidth(90);
trainColumn.setMaxWidth(160);
TableColumn typeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TYPE_COLUMN);
typeColumn.setResizable(true);
typeColumn.setMinWidth(130);
typeColumn.setMaxWidth(190);
TableColumn statusColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.STATUS_COLUMN);
statusColumn.setResizable(true);
statusColumn.setMinWidth(90);
statusColumn.setMaxWidth(140);
TableColumn modeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.MODE_COLUMN);
modeColumn.setResizable(true);
modeColumn.setMinWidth(90);
modeColumn.setMaxWidth(140);
TableColumn allocatedColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATED_COLUMN);
allocatedColumn.setResizable(true);
allocatedColumn.setMinWidth(120);
allocatedColumn.setMaxWidth(200);
TableColumn nextSectionColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.NEXTSECTION_COLUMN);
nextSectionColumn.setResizable(true);
nextSectionColumn.setMinWidth(120);
nextSectionColumn.setMaxWidth(200);
TableColumn allocateButtonColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATEBUTTON_COLUMN);
allocateButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
allocateButtonColumn.setMinWidth(110);
allocateButtonColumn.setMaxWidth(190);
allocateButtonColumn.setResizable(false);
ButtonRenderer buttonRenderer = new ButtonRenderer();
activeTrainsTable.setDefaultRenderer(JButton.class, buttonRenderer);
JButton sampleButton = new JButton(Bundle.getMessage("AllocateButtonName"));
activeTrainsTable.setRowHeight(sampleButton.getPreferredSize().height);
allocateButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
JScrollPane activeTrainsTableScrollPane = new JScrollPane(activeTrainsTable);
p12.add(activeTrainsTableScrollPane, BorderLayout.CENTER);
contentPane.add(p12);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(addTrainButton = new JButton(Bundle.getMessage("InitiateTrain") + "..."));
addTrainButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
atFrame.initiateTrain(e);
newTrainActive = true;
} else {
atFrame.showActivateFrame();
}
}
});
addTrainButton.setToolTipText(Bundle.getMessage("InitiateTrainButtonHint"));
p13.add(new JLabel(" "));
p13.add(new JLabel(" "));
p13.add(allocateExtraButton = new JButton(Bundle.getMessage("AllocateExtra") + "..."));
allocateExtraButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
allocateExtraSection(e);
}
});
allocateExtraButton.setToolTipText(Bundle.getMessage("AllocateExtraButtonHint"));
p13.add(new JLabel(" "));
p13.add(cancelRestartButton = new JButton(Bundle.getMessage("CancelRestart") + "..."));
cancelRestartButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
cancelRestart(e);
} else if (restartingTrainsList.size() > 0) {
atFrame.showActivateFrame();
JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message2"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
} else {
atFrame.showActivateFrame();
}
}
});
cancelRestartButton.setToolTipText(Bundle.getMessage("CancelRestartButtonHint"));
p13.add(new JLabel(" "));
p13.add(terminateTrainButton = new JButton(Bundle.getMessage("TerminateTrain") + "..."));
terminateTrainButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
terminateTrain(e);
} else if (activeTrainsList.size() > 0) {
atFrame.showActivateFrame();
JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message1"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
} else {
atFrame.showActivateFrame();
}
}
});
terminateTrainButton.setToolTipText(Bundle.getMessage("TerminateTrainButtonHint"));
contentPane.add(p13);
// set up pending allocations table
contentPane.add(new JSeparator());
JPanel p21 = new JPanel();
p21.setLayout(new FlowLayout());
p21.add(new JLabel(Bundle.getMessage("RequestedAllocationsTableTitle")));
contentPane.add(p21);
JPanel p22 = new JPanel();
p22.setLayout(new FlowLayout());
allocationRequestTableModel = new AllocationRequestTableModel();
JTable allocationRequestTable = new JTable(allocationRequestTableModel);
allocationRequestTable.setRowSelectionAllowed(false);
allocationRequestTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 100));
TableColumnModel allocationRequestColumnModel = allocationRequestTable.getColumnModel();
TableColumn activeColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ACTIVE_COLUMN);
activeColumn.setResizable(true);
activeColumn.setMinWidth(210);
activeColumn.setMaxWidth(260);
TableColumn priorityColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.PRIORITY_COLUMN);
priorityColumn.setResizable(true);
priorityColumn.setMinWidth(40);
priorityColumn.setMaxWidth(60);
TableColumn trainTypColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.TRAINTYPE_COLUMN);
trainTypColumn.setResizable(true);
trainTypColumn.setMinWidth(130);
trainTypColumn.setMaxWidth(190);
TableColumn sectionColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTION_COLUMN);
sectionColumn.setResizable(true);
sectionColumn.setMinWidth(140);
sectionColumn.setMaxWidth(210);
TableColumn secStatusColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.STATUS_COLUMN);
secStatusColumn.setResizable(true);
secStatusColumn.setMinWidth(90);
secStatusColumn.setMaxWidth(150);
TableColumn occupancyColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.OCCUPANCY_COLUMN);
occupancyColumn.setResizable(true);
occupancyColumn.setMinWidth(80);
occupancyColumn.setMaxWidth(130);
TableColumn secLengthColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTIONLENGTH_COLUMN);
secLengthColumn.setResizable(true);
secLengthColumn.setMinWidth(40);
secLengthColumn.setMaxWidth(60);
TableColumn allocateColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ALLOCATEBUTTON_COLUMN);
allocateColumn.setCellEditor(new ButtonEditor(new JButton()));
allocateColumn.setMinWidth(90);
allocateColumn.setMaxWidth(170);
allocateColumn.setResizable(false);
allocationRequestTable.setDefaultRenderer(JButton.class, buttonRenderer);
sampleButton = new JButton(Bundle.getMessage("AllocateButton"));
allocationRequestTable.setRowHeight(sampleButton.getPreferredSize().height);
allocateColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
TableColumn cancelButtonColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.CANCELBUTTON_COLUMN);
cancelButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
cancelButtonColumn.setMinWidth(75);
cancelButtonColumn.setMaxWidth(170);
cancelButtonColumn.setResizable(false);
cancelButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
JScrollPane allocationRequestTableScrollPane = new JScrollPane(allocationRequestTable);
p22.add(allocationRequestTableScrollPane, BorderLayout.CENTER);
contentPane.add(p22);
// set up allocated sections table
contentPane.add(new JSeparator());
JPanel p30 = new JPanel();
p30.setLayout(new FlowLayout());
p30.add(new JLabel(Bundle.getMessage("AllocatedSectionsTitle") + " "));
autoReleaseBox = new JCheckBox(Bundle.getMessage("AutoReleaseBoxLabel"));
p30.add(autoReleaseBox);
autoReleaseBox.setToolTipText(Bundle.getMessage("AutoReleaseBoxHint"));
autoReleaseBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoReleaseChanged(e);
}
});
// initiallize autoRelease to match autoAllocate
autoReleaseBox.setSelected(_AutoAllocate);
autoAllocateBox = new JCheckBox(Bundle.getMessage("AutoDispatchItem"));
p30.add(autoAllocateBox);
autoAllocateBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
autoAllocateBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoAllocateChanged(e);
}
});
contentPane.add(p30);
autoAllocateBox.setSelected(_AutoAllocate);
JPanel p31 = new JPanel();
p31.setLayout(new FlowLayout());
allocatedSectionTableModel = new AllocatedSectionTableModel();
JTable allocatedSectionTable = new JTable(allocatedSectionTableModel);
allocatedSectionTable.setRowSelectionAllowed(false);
allocatedSectionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(730, 200));
TableColumnModel allocatedSectionColumnModel = allocatedSectionTable.getColumnModel();
TableColumn activeAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.ACTIVE_COLUMN);
activeAColumn.setResizable(true);
activeAColumn.setMinWidth(250);
activeAColumn.setMaxWidth(350);
TableColumn sectionAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.SECTION_COLUMN);
sectionAColumn.setResizable(true);
sectionAColumn.setMinWidth(200);
sectionAColumn.setMaxWidth(350);
TableColumn occupancyAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.OCCUPANCY_COLUMN);
occupancyAColumn.setResizable(true);
occupancyAColumn.setMinWidth(80);
occupancyAColumn.setMaxWidth(140);
TableColumn useStatusColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.USESTATUS_COLUMN);
useStatusColumn.setResizable(true);
useStatusColumn.setMinWidth(90);
useStatusColumn.setMaxWidth(150);
TableColumn releaseColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.RELEASEBUTTON_COLUMN);
releaseColumn.setCellEditor(new ButtonEditor(new JButton()));
releaseColumn.setMinWidth(90);
releaseColumn.setMaxWidth(170);
releaseColumn.setResizable(false);
allocatedSectionTable.setDefaultRenderer(JButton.class, buttonRenderer);
JButton sampleAButton = new JButton(Bundle.getMessage("ReleaseButton"));
allocatedSectionTable.setRowHeight(sampleAButton.getPreferredSize().height);
releaseColumn.setPreferredWidth((sampleAButton.getPreferredSize().width) + 2);
JScrollPane allocatedSectionTableScrollPane = new JScrollPane(allocatedSectionTable);
p31.add(allocatedSectionTableScrollPane, BorderLayout.CENTER);
contentPane.add(p31);
}
dispatcherFrame.pack();
dispatcherFrame.setVisible(true);
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class SerialPacketGenFrame method initComponents.
@Override
public void initComponents() throws Exception {
// the following code sets the frame's initial state
jLabel1.setText("Command:");
jLabel1.setVisible(true);
sendButton.setText("Send");
sendButton.setVisible(true);
sendButton.setToolTipText("Send packet");
packetTextField.setText("");
packetTextField.setToolTipText("Enter command as hexadecimal bytes separated by a space");
packetTextField.setMaximumSize(new Dimension(packetTextField.getMaximumSize().width, packetTextField.getPreferredSize().height));
setTitle("Send Grapevine serial command");
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(jLabel1);
getContentPane().add(packetTextField);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p1.add(parityButton);
p1.add(sendButton);
getContentPane().add(p1);
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
sendButtonActionPerformed(e);
}
});
parityButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
parityButtonActionPerformed(e);
}
});
getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));
// add poll message buttons
JPanel pane3 = new JPanel();
pane3.setLayout(new FlowLayout());
pane3.add(new JLabel("Address:"));
pane3.add(uaAddrField);
pane3.add(pollButton);
uaAddrField.setText("0");
uaAddrField.setToolTipText("Enter node address (decimal integer)");
getContentPane().add(pane3);
pollButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pollButtonActionPerformed(e);
}
});
pollButton.setToolTipText("Send poll request");
// add help menu to window
addHelpMenu("package.jmri.jmrix.grapevine.packetgen.SerialPacketGenFrame", true);
// pack for display
pack();
}
Aggregations