use of net.sourceforge.pmd.util.fxdesigner.util.PropertyDescriptorSpec in project pmd by pmd.
the class PropertyTableView method onAddPropertyClicked.
private void onAddPropertyClicked() {
PropertyDescriptorSpec spec = new PropertyDescriptorSpec();
this.getItems().add(spec);
popEditPropertyDialog(spec);
}
use of net.sourceforge.pmd.util.fxdesigner.util.PropertyDescriptorSpec in project pmd by pmd.
the class PropertyTableView method initialize.
private void initialize() {
this.getColumns().add(propertyNameColumn);
this.getColumns().add(propertyTypeColumn);
this.getColumns().add(propertyValueColumn);
this.setColumnResizePolicy(CONSTRAINED_RESIZE_POLICY);
this.setTableMenuButtonVisible(true);
ObservableList<PropertyTypeId> availableBuilders = FXCollections.observableArrayList(PropertyTypeId.typeIdsToConstants().values());
Collections.sort(availableBuilders);
StringConverter<PropertyTypeId> converter = DesignerUtil.stringConverter(PropertyTypeId::getStringId, PropertyTypeId::lookupMnemonic);
propertyTypeColumn.setCellFactory(ChoiceBoxTableCell.forTableColumn(converter, availableBuilders));
propertyNameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
propertyValueColumn.setCellValueFactory(new PropertyValueFactory<>("value"));
propertyTypeColumn.setCellValueFactory(new PropertyValueFactory<>("typeId"));
this.setPlaceholder(new Label("Right-click to add properties"));
MenuItem editItem = new MenuItem("Edit...");
editItem.setOnAction(e -> {
PropertyDescriptorSpec spec = this.getSelectionModel().getSelectedItem();
if (spec != null) {
popEditPropertyDialog(spec);
}
});
MenuItem removeItem = new MenuItem("Remove");
removeItem.setOnAction(e -> {
PropertyDescriptorSpec selected = this.getSelectionModel().getSelectedItem();
if (selected != null) {
this.getItems().remove(selected);
}
});
MenuItem addItem = new MenuItem("Add property...");
addItem.setOnAction(e -> onAddPropertyClicked());
ContextMenu fullMenu = new ContextMenu();
fullMenu.getItems().addAll(editItem, removeItem, new SeparatorMenuItem(), addItem);
// Reduced context menu, for when there are no properties or none is selected
MenuItem addItem2 = new MenuItem("Add property...");
addItem2.setOnAction(e -> onAddPropertyClicked());
ContextMenu smallMenu = new ContextMenu();
smallMenu.getItems().add(addItem2);
this.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> {
if (t.getButton() == MouseButton.SECONDARY || t.getButton() == MouseButton.PRIMARY && t.getClickCount() > 1) {
if (this.getSelectionModel().getSelectedItem() != null) {
fullMenu.show(this, t.getScreenX(), t.getScreenY());
} else {
smallMenu.show(this, t.getScreenX(), t.getScreenY());
}
}
});
propertyNameColumn.setCellFactory(TextFieldTableCell.forTableColumn());
propertyValueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
this.setEditable(false);
}
Aggregations