Пример #1
0
  private void initForChainRelation() {
    this.removeAllChildren();

    final ChainRelation chainRelation = (ChainRelation) this.relation;

    final TextElement owner = new TextElement("Owner " + chainRelation.getOwner().getId());

    final LabeledComboBox<LayoutConstant> orientationInput =
        new LabeledComboBox("Orientation", this.contentPanel);
    orientationInput.getComboBox().comboBox.addItem(LayoutConstant.ORIENTATION_HORIZONTAL);
    orientationInput.getComboBox().comboBox.addItem(LayoutConstant.ORIENTATION_VERTICAL);
    orientationInput.getComboBox().comboBox.setSelectedItem(chainRelation.getOrientation());

    final LabeledComboBox<LayoutConstant> alignmentInput =
        new LabeledComboBox("Orientation", this.contentPanel);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_NONE);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MIN);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MIDDLE);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MAX);
    alignmentInput.getComboBox().comboBox.setSelectedItem(chainRelation.getAlignment());

    final LabeledInputField spacingInput = new LabeledInputField("Spacing", this.contentPanel);
    spacingInput.getInput().textField.setText(chainRelation.getSpacing() + "");

    Button saveButton = new Button("save");
    saveButton.addAction(
        new ButtonAction() {
          @Override
          public void action() {
            chainRelation.setOrientation(
                (LayoutConstant) orientationInput.getComboBox().comboBox.getSelectedItem());
            chainRelation.setSpacing(
                Double.parseDouble(spacingInput.getInput().textField.getText()));
            chainRelation.setAlignment(
                (LayoutConstant) alignmentInput.getComboBox().comboBox.getSelectedItem());

            editor.relationArea.populateContent(relation.getOwner());
          }
        });

    saveButton.addAction(new RunObservedLayoutAction(this.foreignRoot));

    this.addChild(owner);
    this.addChild(orientationInput);
    this.addChild(alignmentInput);
    this.addChild(spacingInput);
    this.addChild(saveButton);
  }
Пример #2
0
  private void initForSimpleRelation() {
    this.removeAllChildren();

    final SimpleRelation simpleRelation = (SimpleRelation) this.relation;

    final LabeledComboBox<Element> minElementInput =
        new LabeledComboBox<>("Min Element", this.contentPanel);

    for (Element element : simpleRelation.getOwner().getChildren()) {
      minElementInput.getComboBox().comboBox.addItem(element);
    }

    minElementInput.getComboBox().comboBox.addItem(simpleRelation.getOwner());
    minElementInput.getComboBox().comboBox.setSelectedItem(simpleRelation.getMinElement());

    final LabeledComboBox<Element> maxElementInput =
        new LabeledComboBox<>("Max Element", this.contentPanel);

    for (Element element : simpleRelation.getOwner().getChildren()) {
      maxElementInput.getComboBox().comboBox.addItem(element);
    }

    maxElementInput.getComboBox().comboBox.addItem(simpleRelation.getOwner());
    maxElementInput.getComboBox().comboBox.setSelectedItem(simpleRelation.getMaxElement());

    final LabeledComboBox<LayoutConstant> orientationInput =
        new LabeledComboBox("Orientation", this.contentPanel);
    orientationInput.getComboBox().comboBox.addItem(LayoutConstant.ORIENTATION_HORIZONTAL);
    orientationInput.getComboBox().comboBox.addItem(LayoutConstant.ORIENTATION_VERTICAL);
    orientationInput.getComboBox().comboBox.setSelectedItem(simpleRelation.getOrientation());

    final LabeledComboBox<LayoutConstant> alignmentInput =
        new LabeledComboBox("Alignment", this.contentPanel);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_NONE);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MIN);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MIDDLE);
    alignmentInput.getComboBox().comboBox.addItem(LayoutConstant.ALIGNMENT_MAX);
    alignmentInput.getComboBox().comboBox.setSelectedItem(simpleRelation.getAlignment());

    final LabeledInputField weightInput = new LabeledInputField("Weight", this.contentPanel);
    weightInput.getInput().textField.setText(simpleRelation.getWeight() + "");

    Button saveButton = new Button("save");
    saveButton.addAction(
        new ButtonAction() {
          @Override
          public void action() {
            simpleRelation.setOrientation(
                (LayoutConstant) orientationInput.getComboBox().comboBox.getSelectedItem());
            simpleRelation.setWeight(
                Double.parseDouble(weightInput.getInput().textField.getText()));
            simpleRelation.setMinElement(
                (Element) minElementInput.getComboBox().comboBox.getSelectedItem());
            simpleRelation.setMaxElement(
                (Element) maxElementInput.getComboBox().comboBox.getSelectedItem());
            simpleRelation.setAlignment(
                (LayoutConstant) alignmentInput.getComboBox().comboBox.getSelectedItem());

            editor.relationArea.populateContent(relation.getOwner());
          }
        });

    saveButton.addAction(new RunObservedLayoutAction(this.foreignRoot));

    this.addChild(minElementInput);
    this.addChild(maxElementInput);
    this.addChild(orientationInput);
    this.addChild(alignmentInput);
    this.addChild(weightInput);
    this.addChild(saveButton);
  }