Search in sources :

Example 51 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class ConversationState method setSenderAttributesToKeys.

public void setSenderAttributesToKeys(GraphReadMethods graph) {
    senderAttributes.clear();
    for (int keyAttributeId : graph.getPrimaryKey(GraphElementType.VERTEX)) {
        Attribute keyAttribute = new GraphAttribute(graph, keyAttributeId);
        senderAttributes.add(keyAttribute.getName());
    }
}
Also used : GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute)

Example 52 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class FindCriteriaPanel method updateOperators.

/**
 * Sets the relevant operators to this form.
 *
 * @param isNew <code>true</code> to get new operator list,
 * <code>false</code> to use existing.
 */
public void updateOperators(final boolean isNew) {
    if (cmbAttributes.getSelectedItem() instanceof Attribute) {
        final Attribute attr = localState.getAttribute();
        final FindTypeOperators.Type type = FindTypeOperators.Type.getTypeEnum(attr.getAttributeType());
        localState.setType(type);
        final ArrayList<Operator> operators = new ArrayList<>();
        for (final Operator currentItem : type.getOperatorSet()) {
            operators.add(currentItem);
        }
        cmbOperators.setModel(new OperatorComboBoxModel(operators));
        // Determine if this is a new find, or we are restoring from a previous state:
        if (isNew) {
            localState.setOperator((Operator) cmbOperators.getSelectedItem());
        } else {
            cmbOperators.setSelectedItem(localState.getOperator());
        }
        localState.setOperator((Operator) cmbOperators.getSelectedItem());
    } else {
        cmbOperators.setModel(new DefaultComboBoxModel(new String[] { Bundle.No_Operators() }));
        localState.setType(null);
    }
    updateArguments();
}
Also used : Operator(au.gov.asd.tac.constellation.views.find.advanced.FindTypeOperators.Operator) Attribute(au.gov.asd.tac.constellation.graph.Attribute) FindTypeOperators(au.gov.asd.tac.constellation.views.find.advanced.FindTypeOperators) ArrayList(java.util.ArrayList) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel)

Example 53 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class ReplaceTab method updateBasicReplaceParamters.

/**
 * Reads the find text, element type, attributes selected, standard text
 * selection, regEx selection, ignore case selection, exact match selected
 * and search all graphs selection and passes them to the controller to
 * create a BasicFindReplaceParameter
 */
public void updateBasicReplaceParamters() {
    // get the currently selected graphElementType
    final GraphElementType elementType = GraphElementType.getValue(lookForChoiceBox.getSelectionModel().getSelectedItem());
    // get the matching attributeList
    final List<Attribute> attributeList = new ArrayList<>(getMatchingAttributeList(elementType));
    boolean replaceIn = false;
    // determine what currentSelectionChoiceBox option is selected
    if (currentSelectionChoiceBox.getSelectionModel().getSelectedIndex() == 1) {
        replaceIn = true;
    }
    // Create the paramters with the current UI selections
    final BasicFindReplaceParameters parameters = new BasicFindReplaceParameters(findTextField.getText(), replaceTextField.getText(), elementType, attributeList, standardRadioBtn.isSelected(), regExBtn.isSelected(), ignoreCaseCB.isSelected(), exactMatchCB.isSelected(), false, false, false, replaceIn, searchAllGraphs.isSelected());
    // Update the basic replace paramters with the newly created parameter
    FindViewController.getDefault().updateBasicReplaceParameters(parameters);
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Example 54 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class FindViewController method populateAttributes.

/**
 * This loops through all the attribute lists in each open graph adding all
 * unique attributes to the UI attribute list if they are of type string
 *
 * @param type the type of graph element
 * @param attributes the list of attributes
 * @param attributeModificationCounter
 */
public List<String> populateAttributes(final GraphElementType type, final List<Attribute> attributes, final long attributeModificationCounter) {
    /**
     * Clear the attributes, create a attributeList to contain all of the
     * string attributes that are found, and create allAttributes to contain
     * a list of allAttributes regardless of type.
     */
    attributes.clear();
    final List<String> attributeList = new ArrayList<>();
    final List<Attribute> allAttributes = new ArrayList<>();
    // loop through all open graphs
    for (final Graph graph : GraphManager.getDefault().getAllGraphs().values()) {
        // Call the plugin that retrieves all current attributes on the graph
        final GraphAttributePlugin attrPlugin = new GraphAttributePlugin(type, allAttributes, attributeModificationCounter);
        final Future<?> future = PluginExecution.withPlugin(attrPlugin).interactively(true).executeLater(graph);
        // Wait for the search to find its results:
        try {
            future.get();
        } catch (final InterruptedException ex) {
            LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
            Thread.currentThread().interrupt();
        } catch (final ExecutionException ex) {
            LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        }
        // Retrieve a list of all String attributes
        if (attrPlugin.getAttributeModificationCounter() != attributeModificationCounter) {
            // Add all existing attributes to allAttributes
            allAttributes.addAll(attrPlugin.getAttributes());
            // loop through looking for all attributes of type string
            for (final Attribute a : allAttributes) {
                // and attributeList
                if (("string").equals(a.getAttributeType())) {
                    attributes.add(a);
                    attributeList.add(a.getName());
                }
            }
        }
    }
    // Ensure only unique attributes are added to attributes.
    // There would be duplicates in searching multiple graphs
    final Set<Attribute> attributeSet = new LinkedHashSet<>();
    attributeSet.addAll(attributes);
    attributes.clear();
    attributes.addAll(attributeSet);
    // Ensure only unique attribute names are added to attributes.
    // There would be duplicates in searching multiple graphs
    final Set<String> set = new LinkedHashSet<>();
    set.addAll(attributeList);
    attributeList.clear();
    attributeList.addAll(set);
    return attributeList;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttributePlugin(au.gov.asd.tac.constellation.views.find2.plugins.GraphAttributePlugin) ArrayList(java.util.ArrayList) Graph(au.gov.asd.tac.constellation.graph.Graph) ExecutionException(java.util.concurrent.ExecutionException)

Example 55 with Attribute

use of au.gov.asd.tac.constellation.graph.Attribute in project constellation by constellation-app.

the class AdvancedFindTab method changeCriteriaPane.

/**
 * This is called when the user changes the selected attribute type of a
 * specific criteria pane. For example if the user changes the attribute
 * from "Label" to "Color".
 *
 * @param criteriaPane
 * @param type
 * @param attributeName
 */
public void changeCriteriaPane(final AdvancedCriteriaBorderPane criteriaPane, final GraphElementType type, final String attributeName, final boolean updateUI) {
    if (!updateUI) {
        final List<AdvancedCriteriaBorderPane> criteriaList = getCorrespondingCriteriaList(type);
        final GridPane gridPane = getCorrespondingGridPane(type);
        // For each of the panes in the criteriaList.
        for (final AdvancedCriteriaBorderPane pane : criteriaList) {
            // list of attributes it contains.
            if (criteriaPane == pane) {
                final int paneIndex = criteriaList.indexOf(pane);
                final List<Attribute> attributeList = new ArrayList<>(pane.getAttributesList());
                // delete the pane
                deleteCriteriaPane(pane, type, paneIndex);
                // for each of the attributes within the attribute list
                for (final Attribute a : attributeList) {
                    // if the new attribute requested == a.getName
                    if (attributeName == a.getName()) {
                        // Add a new CriteriaPane of the attributType passed
                        // at the index the pane was originaly on.
                        // Select the attributeName of the type passed
                        criteriaList.add(paneIndex, getNewCriteriaPanel(a.getAttributeType(), attributeName, type));
                        gridPane.add(criteriaList.get(paneIndex), 0, paneIndex);
                        pane.getTypeChoiceBox().getSelectionModel().select(attributeName);
                        GridPane.setHgrow(criteriaList.get(paneIndex), Priority.ALWAYS);
                        // update the colours of the list to match
                        updateGridColours(type);
                        return;
                    }
                }
            }
        }
    }
}
Also used : GridPane(javafx.scene.layout.GridPane) Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) AdvancedCriteriaBorderPane(au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)

Aggregations

Attribute (au.gov.asd.tac.constellation.graph.Attribute)94 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)55 ArrayList (java.util.ArrayList)30 Test (org.testng.annotations.Test)23 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)18 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)15 TableViewState (au.gov.asd.tac.constellation.views.tableview.state.TableViewState)13 Graph (au.gov.asd.tac.constellation.graph.Graph)12 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObservableList (javafx.collections.ObservableList)8 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)7 Column (au.gov.asd.tac.constellation.views.tableview.api.Column)7 TableColumn (javafx.scene.control.TableColumn)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)5 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)5 Tuple (au.gov.asd.tac.constellation.utilities.datastructure.Tuple)5 JsonFactory (com.fasterxml.jackson.core.JsonFactory)5