Esempio n. 1
0
 /**
  * opens a NetLogo model from the previously loaded source. This is complicated and I'm not
  * totally sure I understand it, but it really should be documented...
  *
  * @param source the model source. May not be null.
  * @param path the full pathname of the model, including the file. For example:
  *     "/home/mmh/models/My_Model.nlogo". This may be null, if, for example, this is a new model,
  *     or the origin is unknown.
  * @param message the message to display in the "loading" modal dialog.
  * @param modelType the type of this model. Must be one of the types defined in
  *     org.nlogo.workspace.Workspace.
  */
 void openFromSource(String source, String path, String message, ModelType modelType)
     throws UserCancelException {
   // map elements are { source, info, resources, version }
   Map<ModelSection, String[]> map = ModelReader.parseModel(source);
   if (map == null || map.get(ModelSectionJ.VERSION()).length == 0) {
     notifyUserNotValidFile();
   }
   String version = org.nlogo.api.ModelReader.parseVersion(map);
   if (version == null || !version.startsWith("NetLogo")) {
     notifyUserNotValidFile();
   }
   if (org.nlogo.api.Version.is3D() && !org.nlogo.api.Version.is3D(version)) {
     checkWithUserBeforeOpening2DModelin3D();
   }
   if (!org.nlogo.api.Version.is3D() && org.nlogo.api.Version.is3D(version)) {
     checkWithUserBeforeOpening3DModelin2D(version);
   } else {
     if (!org.nlogo.api.Version.knownVersion(version)) {
       checkWithUserBeforeOpeningModelFromFutureVersion(version);
     }
   }
   openFromMap(map, path, message, modelType);
   savedVersion = version;
 }
Esempio n. 2
0
 public void handle(org.nlogo.window.Events.LoadSectionEvent e) {
   if (e.section == ModelSectionJ.WIDGETS()) {
     loadWidgets(e.lines, e.version);
   }
 }