use of org.csstudio.display.pace.model.Instance in project phoebus by ControlSystemStudio.
the class PACETableCell method updateItem.
@Override
public void updateItem(final String item, final boolean empty) {
super.updateItem(item, empty);
if (empty || item == null || getTableRow() == null) {
cell = null;
setBorder(null);
setTooltip(null);
} else {
final Instance instance = getTableRow().getItem();
final int col = getTableView().getColumns().indexOf(getTableColumn());
// Col 0 lists "System", no Cell
if (col > 0) {
cell = instance.getCell(col - 1);
setBorder(cell.isEdited() ? EDITED : null);
setTooltip(tooltip);
}
}
}
use of org.csstudio.display.pace.model.Instance in project phoebus by ControlSystemStudio.
the class GUI method createContextMenu.
private void createContextMenu() {
// Create menu with dummy entry (otherwise it won't show up)
final ContextMenu menu = new ContextMenu(new MenuItem());
// Update menu based on selection
menu.setOnShowing(event -> {
// Get selected Cells and their PV names
final List<Cell> cells = new ArrayList<>();
final List<ProcessVariable> pvnames = new ArrayList<>();
final List<Instance> rows = table.getItems();
for (TablePosition<?, ?> sel : table.getSelectionModel().getSelectedCells()) {
final Cell cell = rows.get(sel.getRow()).getCell(sel.getColumn() - 1);
cells.add(cell);
pvnames.add(new ProcessVariable(cell.getName()));
}
// Update menu
final ObservableList<MenuItem> items = menu.getItems();
items.clear();
items.add(new RestoreCellValues(cells));
items.add(new SetCellValues(table, cells));
// Add PV name entries
if (pvnames.size() > 0) {
items.add(new SeparatorMenuItem());
SelectionService.getInstance().setSelection("AlarmUI", pvnames);
ContextMenuHelper.addSupportedEntries(table, menu);
}
});
table.setContextMenu(menu);
}
use of org.csstudio.display.pace.model.Instance in project phoebus by ControlSystemStudio.
the class PACEInstance method createElogText.
/**
* Create the 'body', the main text of the ELog entry which
* lists all the changes.
* @return ELog text
*/
private String createElogText() {
final StringBuilder body = new StringBuilder(Messages.SaveIntro);
// While changes to most cells are meant to be logged,
// some cells' "main" PV might actually be the "comment" meta-PV
// of another cell.
// In that case, the comment should be logged with the "main" cell,
// and the individual logging of the comment cell should be suppressed.
// Map of 'main' cells to 'comment' cells
final Map<Cell, Cell> comment_cell_map = new HashMap<>();
// Locate secondary comment cells
final int columns = model.getColumns().size();
for (Instance instance : model.getInstances()) {
for (int c = 0; c < columns; ++c) {
final Cell main_cell = instance.getCell(c);
final String comment_pv_name = main_cell.getCommentPVName();
if (!main_cell.isEdited() || comment_pv_name.isEmpty())
continue;
for (int d = 0; d < columns; ++d) {
final Cell search_cell = instance.getCell(d);
if (search_cell.getName().equals(comment_pv_name)) {
comment_cell_map.put(main_cell, search_cell);
break;
}
}
}
}
// Loop over all cells to log changes
for (Instance instance : model.getInstances()) {
// edited. If they have add them to the elog message.
for (int c = 0; c < columns; ++c) {
final Cell cell = instance.getCell(c);
if (!cell.isEdited())
continue;
// the associated "main" cell
if (comment_cell_map.containsValue(cell))
continue;
body.append(MessageFormat.format(Messages.SavePVInfoFmt, cell.getName(), cell.getCurrentValue(), cell.getUserValue()));
// If the cell has comments, find the comment pv and log it's changed
// value with the limit change log report.
final Cell comment_cell = comment_cell_map.get(cell);
if (comment_cell != null)
body.append(MessageFormat.format(Messages.SaveCommentInfoFmt, comment_cell.getObservable().getValue()));
}
}
return body.toString();
}
use of org.csstudio.display.pace.model.Instance in project phoebus by ControlSystemStudio.
the class GUI method createTable.
private TableView<Instance> createTable() {
final TableView<Instance> table = new TableView<>(FXCollections.observableList(model.getInstances()));
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.getSelectionModel().setCellSelectionEnabled(true);
table.setEditable(true);
TableColumn<Instance, String> col = new TableColumn<>(Messages.SystemColumn);
col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName()));
table.getColumns().add(col);
int col_index = 0;
for (Column column : model.getColumns()) {
final int the_col_index = col_index;
col = new TableColumn<>(column.getName());
col.setCellFactory(info -> new PACETableCell());
col.setCellValueFactory(cell -> cell.getValue().getCell(the_col_index).getObservable());
table.getColumns().add(col);
if (column.isReadonly())
col.setEditable(false);
else {
col.setOnEditCommit(event -> {
event.getRowValue().getCell(the_col_index).setUserValue(event.getNewValue());
final int row = event.getTablePosition().getRow();
// Start to edit same column in next row
if (row < table.getItems().size() - 1)
Platform.runLater(() -> table.edit(row + 1, event.getTableColumn()));
});
}
++col_index;
}
return table;
}
Aggregations