Search in sources :

Example 31 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class TrainIcon method makeTrainRouteMenu.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private JMenu makeTrainRouteMenu() {
    JMenu routeMenu = new JMenu(Bundle.getMessage("Route"));
    Route route = _train.getRoute();
    if (route == null) {
        return routeMenu;
    }
    List<RollingStock> carList = CarManager.instance().getByTrainList(_train);
    for (RouteLocation rl : route.getLocationsBySequenceList()) {
        int pickupCars = 0;
        int dropCars = 0;
        String current = "     ";
        if (_train.getCurrentLocation() == rl) {
            // NOI18N
            current = "-> ";
        }
        for (RollingStock rs : carList) {
            Car car = (Car) rs;
            if (car.getRouteLocation() == rl && !car.getTrackName().equals(Car.NONE)) {
                pickupCars++;
            }
            if (car.getRouteDestination() == rl) {
                dropCars++;
            }
        }
        String rText = "";
        String pickups = "";
        String drops = "";
        if (pickupCars > 0) {
            pickups = " " + Bundle.getMessage("Pickup") + " " + pickupCars;
            if (dropCars > 0) {
                drops = ", " + Bundle.getMessage("SetOut") + " " + dropCars;
            }
        } else if (dropCars > 0) {
            drops = " " + Bundle.getMessage("SetOut") + " " + dropCars;
        }
        if (pickupCars > 0 || dropCars > 0) {
            rText = current + rl.getName() + "  (" + pickups + drops + " )";
        } else {
            rText = current + rl.getName();
        }
        routeMenu.add(new RouteAction(rText, rl));
    }
    return routeMenu;
}
Also used : Car(jmri.jmrit.operations.rollingstock.cars.Car) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) JMenu(javax.swing.JMenu) Route(jmri.jmrit.operations.routes.Route) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) Point(java.awt.Point) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 32 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class TrainByCarTypeFrame method adjustCarsComboBoxSize.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private void adjustCarsComboBoxSize() {
    List<RollingStock> cars = CarManager.instance().getList();
    for (RollingStock rs : cars) {
        Car car = (Car) rs;
        carsComboBox.addItem(car);
    }
    Dimension boxsize = carsComboBox.getMinimumSize();
    if (boxsize != null) {
        boxsize.setSize(boxsize.width + 10, boxsize.height);
        carsComboBox.setMinimumSize(boxsize);
    }
    carsComboBox.removeAllItems();
}
Also used : Car(jmri.jmrit.operations.rollingstock.cars.Car) Dimension(java.awt.Dimension) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 33 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class TrainByCarTypeFrame method updateCarsComboBox.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private void updateCarsComboBox() {
    log.debug("update car combobox");
    carsComboBox.removeAllItems();
    String carType = (String) typeComboBox.getSelectedItem();
    // load car combobox
    carsComboBox.addItem(null);
    List<RollingStock> cars = CarManager.instance().getByTypeList(carType);
    for (RollingStock rs : cars) {
        Car car = (Car) rs;
        carsComboBox.addItem(car);
    }
}
Also used : Car(jmri.jmrit.operations.rollingstock.cars.Car) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 34 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class SimDriverAdapter method configure.

/**
     * set up all of the other objects to operate connected to this port
     */
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Access to 'self' OK until multiple instance pattern installed")
@Override
public void configure() {
    // install a traffic controller that doesn't time out
    SerialTrafficController tc = new SerialTrafficController() {

        // timeout doesn't do anything
        @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only until multi-connect update done")
        @Override
        protected void handleTimeout(jmri.jmrix.AbstractMRMessage m, jmri.jmrix.AbstractMRListener l) {
        }
    };
    // connect to the traffic controller
    tc.connectPort(this);
    ((CMRISystemConnectionMemo) getSystemConnectionMemo()).setTrafficController(tc);
    ((CMRISystemConnectionMemo) getSystemConnectionMemo()).configureManagers();
}
Also used : SerialTrafficController(jmri.jmrix.cmri.serial.SerialTrafficController) CMRISystemConnectionMemo(jmri.jmrix.cmri.CMRISystemConnectionMemo) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 35 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class StackMonFrame method requestFunctionStatus.

/*
     * Request the momentary/continuous status of functions for the 
     * current address.
     */
@SuppressWarnings("unused")
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "This is part of work in progress code to allow display of all information about the locomotives in the stack.")
private void requestFunctionStatus() {
    int address = 0;
    if (!adrTextField.getText().equals("")) {
        address = Integer.parseInt(adrTextField.getText());
        XNetMessage msg = XNetMessage.getLocomotiveFunctionStatusMsg(address);
        tc.sendXNetMessage(msg, this);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)142 IOException (java.io.IOException)23 File (java.io.File)22 ArrayList (java.util.ArrayList)20 JPanel (javax.swing.JPanel)14 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)13 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)13 FlowLayout (java.awt.FlowLayout)8 BoxLayout (javax.swing.BoxLayout)7 Location (jmri.jmrit.operations.locations.Location)7 Dimension (java.awt.Dimension)5 FileOutputStream (java.io.FileOutputStream)5 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 Iterator (java.util.Iterator)5 JScrollPane (javax.swing.JScrollPane)5 RouteLocation (jmri.jmrit.operations.routes.RouteLocation)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 List (java.util.List)4 Entry (java.util.Map.Entry)4