Exemple #1
0
 /**
  * opens a model from a URL. Currently, this is only used to create a new model (load the new
  * model template).
  */
 private void openFromURL(String model) throws UserCancelException, java.io.IOException {
   String source = org.nlogo.util.Utils.url2String(model);
   if (model.equals(emptyModelPath())) {
     openFromSource(source, null, "Clearing...", ModelTypeJ.NEW());
   } else {
     // models loaded from URLs are treated as library models, since
     // they are read-only. This is currently never used, so I'm
     // not even sure it's what we would really want...
     openFromSource(source, null, "Loading...", ModelTypeJ.LIBRARY());
   }
 }
Exemple #2
0
 public void handle(org.nlogo.window.Events.OpenModelEvent e) {
   try {
     openFromPath(e.path, ModelTypeJ.LIBRARY());
   } catch (java.io.IOException ex) {
     throw new IllegalStateException(ex);
   }
 }
Exemple #3
0
 @Override
 void action() throws UserCancelException {
   offerSave();
   String source = ModelsLibraryDialog.open(org.nlogo.awt.Hierarchy.getFrame(FileMenu.this));
   String modelPath = ModelsLibraryDialog.getModelPath();
   openFromSource(source, modelPath, "Loading...", ModelTypeJ.LIBRARY());
 }
Exemple #4
0
 private String userChooseSavePath() throws UserCancelException {
   String newFileName = guessFileName();
   String newDirectoryName = null;
   if (app.workspace().getModelType() == ModelTypeJ.NORMAL()) {
     // we only default to saving in the model dir for normal and
     // models. for library and new models, we use the current
     // FileDialog dir.
     newDirectoryName = app.workspace().getModelDir();
   }
   org.nlogo.swing.FileDialog.setDirectory(newDirectoryName);
   String path =
       org.nlogo.swing.FileDialog.show(this, "Save As", java.awt.FileDialog.SAVE, newFileName);
   if (!path.endsWith("." + modelSuffix())) {
     path += "." + modelSuffix();
   }
   return path;
 }
Exemple #5
0
 @Override
 void action() throws UserCancelException, java.io.IOException {
   offerSave();
   openFromPath(userChooseLoadPath(), ModelTypeJ.NORMAL());
 }