Пример #1
0
 public static CatInfo fromPort(Port port) {
   CatInfo info = new CatInfo();
   info.name = port.name;
   info.value = port.getValue();
   info.type = port.getType();
   info.readOnly = false;
   info.leaf = true;
   return info;
 }
Пример #2
0
  public static CatInfo fromCat(Cat cat) throws NoSuchMethodException {

    CatInfo[] insChildren = new CatInfo[cat.getIns().size()];
    for (int i = 0; i < cat.getIns().size(); i++) {
      insChildren[i] = fromPort(cat.getIns().get(i));
    }

    CatInfo[] outsChildren = new CatInfo[cat.getIns().size()];
    for (int i = 0; i < cat.getIns().size(); i++) {
      outsChildren[i] = fromPort(cat.getIns().get(i));
    }

    CatInfo[] gensChildren = new CatInfo[cat.getIns().size()];
    for (int i = 0; i < cat.getIns().size(); i++) {
      gensChildren[i] = fromPort(cat.getIns().get(i));
    }

    CatInfo insInfo = new CatInfo();
    insInfo.name = "INs";
    insInfo.children = insChildren;

    CatInfo outsInfo = new CatInfo();
    outsInfo.name = "OUTs";
    outsInfo.children = outsChildren;

    CatInfo gensInfo = new CatInfo();
    gensInfo.name = "GENs";
    gensInfo.children = gensChildren;

    CatInfo info = new CatInfo();
    info.name = "Cat01";
    info.value = null;
    info.type = null;
    info.readOnly = true;
    info.leaf = false;
    info.children = new CatInfo[] {insInfo, outsInfo, gensInfo};

    //		ObjectConstant<CatInfo> catInfoP=ObjectConstant.valueOf(info);

    //		CatInfoTreeItem treeItem=new CatInfoTreeItem();
    //		treeItem.valueProperty().addListener(new CatInfoChangeListener());
    //		treeItem.addEventHandler(TreeItem.valueChangedEvent(), new
    // EventHandler<TreeModificationEvent<CatInfo>>() {
    //			@Override
    //			public void handle(TreeModificationEvent<CatInfo> event) {
    //				CatInfo info=event.getNewValue();
    //				TreeItem<CatInfo> item=event.getSource();
    //				for(CatInfo child:info.children){
    //					TreeItem<CatInfo> childTreeItem=new TreeItem<CatInfo>();
    //					ObjectConstant<CatInfo> catInfoX=ObjectConstant.valueOf(child);
    //					childTreeItem.valueProperty().bind(catInfoX);
    //					item.getChildren().add(childTreeItem);
    //				}
    //			}
    //		});
    //		treeItem.valueProperty().bind(catInfoP);
    //		treeItem.setValue(info);

    //		TreeItem<CatInfo> treeItem=new TreeItem<CatInfo>(){
    //			@Override
    //			public boolean isLeaf() {
    //				System.out.println(getValue().leaf);
    //				return getValue().leaf;
    //			}
    //
    //		};

    return info;
  }