示例#1
0
  public DataSet getDatasource(PropertyItem propertyItem) {
    String oldRelations = propertyItem.getValue();
    String[] relstions = oldRelations.split(",");
    List<String> includeList = new ArrayList<String>();
    for (String relation : relstions) {
      includeList.add(relation);
    }

    XuiElement xuiElement = (XuiElement) propertyItem.getOwerElement();

    /*如果是data节点或data的子节点*/
    if ((!"$UI/system/components/justep/data/data".equals(xuiElement.getName()))
        && ("data".equals(xuiElement.getConfigAttribute("component-type"))
            || "data".equals(xuiElement.getParentElement().getConfigAttribute("component-type")))) {
      String[] actinoInfo = this.getActionInfoOfData(xuiElement, XuiConstant.P_READER);
      DataSet ds =
          XuiDataSourceManager.getRelationsOfActionMainConcept(actinoInfo[0], actinoInfo[1], true);
      ds.setValueByCondition(DSUtil.SELECTED, true, ModelConstant.ALIAS, includeList);
      return ds;
    }
    /*其他节点,指定editor-parameter属性为data 的ID*/
    else if ("$UI/system/components/justep/data/data".equals(xuiElement.getName())) {
      DataSet ds = XuiDataSourceManager.createHasRelationDataSet();
      List<XuiElement> childList = xuiElement.getChildren();
      for (XuiElement childE : childList) {

        ds.addRecord(
            new Object[] {
              false,
              childE.getProperyValue("name"),
              childE.getProperyValue("label"),
              childE.getProperyValue("name"),
              childE.getProperyValue("type"),
              null,
              "relation"
            });
      }
      ds.setValueByCondition(DSUtil.SELECTED, true, ModelConstant.ALIAS, includeList);
      return ds;

    } else {
      String dataProp = propertyItem.getEditorParameter();
      if (dataProp != null && !dataProp.equals("")) {

        String dataId = ((XuiElement) propertyItem.getOwerElement()).getProperyValue(dataProp);
        if (dataId != null && !dataId.equals("")) {
          XuiElement e = xuiElement.getXuiDataModel().findElementById(dataId);
          if (e != null) {
            return getDatasource(e.getPropertyItem("xid"));
          }
        }
      }
    }
    return new DataSet();
  }
示例#2
0
  @SuppressWarnings("unchecked")
  public void setPropertyItem(PropertyItem propertyItem) {
    dataXID = "";
    // ConsoleView.println("==222==EditorParameter:"+propertyItem.getEditorParameter());
    this.editorParameter =
        (Map<String, String>) JSONUtil.deserialize(propertyItem.getEditorParameter());
    this.propertyItem = propertyItem;
    XuiElement xuiElement = ((XuiElement) propertyItem.getOwerElement());
    if (null != this.editorParameter) {
      if (null != this.editorParameter.get("data")) {
        this.data = xuiElement.getProperyValue(this.editorParameter.get("data"));
        if (null != data && !"".equals(data)) {
          this.data = this.data.replaceAll("\\$model.", "").replaceAll("\\$parent.", "");
          foreachData = this.data;
        }
      }
      if (!"true".equalsIgnoreCase(this.editorParameter.get("isRelation"))) {
        this.isForeachRef = "foreachRef".equals(this.editorParameter.get("type"));
        this.hasLabel = !"false".equalsIgnoreCase(this.editorParameter.get("hasLabel"));
        this.isRelation = false;
      } else {
        this.hasLabel = false;
        this.isRelation = true;
      }
      this.syncData = "true".equalsIgnoreCase(this.editorParameter.get("syncData"));
    }
    findForeachContext(xuiElement);
    String className = propertyItem.getDialogDynData("class-name");
    String methodName = propertyItem.getDialogDynData("method");
    this.dataset =
        (DataSet)
            XuiDynJavaManager.executeMethod(
                propertyItem.getOwnerElementBasePath(),
                className,
                methodName,
                new Object[] {propertyItem});
    if (null != data && !"".equals(data)) {
      List<DataRecord> list = this.dataset.getData().get(0).getChildList();
      for (int i = list.size() - 1; i >= 0; i--) {
        if (!data.equals(list.get(i).getString("xid"))) list.remove(i);
      }
    }

    if (this.dataset != null) {
      this.dataset.addDataSetChangedListener(
          new DataSetChangedListener() {
            public void dataSetChanged(DataSetChangedEvent event) {
              if (event.getEventType() == DataSetChangedEvent.DATACHANGED
                  || event.getEventType() == DataSetChangedEvent.SELECTIONCHANGED) {
                String str =
                    !isRelation
                        ? (selectedRef
                            ? strategyRef.transformPropertyValue(dataset)
                            : strategyLabel.transformPropertyValue(dataset))
                        : strategyRelation.transformPropertyValue(dataset);
                if (!"UNCHANGED".equals(str)) {
                  if (str != null && !str.equals("") && isForeachRef) {
                    str = getForeachRef(str);
                  }
                  displayText.setText(str);
                }
              }
            }
          });
    }

    this.createContents();
  }