use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class ListedTableFrame method initComponents.
@Override
public void initComponents() {
actionList = new ActionJList(this);
detailpanel = new JPanel();
detailpanel.setLayout(new CardLayout());
tabbedTableArray = new ArrayList<TabbedTableItem>(TabbedTableItemListArrayArray.size());
ArrayList<TabbedTableItemListArray> removeItem = new ArrayList<TabbedTableItemListArray>(5);
for (int x = 0; x < TabbedTableItemListArrayArray.size(); x++) {
/* Here we add all the tables into the panel*/
TabbedTableItemListArray item = TabbedTableItemListArrayArray.get(x);
try {
TabbedTableItem itemModel = new TabbedTableItem(item.getClassAsString(), item.getItemString(), item.getStandardTableModel());
itemBeingAdded = itemModel;
detailpanel.add(itemModel.getPanel(), itemModel.getClassAsString());
tabbedTableArray.add(itemModel);
itemBeingAdded.getAAClass().addToFrame(this);
} catch (Exception ex) {
detailpanel.add(errorPanel(item.getItemString()), item.getClassAsString());
log.error("Error when adding " + item.getClassAsString() + " to display\n" + ex);
ex.printStackTrace();
removeItem.add(item);
}
}
for (TabbedTableItemListArray dead : removeItem) {
TabbedTableItemListArrayArray.remove(dead);
}
list = new JList<String>(new Vector<String>(getChoices()));
listScroller = new JScrollPane(list);
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
list.setLayoutOrientation(JList.VERTICAL);
list.addMouseListener(actionList);
buttonpanel = new JPanel();
buttonpanel.setLayout(new BorderLayout(5, 0));
buttonpanel.setLayout(new BoxLayout(buttonpanel, BoxLayout.Y_AXIS));
buttonpanel.add(listScroller);
buildMenus(tabbedTableArray.get(0));
setTitle(tabbedTableArray.get(0).getItemString());
cardHolder = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buttonpanel, detailpanel);
cardHolder.setDividerSize(8);
if (lastdivider != 0) {
cardHolder.setDividerLocation(lastdivider);
} else {
// if no specific size has been given we set it to the lists preferred width
cardHolder.setDividerLocation(listScroller.getPreferredSize().width);
}
cardHolder.addPropertyChangeListener(new PropertyChangeListener() {
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "We only intend to use/save the last position of the Split frame")
@Override
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals("dividerLocation")) {
lastdivider = (Integer) e.getNewValue();
}
}
});
cardHolder.setOneTouchExpandable(true);
getContentPane().add(cardHolder);
pack();
actionList.selectListItem(0);
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class InstallDecoderURLAction method copyfile.
@SuppressFBWarnings(value = "OBL_UNSATISFIED_OBLIGATION", justification = "Looks like false positive")
boolean copyfile(URL from, File toFile, JPanel who) {
InputStream in = null;
OutputStream out = null;
try {
in = from.openConnection().getInputStream();
// open for overwrite
out = new FileOutputStream(toFile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// done - finally cleans up
} catch (FileNotFoundException ex) {
log.debug("" + ex);
JOptionPane.showMessageDialog(who, Bundle.getMessage("CopyError1"));
return false;
} catch (IOException e) {
log.debug("" + e);
JOptionPane.showMessageDialog(who, Bundle.getMessage("CopyError2"));
return false;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e1) {
log.error("exception closing in stream", e1);
}
try {
if (out != null) {
out.close();
}
} catch (IOException e2) {
log.error("exception closing out stream", e2);
}
}
return true;
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class NXFrame method makeAutoRunPanel.
@SuppressFBWarnings(value = "DB_DUPLICATE_SWITCH_CLAUSES", justification = "Same code for both cases")
private JPanel makeAutoRunPanel(int interpretation) {
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.PAGE_AXIS));
float maxSpeed;
float throttleIncr;
String maxSpeedLabel;
String throttleIncrLabel;
switch(interpretation) {
case SignalSpeedMap.PERCENT_NORMAL:
case SignalSpeedMap.PERCENT_THROTTLE:
maxSpeed = _maxThrottle;
maxSpeedLabel = "MaxSpeed";
throttleIncr = _minSpeed;
throttleIncrLabel = "RampIncrement";
break;
case SignalSpeedMap.SPEED_MPH:
// 2.2369363 is 3.6 converted by mile/km
maxSpeed = _maxThrottle * _throttleFactor * 223.69363f;
maxSpeedLabel = "MaxMph";
throttleIncr = _minSpeed * _throttleFactor * 223.69363f;
throttleIncrLabel = "MinMph";
break;
case SignalSpeedMap.SPEED_KMPH:
maxSpeed = _maxThrottle * _throttleFactor * 360f;
maxSpeedLabel = "MaxKMph";
throttleIncr = _minSpeed * _throttleFactor * 360f;
throttleIncrLabel = "MinKMph";
break;
default:
maxSpeed = _maxThrottle;
maxSpeedLabel = "MaxSpeed";
throttleIncr = _minSpeed;
throttleIncrLabel = "RampIncrement";
}
p1.add(makeTextBoxPanel(false, _maxSpeedBox, maxSpeedLabel, null));
p1.add(makeTextBoxPanel(false, _rampInterval, "rampInterval", null));
p1.add(makeTextBoxPanel(false, _rampIncre, throttleIncrLabel, "ToolTipRampIncrement"));
p1.add(makeTextBoxPanel(false, _throttleFactorBox, "ThrottleScale", "ToolTipThrottleScale"));
p1.add(makeTextBoxPanel(false, _shareRouteBox, "ShareRoute", "ToolTipShareRoute"));
_maxSpeedBox.setText(Float.toString(maxSpeed));
_rampInterval.setText(Float.toString(_intervalTime / 1000));
_rampIncre.setText(Float.toString(throttleIncr));
_throttleFactorBox.setText(Float.toString(_throttleFactor));
JPanel p2 = new JPanel();
p2.setLayout(new BoxLayout(p2, BoxLayout.PAGE_AXIS));
// JPanel trainPanel = makeTrainIdPanel(makeTextBoxPanel(
// false, _shareRouteBox, "ShareRoute", "ToolTipShareRoute"));
JPanel trainPanel = makeTrainIdPanel(null);
p2.add(trainPanel);
JPanel autoRunPanel = new JPanel();
autoRunPanel.setLayout(new BoxLayout(autoRunPanel, BoxLayout.PAGE_AXIS));
JPanel pp = new JPanel();
pp.setLayout(new BoxLayout(pp, BoxLayout.LINE_AXIS));
pp.add(Box.createHorizontalStrut(STRUT_SIZE));
pp.add(p1);
pp.add(Box.createHorizontalStrut(STRUT_SIZE));
pp.add(p2);
pp.add(Box.createHorizontalStrut(STRUT_SIZE));
autoRunPanel.add(pp);
ButtonGroup bg = new ButtonGroup();
bg.add(_forward);
bg.add(_reverse);
p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.LINE_AXIS));
p1.add(Box.createHorizontalGlue());
p1.add(makeTextBoxPanel(false, _forward, "forward", null));
p1.add(makeTextBoxPanel(false, _reverse, "reverse", null));
p1.add(Box.createHorizontalGlue());
pp = new JPanel();
pp.setLayout(new BoxLayout(pp, BoxLayout.LINE_AXIS));
pp.add(Box.createHorizontalStrut(STRUT_SIZE));
pp.add(p1);
pp.add(Box.createHorizontalStrut(STRUT_SIZE));
pp.add(Box.createHorizontalStrut(2 * STRUT_SIZE));
autoRunPanel.add(pp);
JPanel ppp = new JPanel();
ppp.setLayout(new BoxLayout(ppp, BoxLayout.LINE_AXIS));
ppp.add(Box.createHorizontalStrut(STRUT_SIZE));
ppp.add(makeTextBoxPanel(false, _stageEStop, "StageEStop", null));
ppp.add(Box.createHorizontalStrut(STRUT_SIZE));
ppp.add(makeTextBoxPanel(false, _haltStartBox, "HaltAtStart", null));
ppp.add(Box.createHorizontalStrut(STRUT_SIZE));
ppp.add(makeTextBoxPanel(false, _calibrateBox, "Calibrate", "calibBlockMessage"));
ppp.add(Box.createHorizontalStrut(STRUT_SIZE));
autoRunPanel.add(ppp);
return autoRunPanel;
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class LocationCopyFrame method buttonActionPerformed.
@Override
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "GUI ease of use")
protected void buttonActionPerformed(java.awt.event.ActionEvent ae) {
if (ae.getSource() == copyButton) {
log.debug("copy location button activated");
if (!checkName()) {
return;
}
if (locationBox.getSelectedItem() == null) {
JOptionPane.showMessageDialog(this, Bundle.getMessage("SelectLocationToCopy"), MessageFormat.format(Bundle.getMessage("CanNotLocation"), new Object[] { Bundle.getMessage("ButtonCopy") }), JOptionPane.ERROR_MESSAGE);
return;
}
Location location = (Location) locationBox.getSelectedItem();
// check to see if there are cars scheduled for pickup or set out
if (moveRollingStockCheckBox.isSelected()) {
for (Track track : location.getTrackList()) {
if (track.getPickupRS() > 0) {
JOptionPane.showMessageDialog(this, MessageFormat.format(Bundle.getMessage("FoundRollingStockPickUp"), new Object[] { track.getPickupRS() }), MessageFormat.format(Bundle.getMessage("TrainsServicingTrack"), new Object[] { track.getName() }), JOptionPane.WARNING_MESSAGE);
// can't move rolling stock, some are scheduled for a pick up
return;
}
if (track.getDropRS() > 0) {
JOptionPane.showMessageDialog(this, MessageFormat.format(Bundle.getMessage("FoundRollingStockDrop"), new Object[] { track.getDropRS() }), MessageFormat.format(Bundle.getMessage("TrainsServicingTrack"), new Object[] { track.getName() }), JOptionPane.WARNING_MESSAGE);
// can't move rolling stock, some are scheduled for drops
return;
}
}
}
// now copy all of the tracks
Location newLocation = locationManager.newLocation(loctionNameTextField.getText());
location.copyLocation(newLocation);
// does the user want the cars to also move to the new tracks?
if (moveRollingStockCheckBox.isSelected()) {
for (Track track : location.getTrackList()) {
moveRollingStock(track, newLocation.getTrackByName(track.getName(), null));
if (deleteTrackCheckBox.isSelected()) {
location.deleteTrack(track);
}
}
}
}
if (ae.getSource() == saveButton) {
log.debug("save track button activated");
// save checkbox states
moveRollingStock = moveRollingStockCheckBox.isSelected();
deleteTrack = deleteTrackCheckBox.isSelected();
// save location file
OperationsXml.save();
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class CarsTableModel method toggleSelectVisible.
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", // NOI18N
justification = "GUI ease of use")
public void toggleSelectVisible() {
XTableColumnModel tcm = (XTableColumnModel) _table.getColumnModel();
isSelectVisible = !tcm.isColumnVisible(tcm.getColumnByModelIndex(SELECT_COLUMN));
tcm.setColumnVisible(tcm.getColumnByModelIndex(SELECT_COLUMN), isSelectVisible);
}
Aggregations