Beispiel #1
0
  /** Save project. */
  private void saveProject() {

    // validate that description is present
    if (description.getText() == null || description.getText().equals("")) {
      Errmsg.getErrorHandler().notice(Resource.getResourceString("empty_desc"));
      return;
    }
    try {

      String num = projectIdText.getText();

      Project p = new Project();

      if (!num.equals("NEW") && !num.equals("CLONE")) {
        p.setKey(Integer.parseInt(num));
      }

      // fill in the fields from the screen
      Calendar cal = startDateChooser.getCalendar();
      if (cal == null) cal = new GregorianCalendar();
      p.setStartDate(cal.getTime()); // start date

      cal = dueDateChooser.getCalendar();
      if (cal != null) {
        p.setDueDate(cal.getTime()); // due date

        // validate due date
        if (DateUtil.isAfter(p.getStartDate(), p.getDueDate())) {
          throw new Warning(Resource.getResourceString("sd_dd_warn"));
        }
      }

      p.setDescription(description.getText());
      p.setStatus((String) statusComboBox.getSelectedItem());

      String cat = (String) categoryBox.getSelectedItem();
      if (cat.equals("") || cat.equals(CategoryModel.UNCATEGORIZED)) {
        p.setCategory(null);
      } else {
        p.setCategory(cat);
      }

      p.setParent(null);
      String proj = (String) parentProjectComboBox.getSelectedItem();
      try {
        p.setParent(getProjectId(proj));

      } catch (Exception e) {
        // no project selected
      }

      TaskModel.getReference().saveProject(p);
      p.setKey(p.getKey());

      showProject(Action.CHANGE, p, null);
    } catch (Warning w) {
      Errmsg.getErrorHandler().notice(w.getMessage());
    } catch (Exception e) {
      Errmsg.getErrorHandler().errmsg(e);
    }
  }
Beispiel #2
0
  /**
   * Main UI initialization.
   *
   * @param trayname - name for the tray icon
   */
  public static void startUI(String trayname) {

    Errmsg.setErrorHandler(new UIErrorHandler());

    // check database timestamp
    try {
      JdbcDB.checkTimestamp();
    } catch (Warning e1) {
      Errmsg.getErrorHandler().notice(e1.getMessage());
    } catch (Exception e) {
      Errmsg.getErrorHandler().errmsg(e);
    }

    // default font
    String deffont = Prefs.getPref(PrefName.DEFFONT);
    if (!deffont.equals("")) {
      Font f = Font.decode(deffont);
      NwFontChooserS.setDefaultFont(f);
    }

    // set the look and feel
    String lnf = Prefs.getPref(PrefName.LNF);
    try {

      // set default jgoodies theme
      if (lnf.contains("jgoodies")) {
        String theme = System.getProperty("Plastic.defaultTheme");
        if (theme == null) {
          System.setProperty("Plastic.defaultTheme", Prefs.getPref(PrefName.GOODIESTHEME));
        }
      }

      UIManager.setLookAndFeel(lnf);
      UIManager.getLookAndFeelDefaults().put("ClassLoader", UIControl.class.getClassLoader());
    } catch (Exception e) {
      log.severe(e.toString());
    }

    // pop up the splash if the option is set
    if (Prefs.getBoolPref(PrefName.SPLASH)) {
      splashScreen = new SplashScreen();
      splashScreen.setText(Resource.getResourceString("Initializing"));
      splashScreen.setVisible(true);
      final String tn = trayname;

      /*
       * in order for the splash to be seen, we will complete
       * initialization later (in the swing thread).
       */
      Timer t =
          new Timer(
              3000,
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                  completeUIInitialization(tn);
                }
              });
      t.setRepeats(false);
      t.start();
    } else completeUIInitialization(trayname);
  }