예제 #1
0
  /**
   * This method handels the creation of a new DrawingArea
   *
   * @param projectName Name of project created
   */
  private void createDrawing(String projectName) {
    if (firstStartup) {
      dailyTips();
      firstStartup = false;
    }

    drawingArea = new DrawingArea(toolbox, toolSettings, activeColorSettings);
    drawingArea.setProjectName(projectName.toLowerCase());

    Dimension desktopSize = jDesktopPane.getSize();
    Dimension jInternalFrameSize = drawingArea.getSize();
    drawingArea.setLocation(
        (desktopSize.width - jInternalFrameSize.width) / 2,
        (desktopSize.height - jInternalFrameSize.height) / 2);

    drawingArea.setTitle("Prosjekt: " + projectName);

    drawingArea.setVisible(true);

    jDesktopPane.add(drawingArea);
    try {
      drawingArea.setSelected(true);
    } catch (PropertyVetoException e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  /**
   * This method handles the loading of an existing project into a new DrawingArea. Gives feedback
   * to the user if project is not found or incompatible with the current version
   *
   * @param projectName Name of project to load
   */
  private void loadDrawing(String projectName) {
    if (firstStartup) {
      dailyTips();
      firstStartup = false;
    }

    drawingArea = new DrawingArea(toolbox, toolSettings, activeColorSettings);
    drawingArea.setProjectName(projectName.toLowerCase());

    try {
      serialization.load(drawingArea, projectName.toLowerCase());

      Dimension desktopSize = jDesktopPane.getSize();
      Dimension jInternalFrameSize = drawingArea.getSize();
      drawingArea.setLocation(
          (desktopSize.width - jInternalFrameSize.width) / 2,
          (desktopSize.height - jInternalFrameSize.height) / 2);

      drawingArea.setTitle("Prosjekt: " + projectName);

      drawingArea.setVisible(true);

      jDesktopPane.add(drawingArea);

    } catch (StorageException ex) {
      // ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
      JOptionPane.showMessageDialog(
          null, "Fant ikke prosjektet på serveren.", "Feil", JOptionPane.ERROR_MESSAGE);

    } catch (IOException ex) {
      // ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
      JOptionPane.showMessageDialog(
          null,
          "Dette prosjektet ble laget på en eldre versjon av programmet.\n"
              + "Dessverre er det ikke kompatibelt med nåværende versjon.",
          "Gammel versjon",
          JOptionPane.ERROR_MESSAGE);

    } catch (URISyntaxException | ClassNotFoundException ex) {
      ex.printStackTrace();
    }

    try {
      drawingArea.setSelected(true);
    } catch (PropertyVetoException e) {
      e.printStackTrace();
    }
  }