Exemplo n.º 1
0
  /**
   * Performs actions after specific Route is selected.
   *
   * @param ae - Route Object Tag value (String)
   */
  public void selectRouteAction(ItemEvent ae) {
    Item item = (Item) ((JComboBox) ae.getSource()).getSelectedItem();
    String routeTag = item.getId();
    Vector<Item> busDirectionItems = null;
    mainView.enableRefresh(false);

    try {
      busDirectionItems = mainModel.getBusDirectionItems(routeTag);

      if (busDirectionItems.size() > 0) {
        // Clear Out Bus Stops Table
        mainView.clearStops();

        // Populate Directions Combobox
        updateMapDirections(busDirectionItems);

        // Populate Directions Hash Map
        mainModel.setDirectionsMap(routeTag);

        // Draw Route on map
        drawMapRoute(routeTag);
      } else {
        mainView.enableRouteDirections(false);
      }
    } catch (ServiceUnavailableException e) {
      mainView.notifyAndExit(MainView.NEXTBUS_SERVICE_UNAVAILABLE);
    } catch (NullPointerException npe) {
      resetAll();
      // npe.printStackTrace();
    }
  }