コード例 #1
0
ファイル: Main.java プロジェクト: richevan3891/SE-300
    public void actionPerformed(ActionEvent event) {
      try {

        File_Open_Save_Dialog openDialog = new File_Open_Save_Dialog(0);
        try {
          FileInput input = new FileInput(openDialog.fileName);

          routesInfo = input.routeArrayList(input.routesToken);
          routesInfo = sortRouteArray(routesInfo);
          airportsInfo = input.airportArrayList(input.airportsToken);
          closuresInfo = input.closureArrayList(input.closuresToken);
          routesInfo = routeClosureStatus(routesInfo, closuresInfo);

          // If one section has an error (is null) set all sections to null and lock all routes and
          // airprots menu items
          if (airportsInfo == null) {
            routesInfo = null;
            closuresInfo = null;
            systemLocked = true;
          } else if (routesInfo == null) {
            airportsInfo = null;
            closuresInfo = null;
            systemLocked = true;
          } else if (closuresInfo == null) {
            airportsInfo = null;
            routesInfo = null;
            systemLocked = true;
          } else {
            systemLocked = false;
          }

          String[][] data = convertArrayListTo2DArray(routesInfo, 1);
          updateRoutesTable(data);

          String historyText = ("The file " + openDialog.fileName + " has been opened.");
          historyArea.append(historyText + "\n");

          // remove all searches from route search table
          Object[][] emptyData = new Object[0][7];
          Main.updateResultsTable(emptyData);
          Main.historyArea.setText("");
        } catch (NullPointerException e) {
          if (openDialog.fileName != null) {
            String historyText = ("there are errors in " + openDialog.fileName);
            historyArea.append(historyText + "\n");
          }
        } catch (FileNotFoundException e) {
          String historyText = ("The file " + openDialog.fileName + " does not exist.");
          historyArea.append(historyText + "\n");
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
コード例 #2
0
ファイル: Main.java プロジェクト: richevan3891/SE-300
    public void actionPerformed(ActionEvent event) {
      FileInput data = null;
      try {
        data = new FileInput("input.txt");
      } catch (Exception e) {

      }
      String[][] origRoutes = convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
      String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1);
      changesCheck(origRoutes, routesList);
    }
コード例 #3
0
ファイル: Main.java プロジェクト: richevan3891/SE-300
    public void actionPerformed(ActionEvent event) {
      FileInput data = null;
      try {
        data = new FileInput("input.txt");
      } catch (Exception e) {

      }
      String[][] origRoutes = convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
      String[][] routesList = convertArrayListTo2DArray(routesInfo, 1);

      String[] origAirports =
          convertAirportArrayListToArray(data.airportArrayList(data.airportsToken));
      String[] airportsList = convertAirportArrayListToArray(airportsInfo);

      String[][] origClosures =
          convertArrayListTo2DArray(data.closureArrayList(data.closuresToken), 0);
      String[][] closuresList = convertArrayListTo2DArray(closuresInfo, 0);
      changesCheck(origRoutes, routesList, origAirports, airportsList, origClosures, closuresList);
    }
コード例 #4
0
ファイル: Main.java プロジェクト: richevan3891/SE-300
  public JPanel Panels() throws IOException {

    Object[][] data = new Object[0][7];

    // Create the initial Routes Table
    try {
      FileInput input = new FileInput("input.txt"); // read the input file

      // get the data from input.txt
      routesInfo = input.routeArrayList(input.routesToken);
      routesInfo = sortRouteArray(routesInfo);
      airportsInfo = input.airportArrayList(input.airportsToken);
      closuresInfo = input.closureArrayList(input.closuresToken);
      routesInfo = routeClosureStatus(routesInfo, closuresInfo);

      // If one section has an error (is null) set all sections to null and lock all routes and
      // airprots menu items
      if (airportsInfo == null) {
        routesInfo = null;
        closuresInfo = null;
        systemLocked = true;
      } else if (routesInfo == null) {
        airportsInfo = null;
        closuresInfo = null;
        systemLocked = true;
      } else if (closuresInfo == null) {
        airportsInfo = null;
        routesInfo = null;
        systemLocked = true;
      }

      data = convertArrayListTo2DArray(routesInfo, 1);

    } catch (FileNotFoundException e1) { // If input.txt is missing
      System.out.println("The file input.txt is missing.");
    } catch (NullPointerException e1) { // If there are any other errors in the file
      System.out.println("There are errors in the input.txt file");
    }

    routePanel.add(CreateRouteTable(data, totalSize)); // add the table to the JPanel
    routePanel.setBorder(BorderFactory.createTitledBorder("Route Table"));
    // ------------------------------------------------end of route
    // table--------------------------------------------------------

    histPanel.setPreferredSize(new Dimension(totalSize.width, totalSize.height / 5));
    histPanel.setBorder(BorderFactory.createTitledBorder("History"));
    historyArea = new TextArea();
    historyArea.setEditable(false);
    historyArea.setPreferredSize(new Dimension(totalSize.width * 7 / 10, totalSize.height / 7));
    histPanel.add(historyArea);
    // ------------------------------------------------end of history
    // table--------------------------------------------------------
    Object[][] emptyData = new Object[0][7];
    resultsPanel.setBorder(BorderFactory.createTitledBorder("Search Results"));
    resultsPanel.add(CreateResultsTable(emptyData, totalSize));
    // ------------------------------------------------end of results
    // table--------------------------------------------------------

    mainPanel.add(routePanel, BorderLayout.WEST);
    mainPanel.add(histPanel, BorderLayout.SOUTH);
    mainPanel.add(resultsPanel, BorderLayout.EAST);

    return mainPanel;
  }