Exemple #1
0
  private void inititateSarType() {
    int selectedIndex = typeSelectionComboBox.getSelectedIndex();
    // 0 Simple SAR
    // 1 Rapid Response
    // 2 Datum Point
    // 3 Datum Line
    // 4 Back track

    switch (selectedIndex) {
      case 0:
        voctManager.setSarType(SAR_TYPE.SIMPLE_SAR);
        // rapidResponseDatumPointInputPanel
        // .setSARType(SAR_TYPE.RAPID_RESPONSE);

        currentCard = SIMPLESAR;
        break;
      case 1:
        voctManager.setSarType(SAR_TYPE.RAPID_RESPONSE);
        rapidResponseDatumPointInputPanel.setSARType(SAR_TYPE.RAPID_RESPONSE);
        currentCard = INPUTSARRAPIDRESPONSEDATUM;
        break;
      case 2:
        voctManager.setSarType(SAR_TYPE.DATUM_POINT);
        rapidResponseDatumPointInputPanel.setSARType(SAR_TYPE.DATUM_POINT);
        currentCard = INPUTSARRAPIDRESPONSEDATUM;
        break;
      case 3:
        voctManager.setSarType(SAR_TYPE.DATUM_LINE);
        currentCard = INPUTPANELDATUMLINE;
        break;
        // case 3:
        // voctManager.setSarType(SAR_TYPE.BACKTRACK);
        // // currentCard = INPUTSARRAPIDRESPONSEDATUM;
        // break;
    }
  }
Exemple #2
0
  @Override
  public void actionPerformed(ActionEvent arg0) {

    if (arg0.getSource() == typeSelectionComboBox) {
      int selectedIndex = typeSelectionComboBox.getSelectedIndex();
      // 0 Simple SAR
      // 1 Rapid Response
      // 2 Datum Point
      // 3 Datum Line
      // 4 Back track

      switch (selectedIndex) {
        case 0:
          descriptiveImage.setIcon(simpleSarIcon);
          descriptiveText.setText(simpleSarTxt);
          nextButton.setEnabled(true);
          break;
        case 1:
          descriptiveImage.setIcon(rapidResponseIcon);
          descriptiveText.setText(rapidresponseTxt);
          nextButton.setEnabled(true);
          break;
        case 2:
          descriptiveImage.setIcon(datumPointIcon);
          descriptiveText.setText(datumPointTxt);
          nextButton.setEnabled(true);
          break;
        case 3:
          descriptiveImage.setIcon(datumLineIcon);
          descriptiveText.setText(datumLineTxt);
          nextButton.setEnabled(true);
          break;
          // case 4:
          // descriptiveImage.setIcon(backtrackIcon);
          // descriptiveText.setText(backtrackTxt);
          // nextButton.setEnabled(false);
          // break;
      }
    }

    if (arg0.getSource() == btnImport) {
      // Import started

      // Open a file menu select for xml files

      // Create SARIS parser for returned object

      JFileChooser fileChooser = new JFileChooser(new File("."));
      fileChooser.addChoosableFileFilter(new XmlFilter());
      fileChooser.setAcceptAllFileFilterUsed(true);
      fileChooser.showOpenDialog(null);

      if (fileChooser.getSelectedFile() != null) {

        String fileChoosen = fileChooser.getSelectedFile().getAbsolutePath();

        try {

          // if (fileChoosen.contains(".sar")) {
          // SARFileParser parser = new SARFileParser(fileChoosen);
          //
          // // voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          // // voctManager.setSarData(parser.getSarData());
          // // calculationsText.setText("SARIS PARSE SUCCESSFULL");
          // // backButton.setEnabled(true);
          // // nextButton.setText("Finish");
          // // nextButton.setEnabled(true);
          //
          // } else {
          SARISXMLParser parser = new SARISXMLParser(fileChoosen);

          voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          voctManager.setSarData(parser.getSarData());
          calculationsText.setText("SARIS PARSE SUCCESSFULL");
          backButton.setEnabled(true);
          nextButton.setText("Finish");
          nextButton.setEnabled(true);

          // }

          CardLayout cl = (CardLayout) (masterPanel.getLayout());
          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;

          // Move to final page where we show the info
        } catch (Exception e) {
          calculationsText.setText("SARIS Parse failed on file " + fileChoosen);
          backButton.setEnabled(true);
          nextButton.setEnabled(false);
          voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          CardLayout cl = (CardLayout) (masterPanel.getLayout());
          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;
        }
      }
    }

    if (arg0.getSource() == nextButton) {
      // Get the current card and action depends on that

      // System.out.println("Next button pressed, currently at :"
      // + currentCard);

      // We're at SAR selection screen
      if (currentCard == SELECTSARTYPE) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        backButton.setEnabled(true);

        inititateSarType();

        // System.out.println("Setting panel to " + currentCard);

        // The type select determines which panel we show
        cl.show(masterPanel, currentCard);

        return;
      }

      // We're at input screen
      if (currentCard == INPUTSARRAPIDRESPONSEDATUM
          || currentCard == INPUTPANELDATUMLINE
          || currentCard == SIMPLESAR) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());

        if (validateInputAndInititate()) {
          // System.out.println("Validated");
          calculationsText.setText(voctManager.getSarData().generateHTML());
          backButton.setEnabled(true);
          nextButton.setText("Finish");

          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;
        } else {
          // do nothing, missing data, internally sorted
        }

        return;
      }

      // We're at confirmation screen
      if (currentCard == CALCULATIONSPANEL) {
        // System.out.println(currentCard);
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        backButton.setEnabled(true);
        nextButton.setText("Next");
        nextButton.setEnabled(true);

        SAR_TYPE type = voctManager.getSarType();

        if (type == SAR_TYPE.RAPID_RESPONSE) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_POINT) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_LINE) {
          currentCard = INPUTPANELDATUMLINE;
        }

        if (type == SAR_TYPE.BACKTRACK) {
          // To be implemented
        }

        if (type == SAR_TYPE.SARIS_DATUM_POINT) {
          // To be implemented
          currentCard = SELECTSARTYPE;
        }

        if (type == SAR_TYPE.SIMPLE_SAR) {
          currentCard = SIMPLESAR;
        }

        if (sarReady) {

          this.setVisible(false);

          // Set the dialog back to input screen for reentering
          cl.show(masterPanel, currentCard);

          // System.out.println("Hiding");

          // Display SAR command
          voctManager.setLoadSarFromSerialize(false);
          voctManager.displaySar();
          sarReady = false;
        }

        return;
      }
    }

    if (arg0.getSource() == backButton) {

      // If we're at Rapid Response or Datum or Back back go back to
      // init
      if (currentCard == INPUTSARRAPIDRESPONSEDATUM
          || currentCard == INPUTPANELDATUMLINE
          || currentCard == SIMPLESAR) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        cl.show(masterPanel, SELECTSARTYPE);
        backButton.setEnabled(false);
        currentCard = SELECTSARTYPE;
        return;
      }

      // We're at confirmation
      if (currentCard == CALCULATIONSPANEL) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());

        SAR_TYPE type = voctManager.getSarType();

        if (type == SAR_TYPE.RAPID_RESPONSE) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_POINT) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_LINE) {
          currentCard = INPUTPANELDATUMLINE;
        }

        if (type == SAR_TYPE.SARIS_DATUM_POINT) {
          // To be implemented
          currentCard = SELECTSARTYPE;
        }

        if (type == SAR_TYPE.SIMPLE_SAR) {
          currentCard = SIMPLESAR;
        }

        cl.show(masterPanel, currentCard);
        backButton.setEnabled(true);
        nextButton.setText("Next");
        return;
      }
    }

    if (arg0.getSource() == cancelButton) {
      this.setVisible(false);
      // voctManager.cancelSarOperation();
      return;
    }
  }