예제 #1
0
 protected void fileOpened(final DocumentView documentView, File file, Object value) {
   final DocumentOrientedApplication application = getApplication();
   if (value == null) {
     documentView.setFile(file);
     documentView.setEnabled(true);
     Frame w = (Frame) SwingUtilities.getWindowAncestor(documentView.getComponent());
     if (w != null) {
       w.setExtendedState(w.getExtendedState() & ~Frame.ICONIFIED);
       w.toFront();
     }
     documentView.getComponent().requestFocus();
     application.addRecentFile(file);
     application.setEnabled(true);
   } else {
     if (value instanceof Throwable) {
       ((Throwable) value).printStackTrace();
     }
     JSheet.showMessageSheet(
         documentView.getComponent(),
         "<html>"
             + UIManager.getString("OptionPane.css")
             + "<b>Couldn't open the file \""
             + file
             + "\".</b><br>"
             + value,
         JOptionPane.ERROR_MESSAGE,
         new SheetListener() {
           public void optionSelected(SheetEvent evt) {
             // application.dispose(documentView);
           }
         });
   }
 }
예제 #2
0
 protected void fileOpened(final Project project, File file, Object value) {
   if (value == null) {
     project.setFile(file);
     project.setEnabled(true);
     getApplication().addRecentFile(file);
   } else {
     JSheet.showMessageSheet(
         project.getComponent(),
         "<html>"
             + UIManager.getString("OptionPane.css")
             + "<b>Couldn't open the file \""
             + file
             + "\".</b><br>"
             + value,
         JOptionPane.ERROR_MESSAGE,
         new SheetListener() {
           public void optionSelected(SheetEvent evt) {
             project.clear();
             project.setEnabled(true);
           }
         });
   }
 }
예제 #3
0
  protected void fileOpened(final DocumentView documentView, File file, Object value) {
    if (value == null) {
      documentView.setFile(file);
      documentView.setEnabled(true);
      getApplication().addRecentFile(file);
    } else {
      JSheet.showMessageSheet(
          documentView.getComponent(),
          "<html>"
              + UIManager.getString("OptionPane.css")
              + "<b>Couldn't open the file \""
              + file
              + "\".</b><br>"
              + value,
          JOptionPane.ERROR_MESSAGE,
          new SheetListener() {
            public void optionSelected(SheetEvent evt) {
              documentView.execute(
                  new Worker() {
                    public Object construct() {
                      try {
                        documentView.clear();
                        return null;
                      } catch (IOException ex) {
                        return ex;
                      }
                    }

                    public void finished(Object result) {
                      documentView.setEnabled(true);
                    }
                  });
            }
          });
    }
  }