Beispiel #1
0
  /** Creates the dialoge for opening an existing project. */
  void openProjectDialog() {

    String[] array = serialization.getStringArrayOfProjects();

    projectName =
        (String)
            JOptionPane.showInputDialog(
                null,
                "Velg prosjekt:",
                "Åpne prosjekt",
                JOptionPane.QUESTION_MESSAGE,
                null,
                array,
                array[0]);

    if ((projectName != null) && (projectName.length() > 0)) {
      loadDrawing(projectName);
    }
  }
Beispiel #2
0
  /**
   * Creates the dialoge for new projects. It checks if the project already exists on the server and
   * gives the user options to load or overwrite the existing if it does.
   */
  void newProject() {

    projectName =
        JOptionPane.showInputDialog(
            null,
            "Angi navnet på det nye prosjektet:",
            "Nytt prosjekt",
            JOptionPane.INFORMATION_MESSAGE);

    if ((projectName != null) && (projectName.length() > 0)) {
      String[] array = serialization.getStringArrayOfProjects();
      boolean projectExists = false;
      for (String storedProject : array) {
        if (projectName.toLowerCase().equals(storedProject)) {
          projectExists = true;

          Object[] options = {"Åpne", "Overskriv", "Avbryt"};
          int n =
              JOptionPane.showOptionDialog(
                  null,
                  "Navnet du anga eksisterer fra før.",
                  "Prosjektet eksisterer",
                  JOptionPane.YES_NO_CANCEL_OPTION,
                  JOptionPane.INFORMATION_MESSAGE,
                  null,
                  options,
                  options[0]);

          if (n == 0) {
            loadDrawing(projectName);
          } else if (n == 1) {
            createDrawing(projectName);
          } else if (n == 2) {
            break;
          }
        }
      }

      if (!projectExists) {
        createDrawing(projectName);
      }
    }
  }