use of javax.swing.BoxLayout in project JMRI by JMRI.
the class AlignmentPanelTest method testShow.
@Test
public void testShow() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
jmri.util.JmriJFrame f = new jmri.util.JmriJFrame("RPS Alignment");
f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
AlignmentPanel panel = new AlignmentPanel();
panel.initComponents();
f.getContentPane().add(panel);
f.pack();
f.setVisible(true);
JFrame f2 = JFrameOperator.waitJFrame("RPS Alignment", true, true);
Assert.assertNotNull("found frame", f2);
f2.dispose();
}
use of javax.swing.BoxLayout in project jabref by JabRef.
the class DroppedFileHandler method tryXmpImport.
// Done by MrDlib
private boolean tryXmpImport(String fileName, ExternalFileType fileType, NamedCompound edits) {
if (!"pdf".equals(fileType.getExtension())) {
return false;
}
List<BibEntry> xmpEntriesInFile;
try {
xmpEntriesInFile = XMPUtil.readXMP(fileName, Globals.prefs.getXMPPreferences());
} catch (IOException e) {
LOGGER.warn("Problem reading XMP", e);
return false;
}
if ((xmpEntriesInFile == null) || xmpEntriesInFile.isEmpty()) {
return false;
}
JLabel confirmationMessage = new JLabel(Localization.lang("The PDF contains one or several BibTeX-records.") + "\n" + Localization.lang("Do you want to import these as new entries into the current library?"));
JPanel entriesPanel = new JPanel();
entriesPanel.setLayout(new BoxLayout(entriesPanel, BoxLayout.Y_AXIS));
xmpEntriesInFile.forEach(entry -> {
JTextArea entryArea = new JTextArea(entry.toString());
entryArea.setEditable(false);
entriesPanel.add(entryArea);
});
JPanel contentPanel = new JPanel(new BorderLayout());
contentPanel.add(confirmationMessage, BorderLayout.NORTH);
contentPanel.add(entriesPanel, BorderLayout.CENTER);
int reply = JOptionPane.showConfirmDialog(frame, contentPanel, Localization.lang("XMP-metadata found in PDF: %0", fileName), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (reply == JOptionPane.CANCEL_OPTION) {
// The user canceled thus that we are done.
return true;
}
if (reply == JOptionPane.NO_OPTION) {
return false;
}
// reply == JOptionPane.YES_OPTION)
/*
* TODO Extract Import functionality from ImportMenuItem then we could
* do:
*
* ImportMenuItem importer = new ImportMenuItem(frame, (mainTable ==
* null), new PdfXmpImporter());
*
* importer.automatedImport(new String[] { fileName });
*/
boolean isSingle = xmpEntriesInFile.size() == 1;
BibEntry single = isSingle ? xmpEntriesInFile.get(0) : null;
boolean success = true;
String destFilename;
if (linkInPlace.isSelected()) {
destFilename = FileUtil.shortenFileName(Paths.get(fileName), panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences())).toString();
} else {
if (renameCheckBox.isSelected() || (single == null)) {
destFilename = fileName;
} else {
destFilename = single.getCiteKey() + "." + fileType.getExtension();
}
if (copyRadioButton.isSelected()) {
success = doCopy(fileName, destFilename, edits);
} else if (moveRadioButton.isSelected()) {
success = doMove(fileName, destFilename, edits);
}
}
if (success) {
for (BibEntry aXmpEntriesInFile : xmpEntriesInFile) {
aXmpEntriesInFile.setId(IdGenerator.next());
edits.addEdit(new UndoableInsertEntry(panel.getDatabase(), aXmpEntriesInFile, panel));
panel.getDatabase().insertEntry(aXmpEntriesInFile);
doLink(aXmpEntriesInFile, fileType, destFilename, true, edits);
}
panel.markBaseChanged();
panel.updateEntryEditorIfShowing();
}
return true;
}
use of javax.swing.BoxLayout in project jabref by JabRef.
the class PreviewPrefsTab method setupGui.
private void setupGui() {
JPanel chooseStyle = FormBuilder.create().columns("0:grow, $lcgap, pref, $lcgap, 0:grow").rows("pref, $lg, fill:pref:grow, $lg, pref:grow, $lg, pref:grow, $lg, pref:grow").padding(Paddings.DIALOG).addSeparator(Localization.lang("Current Preview")).xyw(1, 1, 5).add(available).xywh(1, 3, 1, 7).add(chosen).xywh(5, 3, 1, 7).add(btnRight).xy(3, 3, "fill, bottom").add(btnLeft).xy(3, 5, "fill, top").add(btnUp).xy(3, 7, "fill, bottom").add(btnDown).xy(3, 9, "fill, top").build();
JPanel preview = FormBuilder.create().columns("pref:grow, $lcgap, pref, $lcgap, pref").rows("pref, $lg, fill:pref:grow").padding(Paddings.DIALOG).addSeparator(Localization.lang("Preview")).xy(1, 1).add(btnTest).xy(3, 1).add(btnDefault).xy(5, 1).add(scrollPane).xyw(1, 3, 5).build();
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(chooseStyle, BorderLayout.CENTER);
add(preview, BorderLayout.PAGE_END);
}
use of javax.swing.BoxLayout in project JMRI by JMRI.
the class LogixTableAction method makeEditLogixWindow.
/**
* Create and/or initialize the Edit Logix pane.
*/
void makeEditLogixWindow() {
// Setup the name box components.
setNameBoxListeners();
//if (log.isDebugEnabled()) log.debug("makeEditLogixWindow ");
editUserName.setText(_curLogix.getUserName());
// clear conditional table if needed
if (conditionalTableModel != null) {
conditionalTableModel.fireTableStructureChanged();
}
inEditMode = true;
if (editLogixFrame == null) {
editLogixFrame = new JmriJFrame(rbx.getString("TitleEditLogix"), false, false);
editLogixFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
editLogixFrame.setLocation(100, 30);
Container contentPane = editLogixFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel systemNameLabel = new JLabel(Bundle.getMessage("ColumnSystemName") + ":");
panel1.add(systemNameLabel);
JLabel fixedSystemName = new JLabel(_curLogix.getSystemName());
panel1.add(fixedSystemName);
contentPane.add(panel1);
JPanel panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
JLabel userNameLabel = new JLabel(Bundle.getMessage("ColumnUserName") + ":");
panel2.add(userNameLabel);
panel2.add(editUserName);
editUserName.setToolTipText(rbx.getString("LogixUserNameHint2"));
contentPane.add(panel2);
// add table of Conditionals
JPanel pctSpace = new JPanel();
pctSpace.setLayout(new FlowLayout());
pctSpace.add(new JLabel(" "));
contentPane.add(pctSpace);
JPanel pTitle = new JPanel();
pTitle.setLayout(new FlowLayout());
pTitle.add(new JLabel(rbx.getString("ConditionalTableTitle")));
contentPane.add(pTitle);
// initialize table of conditionals
conditionalTableModel = new ConditionalTableModel();
JTable conditionalTable = new JTable(conditionalTableModel);
conditionalTable.setRowSelectionAllowed(false);
TableColumnModel conditionalColumnModel = conditionalTable.getColumnModel();
TableColumn sNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.SNAME_COLUMN);
sNameColumn.setResizable(true);
sNameColumn.setMinWidth(100);
sNameColumn.setPreferredWidth(130);
TableColumn uNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.UNAME_COLUMN);
uNameColumn.setResizable(true);
uNameColumn.setMinWidth(210);
uNameColumn.setPreferredWidth(260);
TableColumn stateColumn = conditionalColumnModel.getColumn(ConditionalTableModel.STATE_COLUMN);
stateColumn.setResizable(true);
stateColumn.setMinWidth(50);
stateColumn.setMaxWidth(100);
TableColumn buttonColumn = conditionalColumnModel.getColumn(ConditionalTableModel.BUTTON_COLUMN);
// install button renderer and editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
conditionalTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
conditionalTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton("XXXXXX");
conditionalTable.setRowHeight(testButton.getPreferredSize().height);
buttonColumn.setMinWidth(testButton.getPreferredSize().width);
buttonColumn.setMaxWidth(testButton.getPreferredSize().width);
buttonColumn.setResizable(false);
JScrollPane conditionalTableScrollPane = new JScrollPane(conditionalTable);
Dimension dim = conditionalTable.getPreferredSize();
dim.height = 450;
conditionalTableScrollPane.getViewport().setPreferredSize(dim);
contentPane.add(conditionalTableScrollPane);
// add message area between table and buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new BoxLayout(panel4, BoxLayout.Y_AXIS));
JPanel panel41 = new JPanel();
panel41.setLayout(new FlowLayout());
panel41.add(status);
panel4.add(panel41);
JPanel panel42 = new JPanel();
panel42.setLayout(new FlowLayout());
// Conditional panel buttons - New Conditional
JButton newConditionalButton = new JButton(rbx.getString("NewConditionalButton"));
panel42.add(newConditionalButton);
newConditionalButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newConditionalPressed(e);
}
});
newConditionalButton.setToolTipText(rbx.getString("NewConditionalButtonHint"));
// Conditional panel buttons - Reorder
JButton reorderButton = new JButton(rbx.getString("ReorderButton"));
panel42.add(reorderButton);
reorderButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reorderPressed(e);
}
});
reorderButton.setToolTipText(rbx.getString("ReorderButtonHint"));
// Conditional panel buttons - Calculate
JButton calculateButton = new JButton(rbx.getString("CalculateButton"));
panel42.add(calculateButton);
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculatePressed(e);
}
});
calculateButton.setToolTipText(rbx.getString("CalculateButtonHint"));
panel4.add(panel42);
Border panel4Border = BorderFactory.createEtchedBorder();
panel4.setBorder(panel4Border);
contentPane.add(panel4);
// add buttons at bottom of window
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
// Bottom Buttons - Done Logix
JButton done = new JButton(Bundle.getMessage("ButtonDone"));
panel5.add(done);
done.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
donePressed(e);
}
});
done.setToolTipText(rbx.getString("DoneButtonHint"));
// Delete Logix
JButton delete = new JButton(Bundle.getMessage("ButtonDelete"));
panel5.add(delete);
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deletePressed(e);
}
});
delete.setToolTipText(rbx.getString("DeleteLogixButtonHint"));
contentPane.add(panel5);
}
editLogixFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
if (inEditMode) {
donePressed(null);
} else {
finishDone();
}
}
});
editLogixFrame.pack();
editLogixFrame.setVisible(true);
}
use of javax.swing.BoxLayout in project JMRI by JMRI.
the class LogixTableAction method deletePressed.
/**
* Respond to the Delete combo selection Logix window.
*
* @param sName system name of bean to be deleted
*/
void deletePressed(String sName) {
if (!checkFlags(sName)) {
return;
}
if (!checkConditionalReferences(sName)) {
return;
}
final Logix x = _logixManager.getBySystemName(sName);
final jmri.UserPreferencesManager p;
p = jmri.InstanceManager.getNullableDefault(jmri.UserPreferencesManager.class);
if (p != null && p.getMultipleChoiceOption(getClassName(), "delete") == 0x02) {
if (x != null) {
_logixManager.deleteLogix(x);
deleteSourceWhereUsed();
}
} else {
final JDialog dialog = new JDialog();
String msg;
dialog.setTitle(rbx.getString("ConfirmTitle"));
dialog.setLocationRelativeTo(null);
dialog.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
JPanel container = new JPanel();
container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
msg = java.text.MessageFormat.format(rbx.getString("ConfirmLogixDelete"), sName);
JLabel question = new JLabel(msg);
question.setAlignmentX(Component.CENTER_ALIGNMENT);
container.add(question);
final JCheckBox remember = new JCheckBox(Bundle.getMessage("MessageRememberSetting"));
remember.setFont(remember.getFont().deriveFont(10f));
remember.setAlignmentX(Component.CENTER_ALIGNMENT);
JButton yesButton = new JButton(Bundle.getMessage("ButtonYes"));
JButton noButton = new JButton(Bundle.getMessage("ButtonNo"));
JPanel button = new JPanel();
button.setAlignmentX(Component.CENTER_ALIGNMENT);
button.add(yesButton);
button.add(noButton);
container.add(button);
noButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//there is no point in remebering this the user will never be
//able to delete a bean!
/*if(remember.isSelected()){
setDisplayDeleteMsg(0x01);
}*/
dialog.dispose();
}
});
yesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (p != null && remember.isSelected()) {
p.setMultipleChoiceOption(getClassName(), "delete", 0x02);
}
if (x != null) {
_logixManager.deleteLogix(x);
deleteSourceWhereUsed();
}
dialog.dispose();
}
});
container.add(remember);
container.setAlignmentX(Component.CENTER_ALIGNMENT);
container.setAlignmentY(Component.CENTER_ALIGNMENT);
dialog.getContentPane().add(container);
dialog.pack();
dialog.setModal(true);
dialog.setVisible(true);
}
/*if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(f, java.text.MessageFormat.format(
rbx.getString("ConfirmLogixDelete"), sName),
rbx.getString("ConfirmTitle"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE) )
{
Logix x = _logixManager.getBySystemName(sName);
if (x != null) {
_logixManager.deleteLogix(x);
}
}*/
f.setVisible(true);
}
Aggregations