use of au.gov.asd.tac.constellation.views.attributeeditor.editors.ListSelectionEditorFactory.ListSelectionEditor in project constellation by constellation-app.
the class AttributeEditorPanel method editKeysAction.
private void editKeysAction(final GraphElementType elementType) {
final List<String> currentKeyAttributes = new ArrayList<>();
final List<String> allAttributes = new ArrayList<>();
final Graph graph = GraphManager.getDefault().getActiveGraph();
if (graph != null) {
final ReadableGraph rg = graph.getReadableGraph();
try {
int[] keys = rg.getPrimaryKey(elementType);
for (int key : keys) {
currentKeyAttributes.add(rg.getAttributeName(key));
}
for (int i = 0; i < rg.getAttributeCount(elementType); i++) {
allAttributes.add(rg.getAttributeName(rg.getAttribute(elementType, i)));
}
} finally {
rg.release();
}
final EditOperation editOperation = new PrimaryKeyEditOperation(elementType);
final DefaultGetter<List<String>> defaultGetter = new PrimaryKeyDefaultGetter(elementType);
final AbstractEditor<List<String>> editor = LIST_SELECTION_EDITOR_FACTORY.createEditor(editOperation, defaultGetter, String.format("Edit primary key for %ss", elementType.getShortLabel()), currentKeyAttributes);
((ListSelectionEditor) editor).setPossibleItems(allAttributes);
final AttributeEditorDialog dialog = new AttributeEditorDialog(true, editor);
dialog.showDialog();
}
}
Aggregations