/** 将工作流树节点对象保存到指定目录下 文件名为该对象的id */
  public static void SaveFileModelToFile(FileModel fileModel) throws IOException {
    if (fileModel == null) {
      logger.error("传入的FileModel的为空,保存失败!");
      return;
    }

    //		File file = fileModel.getFile();
    // 数据库设计文件
    File spdFile =
        new File(
            SystemConstants.WORKSPACEPATH,
            fileModel.getFolderName() + File.separator + SystemConstants.ZIP_FILE_SUNCARDDESIGNER);
    if (!spdFile.exists()) {
      spdFile.createNewFile();
    }

    // 表格初始化信息文件
    File spddFile =
        new File(
            SystemConstants.WORKSPACEPATH,
            fileModel.getFolderName()
                + File.separator
                + SystemConstants.ZIP_FILE_SUNCARDDESIGNER_DATA);
    if (!spddFile.exists()) {
      spddFile.createNewFile();
    }
    //		// 存放表格初始化信息的文件夹
    //		File spddFolder = new File(SystemConstants.WORKSPACEPATH,
    //				fileModel.getFolderName() + File.separator +
    // SystemConstants.ZIP_FILE_SUNCARDDESIGNER_DATA_FOLDER + File.separator);
    //		if(!spddFolder.exists()) {
    //			spddFolder.mkdirs();
    //		}

    Document document = SwitchObjAndXml.getDocFromFileModel(fileModel);
    // 写入设计文件信息
    OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(spdFile), "UTF-8");
    out.write(document.asXML());
    out.close();

    // 写入表格初始化信息
    document = SwitchObjAndXml.getInitTableDataDocFromFileModel(fileModel);
    out = new OutputStreamWriter(new FileOutputStream(spddFile), "UTF-8");
    out.write(document.asXML());
    out.close();

    // 给文件模型对应的CommandStack设定保存点
    CommandStack commandStack = DefaultViewPart.getFileCommandFromObj(fileModel);
    if (commandStack != null) {
      commandStack.markSaveLocation();
    }
  }
示例#2
0
  @Override
  public Object clone() {
    LineGefModel linkGefModel = new LineGefModel();
    linkGefModel.setSource(this.getSource());
    linkGefModel.setTarget(this.getTarget());

    try {
      linkGefModel.setDataObject((DataObjectInterface) lineModel.clone());
    } catch (CloneNotSupportedException e) {
      logger.error("克隆LineGefModel的LineModel失败!");
      e.printStackTrace();
    }

    // 注意:克隆时,暂时没有拷贝LineXmlProperty 和 List<Point>信息。

    return linkGefModel;
  }
  /** 将工作流树节点对象保存到指定目录下 文件名为该对象的id */
  public static void SaveProjectModelToFile(ProjectModel projectModel) throws IOException {
    if (projectModel == null) {
      logger.error("传入的FileModel的为空,保存失败!");
      return;
    }

    // 数据库设计文件
    File ppdFile =
        new File(
            SystemConstants.PROJECTSPACEPATH,
            projectModel.getFolderName() + File.separator + SystemConstants.ZIP_FILE_PROJECT);
    if (!ppdFile.exists()) {
      ppdFile.createNewFile();
    }

    // 表格初始化信息文件
    File spddFile =
        new File(
            SystemConstants.PROJECTSPACEPATH,
            projectModel.getFolderName()
                + File.separator
                + SystemConstants.ZIP_FILE_SUNCARDDESIGNER_DATA);
    if (!spddFile.exists()) {
      spddFile.createNewFile();
    }

    Document document = SwitchObjAndXml.getDocFromProjectModel(projectModel);
    // 写入项目文件信息
    OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(ppdFile), "UTF-8");
    out.write(document.asXML());
    out.close();

    // 写入表格初始化信息
    document = SwitchObjAndXml.getInitTableDataDocFromProjectModel(projectModel);
    out = new OutputStreamWriter(new FileOutputStream(spddFile), "UTF-8");
    out.write(document.asXML());
    out.close();

    // 给文件模型对应的CommandStack设定保存点
    CommandStack commandStack =
        ProjectDefaultViewPart.getCommandStackFromProjectModel(projectModel);
    if (commandStack != null) {
      commandStack.markSaveLocation();
    }
  }