コード例 #1
0
  public final void setRepresentativeName() {
    if (property == null) {
      return;
    }
    PropertyValue value = property.get();

    if (value == null) {
      setText(property.name());
    } else {
      if (value instanceof FromConfigurationPropertyValue) {
        String name = "";
        FromConfigurationPropertyValue fcpv = (FromConfigurationPropertyValue) value;
        Property confName =
            fcpv.getValue().get("name") == null
                ? fcpv.getValue().get("Name")
                : fcpv.getValue().get("name");
        if (confName != null) {
          name = " [" + (confName.get() == null ? "" : confName.get().stringValue()) + "]";
        }
        setText(fcpv.getValue().registeredName() + name);
      } else {
        setText("??? SOMETHING ???");
      }
    }
  }
コード例 #2
0
  private void updateModelValue() {
    if (property.get() == null || !(property.get() instanceof FromConfigurationPropertyValue)) {
      try {
        String defaultName = (String) choiceBox.getItems().get(0);
        Configuration defaultValue = Registery.get().getConfiguration(defaultName);
        property.set(new FromConfigurationPropertyValue(defaultValue));
      } catch (Exception ex) {
        Logger.getLogger(ConfigurationPropertyEditor.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    FromConfigurationPropertyValue fcpv = (FromConfigurationPropertyValue) property.get();

    if (fcpv != null
        && fcpv.getValue()
            != null) { // in case property is a dummy (came from collection property editor)
      Class implementor = fcpv.getValue().configuredType();
      String className = Registery.get().getRegisteredClassName(implementor);
      Property temp = property;
      property = null;
      choiceBox.getSelectionModel().select(className);
      property = temp;
      if (parentCollection != null && choiceBox.getItems().size() <= 1) {
        setText(className);
      }
      confEditor.setModel(fcpv.getValue(), readOnly, filter);
    } else {
      choiceBox.getSelectionModel().select("NULL");
    }
  }
コード例 #3
0
  private void extractImplementors(Property property) {
    if (this.property == property) {
      return;
    }
    this.property = null;
    Class pType = property.typeInfo().getType();
    Collection<Class> implementors = Registery.get().getImplementors(pType);
    choiceBox.getItems().clear();
    if (parentCollection == null) {
      choiceBox.getItems().add("NULL");
    }

    implementors.forEach(
        (i) -> choiceBox.getItems().add(Registery.get().getRegisteredClassName(i)));

    if (!readOnly && (parentCollection == null || implementors.size() > 1)) {
      editorVBox.getChildren().add(implementorsBorderPane);
    }
  }
コード例 #4
0
  public ConfigurationPropertyEditor(ConfigurationEditor parent, Property collection) {
    this.parent = parent;
    this.parentCollection = collection;

    getStyleClass().add("configuration-property-editor");

    selected = new SimpleBooleanProperty(false);

    skinProperty()
        .addListener(
            (sp, o, n) -> {
              Node node = FXUtils.getTitledPaneTitleRegion(this);

              if (node != null) {
                node.addEventFilter(MouseEvent.MOUSE_RELEASED, eh -> eh.consume());
                node.addEventFilter(
                    MouseEvent.MOUSE_PRESSED,
                    eh -> {
                      eh.consume();
                      if (!selected.get()) {
                        selected.set(true);
                      } else {
                        setExpanded(!isExpanded());
                      }
                    });
              }
            });

    selected.addListener(
        (p, ov, nv) -> {
          if (nv && parent != null) {
            parent.select(this);
          }
        });

    infoContainer = new Label("");
    confEditor = new ConfigurationEditorInternal(parent, this);

    implementorsBorderPane = new BorderPane();
    implementorsBorderPane.getStyleClass().add("implementors");

    Label label = new Label("type :");
    label.setPadding(new Insets(0, LABEL_MARGING, 0, 0));
    BorderPane.setAlignment(label, Pos.CENTER_LEFT);
    implementorsBorderPane.setLeft(label);

    choiceBox = new ChoiceBox<>();
    //        choiceBox.setMaxWidth(Double.MAX_VALUE);
    choiceBox
        .valueProperty()
        .addListener(
            (ObservableValue<? extends String> p, String ov, String nv) -> {
              try {
                if (property != null) {
                  Configuration value = null;
                  if (!nv.equals("NULL")) {
                    value = Registery.get().getConfiguration(nv);
                  }
                  property.set(value == null ? null : new FromConfigurationPropertyValue(value));
                  setRepresentativeName();
                  confEditor.setModel(value, readOnly, filter);
                }
              } catch (ClassNotFoundException ex) {
                Logger.getLogger(ConfigurationPropertyEditor.class.getName())
                    .log(Level.SEVERE, null, ex);
              }
            });
    BorderPane.setAlignment(choiceBox, Pos.CENTER_LEFT);
    implementorsBorderPane.setCenter(choiceBox);

    editorVBox = new VBox();
    editorVBox.getChildren().addAll(implementorsBorderPane, confEditor);
    setContent(editorVBox);

    setGraphic(infoContainer);
    setExpanded(false);
  }