Ejemplo n.º 1
0
    public void actionPerformed(ActionEvent e) {
      if (readOnly) {
        return;
      }
      JFileChooser fc = getFileChooser();
      File currentDirectory = fc.getCurrentDirectory();

      if (!currentDirectory.exists()) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderParentDoesntExistText,
            newFolderParentDoesntExistTitleText,
            JOptionPane.WARNING_MESSAGE);
        return;
      }

      File newFolder;
      try {
        newFolder = fc.getFileSystemView().createNewFolder(currentDirectory);
        if (fc.isMultiSelectionEnabled()) {
          fc.setSelectedFiles(new File[] {newFolder});
        } else {
          fc.setSelectedFile(newFolder);
        }
      } catch (IOException exc) {
        JOptionPane.showMessageDialog(
            fc,
            newFolderErrorText + newFolderErrorSeparator + exc,
            newFolderErrorText,
            JOptionPane.ERROR_MESSAGE);
        return;
      }

      fc.rescanCurrentDirectory();
    }
Ejemplo n.º 2
0
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();

    if (isVisible()
        && (e.getSource() == optionPane)
        && (JOptionPane.VALUE_PROPERTY.equals(prop)
            || JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) {
      Object value = optionPane.getValue();

      if (value == JOptionPane.UNINITIALIZED_VALUE) return;
      optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);

      if (button1.equals(value)) {
        try {
          double a = Double.parseDouble(left.getText());
          double b = Double.parseDouble(right.getText());
          double err = Double.parseDouble(error.getText());

          if (a > b) {
            JOptionPane.showMessageDialog(this, "A < B!!!", null, JOptionPane.ERROR_MESSAGE);
          } else {
            hideIt();
            graphic.startApplyingMethod(parentFrame.getSelectedMethod(), err, a, b);
          }
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(
              this, "Trebuie sa fie numar real!", null, JOptionPane.ERROR_MESSAGE);
        }
      } else if (button2.equals(value)) {
        hideIt();
      }
    }
  }
Ejemplo n.º 3
0
    @Override
    public void actionPerformed(ActionEvent e) {
      Frame frame = getFrame();
      JFileChooser chooser = new JFileChooser();
      int ret = chooser.showOpenDialog(frame);

      if (ret != JFileChooser.APPROVE_OPTION) {
        return;
      }

      File f = chooser.getSelectedFile();
      if (f.isFile() && f.canRead()) {
        Document oldDoc = getEditor().getDocument();
        if (oldDoc != null) {
          oldDoc.removeUndoableEditListener(undoHandler);
        }
        if (elementTreePanel != null) {
          elementTreePanel.setEditor(null);
        }
        getEditor().setDocument(new PlainDocument());
        frame.setTitle(f.getName());
        Thread loader = new FileLoader(f, editor.getDocument());
        loader.start();
      } else {
        JOptionPane.showMessageDialog(
            getFrame(),
            "Could not open file: " + f,
            "Error opening file",
            JOptionPane.ERROR_MESSAGE);
      }
    }
Ejemplo n.º 4
0
  private void saveDataToFile(File file) {
    try {
      PrintStream out = new PrintStream(new FileOutputStream(file));

      // Print header line
      out.print("Time");
      for (Sequence seq : seqs) {
        out.print("," + seq.name);
      }
      out.println();

      // Print data lines
      if (seqs.size() > 0 && seqs.get(0).size > 0) {
        for (int i = 0; i < seqs.get(0).size; i++) {
          double excelTime = toExcelTime(times.time(i));
          out.print(String.format(Locale.ENGLISH, "%.6f", excelTime));
          for (Sequence seq : seqs) {
            out.print("," + getFormattedValue(seq.value(i), false));
          }
          out.println();
        }
      }

      out.close();
      JOptionPane.showMessageDialog(
          this,
          Resources.format(
              Messages.FILE_CHOOSER_SAVED_FILE, file.getAbsolutePath(), file.length()));
    } catch (IOException ex) {
      String msg = ex.getLocalizedMessage();
      String path = file.getAbsolutePath();
      if (msg.startsWith(path)) {
        msg = msg.substring(path.length()).trim();
      }
      JOptionPane.showMessageDialog(
          this,
          Resources.format(Messages.FILE_CHOOSER_SAVE_FAILED_MESSAGE, path, msg),
          Messages.FILE_CHOOSER_SAVE_FAILED_TITLE,
          JOptionPane.ERROR_MESSAGE);
    }
  }
 public void save() {
   if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
     try {
       File file = chooser.getSelectedFile();
       XMLEncoder encoder = new XMLEncoder(new FileOutputStream(file));
       encoder.writeObject(frame);
       encoder.close();
     } catch (IOException e) {
       JOptionPane.showMessageDialog(null, e);
     }
   }
 }
  public void load() {
    // show file chooser dialog
    int r = chooser.showOpenDialog(null);

    // if file selected, open
    if (r == JFileChooser.APPROVE_OPTION) {
      try {
        File file = chooser.getSelectedFile();
        XMLDecoder decoder = new XMLDecoder(new FileInputStream(file));
        decoder.readObject();
        decoder.close();
      } catch (IOException e) {
        JOptionPane.showMessageDialog(null, e);
      }
    }
  }
 public void showAboutBox() {
   JOptionPane.showMessageDialog(this, ABOUTMSG);
 }
Ejemplo n.º 8
0
 /** report exceptions */
 protected void reportException(final Exception exception) {
   final String message = exception.getMessage();
   JOptionPane.showMessageDialog(
       _view, message, "Default Folder Error", JOptionPane.ERROR_MESSAGE);
 }
Ejemplo n.º 9
0
    public void actionPerformed(ActionEvent e) {
      if (rebuilding) {
        return;
      }
      if (e.getActionCommand().equals("polygamy yes")) {
        ctxt.saveState = true;
        ctxt.polygamyPermit = true;
        SIL_Edit.edWin.chart.dirty = true;
      }
      if (e.getActionCommand().equals("polygamy no")) {
        ctxt.saveState = true;
        ctxt.polygamyPermit = false;
        SIL_Edit.edWin.chart.dirty = true;
      }
      if (e.getActionCommand().equals("distinct yes")) {
        ctxt.saveState = true;
        ctxt.distinctAdrTerms = true;
        SIL_Edit.edWin.setDistinctAdrMenuItemSelected(true);
        SIL_Edit.edWin.distinctAdrItemActionPerformed(null);
        SIL_Edit.edWin.chart.dirty = true;
        MainPane.topPane.setVisible(true);
      }
      if (e.getActionCommand().equals("distinct no")) {
        ctxt.saveState = true;
        ctxt.distinctAdrTerms = false;
        SIL_Edit.edWin.setDistinctAdrMenuItemSelected(false);
        SIL_Edit.edWin.distinctAdrItemActionPerformed(null);
        SIL_Edit.edWin.chart.dirty = true;
        MainPane.topPane.setVisible(true);
      }
      if (e.getActionCommand().equals("edit matrix")) {
        JOptionPane.showMessageDialog(
            ed,
            "Editing the Kin Term Matrix as a table" + "\nwill be a feature of a future version.",
            "Action Not Availabe",
            JOptionPane.INFORMATION_MESSAGE);
      }
      if (e.getActionCommand().equals("view/edit person")) {
        ctxt.saveState = true;
        Individual edee = (Individual) peopleList.get(indPick.getSelectedIndex());
        PersonEditor pEd = new PersonEditor(ctxt, ed, "View or Edit a Person", edee, "census", 0);
        if (!pEd.dupEditor) {
          pEd.desktop = desktop;
          desktop.add(pEd);
          pEd.miViewMe = menuView.add(pEd.windowNum);
          pEd.miViewMe.addActionListener(pEd);
          pEd.menuView = menuView;
          pEd.show();
          pEd.moveToFront();
          try {
            pEd.setSelected(true);
          } catch (PropertyVetoException pv) {
          }
        } else {
          try {
            pEd.setClosed(true);
          } catch (PropertyVetoException pv) {
          }
        }
      }
      if (e.getActionCommand().equals("view/edit family")) {
        ctxt.saveState = true;
        int serial = famPick.getSelectedIndex();
        Family edee = (Family) famList.get(serial);
        FamilyEditor fEd = new FamilyEditor(ctxt, ed, "View or Edit a Family", edee, "census");
        if (!fEd.dupEditor) {
          fEd.desktop = desktop;
          fEd.setLocation(350, 100);
          desktop.add(fEd);
          fEd.miViewMe = menuView.add(fEd.windowNum);
          fEd.miViewMe.addActionListener(fEd);
          fEd.menuView = menuView;
          fEd.show();
          fEd.moveToFront();
          try {
            fEd.setSelected(true);
          } catch (PropertyVetoException pv) {
          }
        } else {
          try {
            fEd.setClosed(true);
          } catch (PropertyVetoException pv) {
          }
        }
      }
      if (e.getActionCommand().equals("add UDP")) {
        UserDefinedProperty newU = new UserDefinedProperty("*newUDP");
        UDPEditor eddy = new UDPEditor(ctxt, ed, "Create New UDP", true, newU);
        eddy.desktop = desktop;
        eddy.setLocation(250, 50);
        desktop.add(eddy);
        eddy.miViewMe = menuView.add(eddy.windowNum);
        eddy.miViewMe.addActionListener(eddy);
        eddy.menuView = menuView;
        eddy.show();
        eddy.moveToFront();
        try {
          eddy.setSelected(true);
        } catch (PropertyVetoException pv) {
        }
      }
      if (e.getActionCommand().equals("view/edit UDP")) {
        String victim = (String) UDPick.getSelectedItem();
        UserDefinedProperty theUDP = (UserDefinedProperty) ctxt.userDefinedProperties.get(victim);
        UDPEditor eddy = new UDPEditor(ctxt, ed, "Edit UDP " + victim, false, theUDP);
        eddy.desktop = desktop;
        eddy.setLocation(250, 50);
        desktop.add(eddy);
        eddy.miViewMe = menuView.add(eddy.windowNum);
        eddy.miViewMe.addActionListener(eddy);
        eddy.menuView = menuView;
        eddy.show();
        eddy.moveToFront();
        try {
          eddy.setSelected(true);
        } catch (PropertyVetoException pv) {
        }
      }

      if (e.getActionCommand().equals("edit dtRef")) {
        ctxt.saveState = true;
        try {
          EditTheoryFrame etf = EditTheoryFrame.getEditTheoryFrame(ctxt.domTheoryRef());
          etf.setVisible(true);
        } catch (Exception exc) {
          System.err.println("ERROR in creating Edit Frame.\n" + exc);
        }
      }
      if (e.getActionCommand().equals("edit dtAddr")) {
        ctxt.saveState = true;
        try {
          EditTheoryFrame etf = EditTheoryFrame.getEditTheoryFrame(ctxt.domTheoryAdr());
          etf.setVisible(true);
        } catch (Exception exc) {
          System.err.println("ERROR in creating Edit Frame.\n" + exc);
        }
      }
    } //  end of ActionListener method actionPerformed