Ejemplo n.º 1
0
  public void removeSampleData(FXOMObject startObject) {
    final AbstractSampleData currentData = sampleDataMap.get(startObject);
    if (currentData != null) {
      currentData.removeFrom(startObject.getSceneGraphObject());
    }

    if (startObject instanceof FXOMInstance) {
      final FXOMInstance fxomInstance = (FXOMInstance) startObject;
      for (FXOMProperty p : fxomInstance.getProperties().values()) {
        if (p instanceof FXOMPropertyC) {
          final FXOMPropertyC pc = (FXOMPropertyC) p;
          for (FXOMObject v : pc.getValues()) {
            removeSampleData(v);
          }
        }
      }
    } else if (startObject instanceof FXOMCollection) {
      final FXOMCollection fxomCollection = (FXOMCollection) startObject;
      for (FXOMObject i : fxomCollection.getItems()) {
        removeSampleData(i);
      }
    }
  }
  @Override
  protected void updateFxomInstanceWithValue(FXOMInstance valueInstance, Object value) {
    final String fxConstant;

    if (value == TreeTableView.CONSTRAINED_RESIZE_POLICY) {
      fxConstant = "CONSTRAINED_RESIZE_POLICY"; // NOI18N
    } else if (value == TreeTableView.UNCONSTRAINED_RESIZE_POLICY) {
      fxConstant = "UNCONSTRAINED_RESIZE_POLICY"; // NOI18N
    } else {
      // Emergency code
      assert false;
      fxConstant = "CONSTRAINED_RESIZE_POLICY"; // NOI18N
    }

    valueInstance.setFxConstant(fxConstant);
  }
Ejemplo n.º 3
0
  public void assignSampleData(FXOMObject startObject) {
    assert startObject != null;

    final Object sceneGraphObject = startObject.getSceneGraphObject();
    final AbstractSampleData currentData = sampleDataMap.get(startObject);
    final AbstractSampleData newData;

    if (sceneGraphObject == null) {
      // startObject is unresolved
      newData = null;
    } else {
      final Class<?> sceneGraphClass = sceneGraphObject.getClass();
      if (sceneGraphClass == ChoiceBox.class) {
        final ChoiceBox<?> choiceBox = (ChoiceBox) sceneGraphObject;
        if (choiceBox.getItems().isEmpty()) {
          if (currentData instanceof ChoiceBoxSampleData) {
            newData = currentData;
          } else {
            newData = new ChoiceBoxSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == ComboBox.class) {
        final ComboBox<?> comboBox = (ComboBox) sceneGraphObject;
        if (comboBox.getItems().isEmpty()) {
          if (currentData instanceof ComboBoxSampleData) {
            newData = currentData;
          } else {
            newData = new ComboBoxSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == ListView.class) {
        final ListView<?> listView = (ListView) sceneGraphObject;
        if (listView.getItems().isEmpty()) {
          if (currentData instanceof ListViewSampleData) {
            newData = currentData;
          } else {
            newData = new ListViewSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == TreeView.class) {
        final TreeView<?> treeView = (TreeView) sceneGraphObject;
        if (treeView.getRoot() == null) {
          if (currentData instanceof TreeViewSampleData) {
            newData = currentData;
          } else {
            newData = new TreeViewSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == TableView.class) {
        final TableView<?> treeView = (TableView) sceneGraphObject;
        if (TableViewSampleData.canApplyTo(treeView)) {
          if (currentData instanceof TableViewSampleData) {
            newData = currentData;
          } else {
            newData = new TableViewSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == TreeTableView.class) {
        final TreeTableView<?> treeTableView = (TreeTableView) sceneGraphObject;
        if (treeTableView.getRoot() == null) {
          if (currentData instanceof TreeTableViewSampleData) {
            newData = currentData;
          } else {
            newData = new TreeTableViewSampleData();
          }
        } else {
          newData = null;
        }
      } else if (sceneGraphClass == PieChart.class) {
        final PieChart pieChart = (PieChart) sceneGraphObject;
        if (pieChart.getData().isEmpty()) {
          if (currentData instanceof PieChartSampleData) {
            newData = currentData;
          } else {
            newData = new PieChartSampleData();
          }
        } else {
          newData = null;
        }
      } else if (XYChartSampleData.isKnownXYChart(sceneGraphObject)) {
        final XYChart<?, ?> xyChart = (XYChart) sceneGraphObject;
        if (xyChart.getData().isEmpty()) {
          if (currentData instanceof XYChartSampleData) {
            newData = currentData;
          } else {
            newData = new XYChartSampleData();
          }
        } else {
          newData = null;
        }
      } else {
        newData = null;
      }
    }

    if (newData == null) {
      if (currentData != null) {
        sampleDataMap.remove(startObject);
      }
    } else {
      newData.applyTo(sceneGraphObject);
      sampleDataMap.put(startObject, newData);
    }

    if (startObject instanceof FXOMInstance) {
      final FXOMInstance fxomInstance = (FXOMInstance) startObject;
      for (FXOMProperty p : fxomInstance.getProperties().values()) {
        if (p instanceof FXOMPropertyC) {
          final FXOMPropertyC pc = (FXOMPropertyC) p;
          for (FXOMObject v : pc.getValues()) {
            assignSampleData(v);
          }
        }
      }
    } else if (startObject instanceof FXOMCollection) {
      final FXOMCollection fxomCollection = (FXOMCollection) startObject;
      for (FXOMObject i : fxomCollection.getItems()) {
        assignSampleData(i);
      }
    }
  }
 @Override
 public T makeValueFromFxomInstance(FXOMInstance valueFxomInstance) {
   return getValueClass().cast(valueFxomInstance.getSceneGraphObject());
 }