public boolean build() {
    scrollPaneTable.clearChildren();

    if (properties.getProxies().first() instanceof GroupEntityProxy) {
      return false;
    }

    boolean atLeastOneComponentAdded = false;

    for (Class<? extends Component> clazz : componentClasses) {
      if (EntityUtils.isComponentCommon(clazz, properties.getProxies()) == false) {
        VisTextButton button = new VisTextButton(clazz.getSimpleName(), buttonStyle);
        button.setFocusBorderEnabled(false);
        scrollPaneTable.add(button).expandX().fillX().row();

        button.addListener(
            new VisChangeListener(
                (event, actor) -> {
                  listener.selected(clazz);
                  remove();
                }));

        atLeastOneComponentAdded = true;
      }
    }

    invalidateHierarchy();

    return atLeastOneComponentAdded;
  }
Exemple #2
0
  public List<VisTextButton> getButtons(Class<? extends Annotation> cls) {
    List<VisTextButton> btnList = new ArrayList<>();
    Reflections r = new Reflections("net.ncguy.impossible.graph.nodes");

    Set<Class<?>> clsSet = r.getTypesAnnotatedWith(cls);
    r.save("nodeBtns.bin");
    System.out.println("gfdsgfd");
    for (Class<?> c : clsSet) {
      VisTextButton btn = new VisTextButton("Add " + TextUtils.formatString(c.getSimpleName()));
      btn.addListener(
          new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
              super.clicked(event, x, y);
              try {
                BaseNode node = (BaseNode) c.getConstructor(GraphBase.class).newInstance(graphBase);
                addNode(node);
              } catch (Exception e) {
                e.printStackTrace();
              }
              graphBase.rebuildDnD();
            }
          });
      btnList.add(btn);
    }
    return btnList;
  }