use of au.gov.asd.tac.constellation.views.attributeeditor.editors.AbstractEditorFactory in project constellation by constellation-app.
the class AttributeEditorPanel method createColourMenuItem.
private MenuItem createColourMenuItem(final String itemName, final String correspondingPreference, final Color color) {
final HBox schemaMenuNode = new HBox(CELL_ITEM_SPACING);
final MenuItem schemaMenuItem = new MenuItem(null, schemaMenuNode);
final Rectangle schemaMenuRect = new Rectangle(20, 20);
final Text schemaMenuText = new Text(itemName);
schemaMenuText.setStyle("-fx-fill: white; -fx-font-smoothing-type:lcd;");
schemaMenuNode.getChildren().addAll(schemaMenuRect, schemaMenuText);
schemaMenuRect.setFill(color);
schemaMenuRect.setStroke(Color.LIGHTGREY);
schemaMenuItem.setOnAction(e -> {
final EditOperation editOperation = value -> prefs.put(correspondingPreference, ((ConstellationColor) value).getHtmlColor());
// return type of createEditor will actually be AbstractEditor<ConstellationColor>
@SuppressWarnings("unchecked") final AbstractEditor<ConstellationColor> editor = ((AbstractEditorFactory<ConstellationColor>) AttributeValueEditorFactory.getEditFactory(ColorAttributeDescription.ATTRIBUTE_NAME)).createEditor(editOperation, String.format("for %s", itemName), ConstellationColor.fromFXColor(color));
final AttributeEditorDialog dialog = new AttributeEditorDialog(false, editor);
dialog.showDialog();
});
return schemaMenuItem;
}
Aggregations