Beispiel #1
0
 public void doIt(DocumentView documentView) {
   JFileChooser fileChooser = documentView.getOpenChooser();
   if (fileChooser.showOpenDialog(documentView.getComponent()) == JFileChooser.APPROVE_OPTION) {
     openFile(documentView, fileChooser);
   } else {
     documentView.setEnabled(true);
   }
 }
Beispiel #2
0
  public void actionPerformed(ActionEvent evt) {
    final DocumentOrientedApplication application = getApplication();
    if (application.isEnabled()) {
      application.setEnabled(false);
      // Search for an empty documentView
      DocumentView emptyProject = application.getCurrentView();
      if (emptyProject == null || emptyProject.getFile() != null || emptyProject.isModified()) {
        emptyProject = null;
        /*
        for (DocumentView aProject : application.getViews()) {
            if (aProject.getFile() == null &&
                    ! aProject.isModified()) {
                emptyProject = aProject;
                break;
            }
        }*/
      }

      final DocumentView p;
      boolean removeMe;
      if (emptyProject == null) {
        p = application.createView();
        application.add(p);
        removeMe = true;
        removeMe = true;
      } else {
        p = emptyProject;
        removeMe = false;
      }
      JFileChooser fileChooser = p.getOpenChooser();
      if (fileChooser.showOpenDialog(application.getComponent()) == JFileChooser.APPROVE_OPTION) {
        application.show(p);
        openFile(fileChooser, p);
      } else {
        if (removeMe) {
          application.remove(p);
        }
        application.setEnabled(true);
      }
    }
  }