예제 #1
0
/**
 * 普通连接线的Model
 *
 * @author 易振强
 * @version 1.0, 2011-12-15
 * @see
 * @since 1.0
 */
public class LineGefModel extends AbstractLineGefModel {
  public static final String PROP_ID_LABEL = "linemodel_label_text";
  private Label label = new Label("");

  private LineModel lineModel;

  public static Log logger = LogManager.getLogger(LineGefModel.class.getName());

  public LineGefModel() {
    getLineXmlProperty().setLabel("");
    lineModel = new LineModel();
  }

  @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;
  }

  public Label getLabel() {
    return label;
  }

  @Override
  public void setLabelText(String text) {
    this.label.setText(text);
    getLineXmlProperty().setLabel(text);
    firePropertyListenerChange(PROP_ID_LABEL, null, text);
  }

  public String getLabelText() {
    return label.getText();
  }

  @Override
  public LineModel getDataObject() {
    return lineModel;
  }

  @Override
  public void setDataObject(DataObjectInterface object) {
    lineModel = (LineModel) object;
  }
}
예제 #2
0
/**
 * 产品空间模型 一个产品空间模型可以包含多个产品模型(ProductModel)
 *
 * @author Manzhizhen
 * @version 1.0, 2012-9-5
 * @see
 * @since 1.0
 */
public class ProductSpaceModel {
  // 存放了一个产品空间中的所有产品
  private static Map<FileModel, List<ProductModel>> productModelMap =
      new HashMap<FileModel, List<ProductModel>>();

  private static Log logger = LogManager.getLogger(ProductSpaceModel.class.getName());

  public static Map<FileModel, List<ProductModel>> getProductModelMap() {
    return productModelMap;
  }
}
/**
 * 模型创建和位置、大小改变的策略
 *
 * @author 易振强
 * @version [1.0, 2012-3-26]
 * @see
 * @since 1.0
 */
public class WorkFlowXYLayoutEditPolicy extends XYLayoutEditPolicy {
  private Log logger = LogManager.getLogger(WorkFlowXYLayoutEditPolicy.class.getName());

  @Override
  protected Command getCreateCommand(CreateRequest request) {
    CreateModelCommand command = new CreateModelCommand();

    // 产生创建图形的尺寸和位置
    Rectangle constraint = (Rectangle) getConstraintFor(request);

    // 获得新创建的模型
    AbstractModel model = (AbstractModel) request.getNewObject();

    // 为该图形设置前面获得的位置和尺寸
    model.setConstraint(constraint);

    command.setWorkFlowModel((WorkFlowModel) getHost().getModel());
    command.setModel(model);

    return command;
  }

  @Override
  protected Command createChangeConstraintCommand(EditPart child, Object constraint) {

    ChangeConstraintCommand command = new ChangeConstraintCommand();
    command.setModel((AbstractModel) child.getModel());
    command.setConstraint((Rectangle) constraint);

    return command;
  }

  @Override
  protected Command createAddCommand(EditPart child, Object constraint) {
    return createAddCommand(child, constraint);
  }

  @Override
  protected Command getDeleteDependantCommand(Request request) {
    return null;
  }

  @Override
  public Command getCommand(Request request) {
    return super.getCommand(request);
  }
}
예제 #4
0
/**
 * 表格初始化数据模型
 *
 * @author Manzhizhen
 * @version 1.0 2013-4-11
 * @see
 * @since 1.0
 */
public class TableDataModel implements DataObjectInterface {
  private Map<ColumnModel, String> dataMap = new HashMap<ColumnModel, String>();
  private boolean canModify = true; // 标记该初始化模型是否能在IDE上修改

  private static String elementName = "tableDataModel"; // 保存为document时候的顶节点name

  private Log logger = LogManager.getLogger(TableDataModel.class.getName());

  public Map<ColumnModel, String> getDataMap() {
    return dataMap;
  }

  public boolean isCanModify() {
    return canModify;
  }

  public void setCanModify(boolean canModify) {
    this.canModify = canModify;
  }

  @Override
  public Element getElementFromObject(Element parent) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Object getObjectFromElement(Element element, Object... obj) {
    if (element == null) {
      logger.warn("TableDataModel的Element为空,无法将xml转换为对象!");
      return null;
    }

    if (!elementName.equals(element.getName())) {
      element = element.element(elementName);
      if (element == null) {
        logger.warn("InitTableDataModel的Element为空,无法将xml转换为对象!");
        return null;
      }
    }

    return null;
  }
}
예제 #5
0
/**
 * 对象和文件互转类
 *
 * @author 易振强
 * @version 1.0, 2012-3-28
 * @see
 * @since 1.0
 */
public class SwitchObjectAndFile {
  private static Log logger = LogManager.getLogger(SwitchObjectAndFile.class.getName());

  /** 将工作流树节点对象保存到指定目录下 文件名为该对象的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();
    }
  }

  /** 将工作流树节点对象保存到指定目录下 文件名为该对象的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();
    }
  }
}