Ejemplo n.º 1
0
 private void openFromMap(
     final Map<ModelSection, String[]> map,
     final String path,
     String message,
     final ModelType modelType) {
   try {
     if (firstLoad) {
       firstLoad = false;
       // app frame isn't even showing yet, so no need for ModalProgressTask
       org.nlogo.window.ModelLoader.load(this, path, modelType, map);
     } else {
       Runnable loader =
           new Runnable() {
             public void run() {
               try {
                 org.nlogo.window.ModelLoader.load(FileMenu.this, path, modelType, map);
               } catch (org.nlogo.window.InvalidVersionException e) {
                 // we've already checked the version
                 // so I don't expect this ever to happen
                 // but in case it does...
                 throw new IllegalStateException(e);
               }
             }
           };
       org.nlogo.swing.ModalProgressTask.apply(
           org.nlogo.awt.Hierarchy.getFrame(this), message, loader);
       app.tabs().requestFocus();
     }
   } catch (org.nlogo.window.InvalidVersionException e) {
     // we've already checked the version
     throw new IllegalStateException(e);
   }
 }
Ejemplo n.º 2
0
 private void doSave(final String path) throws UserCancelException {
   checkWithUserBeforeSavingModelFromOldVersion();
   Saver saver = new Saver(path);
   org.nlogo.swing.ModalProgressTask.apply(
       org.nlogo.awt.Hierarchy.getFrame(this), "Saving...", saver);
   if (saver.getException() != null) {
     javax.swing.JOptionPane.showMessageDialog(
         this,
         "Save failed.  Error: " + saver.getException().getMessage(),
         "NetLogo",
         javax.swing.JOptionPane.ERROR_MESSAGE);
   }
   if (!saver.getResult()) {
     throw new UserCancelException();
   }
   app.tabs().saveExternalFiles();
 }
Ejemplo n.º 3
0
  public FileMenu(App app, ModelSaver modelSaver, AppletSaver appletSaver) {
    super(I18N.guiJ().get("menu.file"));
    this.app = app;
    this.modelSaver = modelSaver;
    this.appletSaver = appletSaver;
    addMenuItem('N', new NewAction());
    addMenuItem('O', new OpenAction());
    addMenuItem('M', new ModelsLibraryAction());
    addSeparator();
    addMenuItem('S', new SaveAction());
    addMenuItem(new SaveAsAction());
    addMenuItem(new SaveAppletAction());
    addSeparator();
    addMenuItem(I18N.guiJ().get("menu.file.print"), 'P', app.tabs().printAction());
    addSeparator();
    org.nlogo.swing.Menu exportMenu = new org.nlogo.swing.Menu(I18N.guiJ().get("menu.file.export"));
    exportMenu.addMenuItem(new ExportWorldAction());
    exportMenu.addMenuItem(new ExportPlotAction());
    exportMenu.addMenuItem(new ExportAllPlotsAction());
    exportMenu.addMenuItem(new ExportGraphicsAction());
    exportMenu.addMenuItem(new ExportInterfaceAction());
    exportMenu.addMenuItem(new ExportOutputAction());
    add(exportMenu);
    addSeparator();
    org.nlogo.swing.Menu importMenu = new org.nlogo.swing.Menu(I18N.guiJ().get("menu.file.import"));
    importMenu.addMenuItem(new ImportWorldAction());
    importMenu.addMenuItem(new ImportPatchColorsAction());
    importMenu.addMenuItem(new ImportPatchColorsRGBAction());
    if (!org.nlogo.api.Version.is3D()) {
      importMenu.addMenuItem(new ImportDrawingAction());
    }
    importMenu.addMenuItem(new ImportClientAction());

    add(importMenu);
    if (!System.getProperty("os.name").startsWith("Mac")) {
      addSeparator();
      addMenuItem('Q', new QuitAction());
    }
    // initialize here, unless there's a big problem early on in the
    // initial load process it'll get initialize properly below
    // maybe this fixes Nigel Gilbert's bug. maybe. ev 1/30/07
    savedVersion = org.nlogo.api.Version.version();
  }