Search in sources :

Example 1 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class ResetStatePluginNGTest method setupGraph.

private void setupGraph() {
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    try {
        WritableGraph wg = graph.getWritableGraph("", true);
        final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
        ArrayList<Attribute> attributeList = new ArrayList<>();
        BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
        FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
        wg.setObjectValue(stateId, 0, foundResult);
        wg.commit();
    } catch (final InterruptedException ex) {
        Exceptions.printStackTrace(ex);
        Thread.currentThread().interrupt();
    }
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) FindResultsList(au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph)

Example 2 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class FindViewControllerNGTest method testUpdateBasicReplaceParameters.

/**
 * Test of updateBasicReplaceParameters method, of class FindViewController.
 */
@Test
public void testUpdateBasicReplaceParameters() {
    System.out.println("updateBasicReplaceParameters");
    FindViewController instance = FindViewController.getDefault();
    List<Attribute> attributeList = new ArrayList<>();
    instance.updateBasicReplaceParameters(parameters);
    BasicFindReplaceParameters result = instance.getCurrentBasicReplaceParameters();
    // The object is copied in the updateBasicFindParameters function
    // This will cause a direct comparison of the object to be false
    assertEquals(result, parameters);
    assertNotEquals(result, parameters2);
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 3 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class FindViewControllerNGTest method testGetCurrentBasicFindParameters.

/**
 * Test of getCurrentBasicFindParameters method, of class
 * FindViewController.
 */
@Test
public void testGetCurrentBasicFindParameters() {
    System.out.println("getCurrentBasicFindParameters");
    final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
    FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
    /**
     * Check getting getCurrentBasicReplaceParamters returns the default
     * parameters
     */
    BasicFindReplaceParameters defaultParameters = new BasicFindReplaceParameters();
    instance.updateBasicFindParameters(defaultParameters);
    assertEquals(instance.getCurrentBasicFindParameters(), defaultParameters);
    /**
     * Check getting getCurrentBasicReplaceParamters returns the matching
     * parameters of what it was set to
     */
    instance.updateBasicFindParameters(parameters);
    assertEquals(instance.getCurrentBasicFindParameters(), parameters);
}
Also used : BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 4 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters 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 5 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters 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)

Aggregations

BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)13 Attribute (au.gov.asd.tac.constellation.graph.Attribute)9 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)6 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)5 FindResultsList (au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList)5 FindResult (au.gov.asd.tac.constellation.views.find2.utilities.FindResult)3 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)2 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1