Esempio n. 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();
  }
Esempio n. 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();
  }
Esempio n. 3
0
  /** 调用js方法设置数据* */
  @SuppressWarnings("unchecked")
  private void init() {
    String currentValue = this.currentProp.getValue();
    String[] valueItems = currentValue.split(" ");
    Set<String> set = new HashSet<String>();
    for (String valueItem : valueItems) {
      set.add(valueItem);
    }
    Element staticData = currentProp.getDlgEditorConfig().element("static-data");
    StringBuffer sbf = new StringBuffer();
    if (staticData != null) {
      List<Element> eList = (currentProp.getDlgEditorConfig().element("static-data")).elements();
      for (Element e : eList) {
        List<Element> itemList = e.elements();
        StringBuffer itemsbf = new StringBuffer();
        boolean isSelected = set.contains(e.attributeValue("name"));
        for (Element item : itemList) {
          String selected = "";
          String name = item.attributeValue("name");
          if (isSelected && set.contains(name)) {
            selected = "checked:'checked',";
            set.remove(name);
          }
          itemsbf.append(
              ",{"
                  + selected
                  + "name:'"
                  + name
                  + "',label:'"
                  + item.attributeValue("label")
                  + "',isDefault:'"
                  + item.attributeValue("is-default")
                  + "'}");
        }
        String selected = "";
        String name = e.attributeValue("name");
        if (set.contains(name)) {
          selected = "checked:'checked',";
          set.remove(name);
        }
        sbf.append(
            ",{"
                + selected
                + "name:'"
                + name
                + "',label:'"
                + e.attributeValue("label")
                + "',items:["
                + itemsbf.toString()
                + "]}");
      }
    }
    Element e =
        ((XuiDataModel) this.currentProp.getOwerElement().getDataModel())
            .getConfig()
            .getCommonEditor("classList"); // 公共class
    String value = e.element("static-data").attributeValue("value");
    if (value != null) {
      String[] items = value.split(",");
      for (String item : items) {
        set.remove(item.split(":")[0]);
      }
    }

    String cusValue = "";
    for (String s : set) {
      cusValue += " " + s;
    }

    browser.execute(
        "init('"
            + currentValue
            + "',\"["
            + sbf.toString()
            + "]\",'"
            + cusValue.trim()
            + "','"
            + value
            + "');");
  }