Search in sources :

Example 56 with Attribute

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

the class BasicFindTab method populateAttributes.

/**
 * Populates the inAttributeMenu with all relevant String attributes based
 * on the type of graph element selected in the lookForChoiceBox
 *
 * @param type
 */
public void populateAttributes(final GraphElementType type) {
    // retrieve a list of all current attributes that exist in all active
    // graphs that are of type string
    final List<String> attributeList = FindViewController.getDefault().populateAttributes(type, attributes, ATTRIBUTE_MODIFICATION_COUNTER);
    /**
     * Check if the current thread is the main application thread. If it is
     * run the logic. If it isnt set up a countdown latch to ensure it this
     * process is completed.
     */
    if (Platform.isFxApplicationThread()) {
        // clear all current checks and all items in the inAttributeMenu
        inAttributesMenu.getCheckModel().clearChecks();
        inAttributesMenu.getItems().clear();
        // Get the matching selected attribute list
        final List<Attribute> selected = getMatchingAttributeList(type);
        // loop through all attributes in the complete attribute list
        for (final String attribute : attributeList) {
            // add all attributes to the inAttributeMenu
            inAttributesMenu.getItems().add(attribute);
            // selected attributes name matches the current attribute
            for (int i = 0; i <= selected.size() - 1; i++) {
                if (selected.get(i).getName() == attribute) {
                    inAttributesMenu.getCheckModel().check(attribute);
                }
            }
        }
    } else {
        final CountDownLatch cdl = new CountDownLatch(1);
        Platform.runLater(() -> {
            inAttributesMenu.getCheckModel().clearChecks();
            inAttributesMenu.getItems().clear();
            final List<Attribute> selected = getMatchingAttributeList(type);
            for (final String attribute : attributeList) {
                inAttributesMenu.getItems().add(attribute);
                for (int i = 0; i <= selected.size() - 1; i++) {
                    if (selected.get(i).getName() == attribute) {
                        inAttributesMenu.getCheckModel().check(attribute);
                    }
                }
            }
            cdl.countDown();
        });
        try {
            cdl.await();
        } catch (final InterruptedException ex) {
            LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
            Thread.currentThread().interrupt();
        }
    }
    // update the current parameters to be current
    updateBasicFindParamters();
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 57 with Attribute

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

the class BasicFindTab method updateBasicFindParamters.

/**
 * 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 updateBasicFindParamters() {
    final GraphElementType elementType = GraphElementType.getValue(lookForChoiceBox.getSelectionModel().getSelectedItem());
    final List<Attribute> attributeList = new ArrayList<>(getMatchingAttributeList(elementType));
    boolean addTo = false;
    boolean removeFrom = false;
    boolean findIn = false;
    // to true
    switch(currentSelectionChoiceBox.getSelectionModel().getSelectedIndex()) {
        case 0:
            break;
        case 1:
            addTo = true;
            break;
        case 2:
            findIn = true;
            break;
        case 3:
            removeFrom = true;
            break;
        default:
            break;
    }
    // creates a new basicFindReplaceParameter with the currently selected
    // UI parameters
    final BasicFindReplaceParameters parameters = new BasicFindReplaceParameters(findTextField.getText(), "", elementType, attributeList, standardRadioBtn.isSelected(), regExBtn.isSelected(), ignoreCaseCB.isSelected(), exactMatchCB.isSelected(), findIn, addTo, removeFrom, false, searchAllGraphs.isSelected());
    FindViewController.getDefault().updateBasicFindParameters(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 58 with Attribute

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

the class ReplacePanel method updateComboBox.

// End of variables declaration//GEN-END:variables
private void updateComboBox() {
    dropDownPanel.removeAll();
    resetComboBox();
    selectAll.setEnabled(attributes.size() > 0);
    for (Attribute a : attributes) {
        JCheckBox attrCheckbox = new JCheckBox(a.getName());
        attrCheckbox.addActionListener(e -> {
            JCheckBox temp = (JCheckBox) e.getSource();
            checkBoxValueChanged(temp.getText(), temp.isSelected());
        });
        dropDownPanel.add(attrCheckbox);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) Attribute(au.gov.asd.tac.constellation.graph.Attribute)

Example 59 with Attribute

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

the class GraphAttributePlugin method retrieveAttributes.

/**
 * Helper method that performs the attribute query operation.
 * <p>
 * Sets any found attributes to an internal variable which can be later
 * returned through use of the <code>getAttributes()</code> method.
 *
 * @param graph The graph to retrieve attributes for.
 *
 * @see Graph
 */
private void retrieveAttributes(final GraphReadMethods graph) {
    final long amc = graph.getAttributeModificationCounter();
    attributes.clear();
    final int attrCount = graph.getAttributeCount(type);
    for (int position = 0; position < attrCount; position++) {
        final int attr = graph.getAttribute(type, position);
        final Attribute candidate = new GraphAttribute(graph, attr);
        attributes.add(candidate);
    }
    attributeModificationCounter = amc;
}
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 60 with Attribute

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

the class FindViewControllerNGTest method testPopulateAttributes.

/**
 * Test of populateAttributes method, of class FindViewController.
 */
@Test
public void testPopulateAttributes() {
    System.out.println("populateAttributes");
    /**
     * Set up the graph with 4 vertexs, 4 transactions, 3 vertex attributes
     * (2 of type string), 3 transaction attributes (2 of type string)
     */
    setupGraph();
    /**
     * Create a mock of the top component, get an intsance of the
     * controller, create a mock of the graph manager, when getAllGraphs is
     * called return the graphMap created in this class
     */
    final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
    FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
    final GraphManager gm = Mockito.mock(GraphManager.class);
    when(gm.getAllGraphs()).thenReturn(graphMap);
    try (MockedStatic<GraphManager> mockedStatic = Mockito.mockStatic(GraphManager.class)) {
        mockedStatic.when(() -> GraphManager.getDefault()).thenReturn(gm);
        List<Attribute> attributes = new ArrayList<>();
        GraphElementType type = GraphElementType.VERTEX;
        List<String> result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
        assertEquals(result.get(0), "Label");
        assertEquals(result.get(1), "Identifier");
        assertEquals(result.size(), 2);
        type = GraphElementType.TRANSACTION;
        result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
        assertEquals(result.get(0), "Label");
        assertEquals(result.get(1), "Identifier");
        assertEquals(result.size(), 2);
        type = GraphElementType.EDGE;
        result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
        assertEquals(result.size(), 0);
    }
// TODO review the generated test code and remove the default call to fail.
}
Also used : GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

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