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();
}
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);
}
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);
}
}
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;
}
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.
}
Aggregations