Search in sources :

Example 1 with PropertySet

use of org.openide.nodes.Node.PropertySet in project gephi by gephi.

the class LayoutNode method getPropertySets.

@Override
public PropertySet[] getPropertySets() {
    if (propertySets == null) {
        try {
            Map<String, Sheet.Set> sheetMap = new HashMap<>();
            for (LayoutProperty layoutProperty : layout.getProperties()) {
                Sheet.Set set = sheetMap.get(layoutProperty.getCategory());
                if (set == null) {
                    set = Sheet.createPropertiesSet();
                    set.setDisplayName(layoutProperty.getCategory());
                    sheetMap.put(layoutProperty.getCategory(), set);
                }
                set.put(layoutProperty.getProperty());
            }
            propertySets = sheetMap.values().toArray(new PropertySet[0]);
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
            return null;
        }
    }
    return propertySets;
}
Also used : PropertySet(org.openide.nodes.Node.PropertySet) HashMap(java.util.HashMap) LayoutProperty(org.gephi.layout.spi.LayoutProperty) PropertySet(org.openide.nodes.Node.PropertySet) Sheet(org.openide.nodes.Sheet)

Example 2 with PropertySet

use of org.openide.nodes.Node.PropertySet in project ACS by ACS-Community.

the class TableHolderImpl method setTableColumns.

public void setTableColumns(GPNode node, String[] propNames, boolean[] sortable) {
    // this is based on the org.openide.nodes.Node.getPropertySets() method, which is filled in by the
    // cern.gp.nodes.impl.BeanNode.createProperties();
    // get the normal and experts propertySets and concatenate them
    Node.Property[] allProperties;
    PropertySet[] propSets = node.getPeerNode().getPropertySets();
    Node.Property[] normalProperties = propSets[0].getProperties();
    if (propSets.length == 1) {
        allProperties = normalProperties;
    } else {
        Node.Property[] expertProperties = propSets[1].getProperties();
        allProperties = new Node.Property[normalProperties.length + expertProperties.length];
        System.arraycopy(normalProperties, 0, allProperties, 0, normalProperties.length);
        System.arraycopy(expertProperties, 0, allProperties, normalProperties.length, expertProperties.length);
    }
    final Node.Property[] tableProperties;
    if (propNames == null) {
        tableProperties = allProperties;
    } else {
        ArrayList list = new ArrayList(propNames.length);
        for (int n = 0; n < propNames.length; n++) {
            for (int p = 0; p < allProperties.length; p++) {
                if (propNames[n].equals(allProperties[p].getName())) {
                    list.add(allProperties[p]);
                }
            }
        }
        tableProperties = (Node.Property[]) list.toArray(new Node.Property[list.size()]);
    }
    tablePropertyHolder.setProperties(tableProperties, sortable);
}
Also used : GPNode(cern.gp.nodes.GPNode) Node(org.openide.nodes.Node) ArrayList(java.util.ArrayList) PropertySet(org.openide.nodes.Node.PropertySet) Property(org.openide.nodes.Node.Property)

Aggregations

PropertySet (org.openide.nodes.Node.PropertySet)2 GPNode (cern.gp.nodes.GPNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LayoutProperty (org.gephi.layout.spi.LayoutProperty)1 Node (org.openide.nodes.Node)1 Property (org.openide.nodes.Node.Property)1 Sheet (org.openide.nodes.Sheet)1