Пример #1
0
  public AxoObjectInstanceAbstract(
      AxoObjectAbstract type, Patch patch1, String InstanceName1, Point location) {
    super();
    this.type = type;
    typeName = type.id;
    if (type.createdFromRelativePath && (patch1 != null)) {
      String pPath = patch1.getFileNamePath();
      String oPath = type.sPath;

      if (oPath.endsWith(".axp") || oPath.endsWith(".axo") || oPath.endsWith(".axs")) {
        oPath = oPath.substring(0, oPath.length() - 4);
      }
      pPath = pPath.replaceAll("\\\\", "/");
      oPath = oPath.replaceAll("\\\\", "/");
      String[] pPathA = pPath.split("/");
      String[] oPathA = oPath.split("/");
      int i = 0;
      while ((i < pPathA.length) && (i < oPathA.length) && (oPathA[i].equals(pPathA[i]))) {
        i++;
      }
      String rPath = "";
      for (int j = i; j < pPathA.length - 1; j++) {
        rPath += "../";
      }
      if (rPath.isEmpty()) {
        rPath = ".";
      } else {
        rPath = rPath.substring(0, rPath.length() - 1);
      }
      for (int j = i; j < oPathA.length; j++) {
        rPath += "/" + oPathA[j];
      }

      System.out.println(rPath);
      typeName = rPath;
      //            File f = new File();
      //            f.ge
      //            typeName =
    }

    typeSHA = type.getSHA();
    typeUUID = type.getUUID();
    this.InstanceName = InstanceName1;
    this.x = location.x;
    this.y = location.y;
    this.patch = patch1;
  }
Пример #2
0
 public AxoObjectAbstract resolveType() {
   if (type != null) {
     return type;
   }
   if (typeUUID != null) {
     type = MainFrame.axoObjects.GetAxoObjectFromUUID(typeUUID);
     if (type != null) {
       System.out.println("restored from UUID:" + type.id);
       typeName = type.id;
     }
   }
   if ((type == null) && (typeSHA != null)) {
     type = MainFrame.axoObjects.GetAxoObjectFromSHA(typeSHA);
     if (type != null) {
       System.out.println("restored from SHA:" + type.id);
       typeName = type.id;
     }
   }
   if (type == null) {
     ArrayList<AxoObjectAbstract> types =
         MainFrame.axoObjects.GetAxoObjectFromName(typeName, patch.GetCurrentWorkingDirectory());
     if (types == null) {
       Logger.getLogger(AxoObjectInstanceAbstract.class.getName())
           .log(Level.SEVERE, "Object name {0} not found", typeName);
     } else { // pick first
       if (types.size() > 1) {
         typeWasAmbiguous = true;
       }
       type = types.get(0);
       if (type instanceof AxoObjectUnloaded) {
         AxoObjectUnloaded aou = (AxoObjectUnloaded) type;
         type = aou.Load();
         return (AxoObject) type;
       }
       typeSHA = type.getSHA();
     }
   }
   return type;
 }