Search in sources :

Example 1 with ListSelectionEditor

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();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ListSelectionEditor(au.gov.asd.tac.constellation.views.attributeeditor.editors.ListSelectionEditorFactory.ListSelectionEditor) ArrayList(java.util.ArrayList) EditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.EditOperation) ModifyAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.ModifyAttributeEditOperation) CreateAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.CreateAttributeEditOperation) AttributeValueEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.AttributeValueEditOperation) PrimaryKeyEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyEditOperation) PrimaryKeyDefaultGetter(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyDefaultGetter) Graph(au.gov.asd.tac.constellation.graph.Graph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) PrimaryKeyEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyEditOperation) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Graph (au.gov.asd.tac.constellation.graph.Graph)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 ListSelectionEditor (au.gov.asd.tac.constellation.views.attributeeditor.editors.ListSelectionEditorFactory.ListSelectionEditor)1 AttributeValueEditOperation (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.AttributeValueEditOperation)1 CreateAttributeEditOperation (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.CreateAttributeEditOperation)1 EditOperation (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.EditOperation)1 ModifyAttributeEditOperation (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.ModifyAttributeEditOperation)1 PrimaryKeyDefaultGetter (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyDefaultGetter)1 PrimaryKeyEditOperation (au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyEditOperation)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ObservableList (javafx.collections.ObservableList)1