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