Search in sources :

Example 1 with AttributeValueManipulator

use of org.gephi.datalab.spi.values.AttributeValueManipulator in project gephi by gephi.

the class PopupMenuUtils method createSubMenuFromRowColumn.

public static JMenu createSubMenuFromRowColumn(Element row, Column column) {
    DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
    JMenu subMenu = new JMenu(NbBundle.getMessage(PopupMenuUtils.class, "Cell.Popup.subMenu.text"));
    subMenu.setIcon(ImageUtilities.loadImageIcon("org/gephi/desktop/datalab/resources/table-select.png", true));
    Integer lastManipulatorType = null;
    for (AttributeValueManipulator am : dlh.getAttributeValueManipulators()) {
        am.setup(row, column);
        if (lastManipulatorType == null) {
            lastManipulatorType = am.getType();
        }
        if (lastManipulatorType != am.getType()) {
            subMenu.addSeparator();
        }
        lastManipulatorType = am.getType();
        subMenu.add(PopupMenuUtils.createMenuItemFromManipulator(am));
    }
    if (subMenu.getMenuComponentCount() == 0) {
        subMenu.setEnabled(false);
    }
    return subMenu;
}
Also used : DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) AttributeValueManipulator(org.gephi.datalab.spi.values.AttributeValueManipulator) JMenu(javax.swing.JMenu)

Example 2 with AttributeValueManipulator

use of org.gephi.datalab.spi.values.AttributeValueManipulator in project gephi by gephi.

the class DataLaboratoryHelper method getAttributeValueManipulators.

/**
     * <p>Prepares an array with one new instance of every AttributeValueManipulator
     * that has a builder registered and returns it.</p>
     * <p>It also returns the manipulators ordered first by type and then by position.</p>
     * @return Array of all AttributeValueManipulator implementations
     */
public AttributeValueManipulator[] getAttributeValueManipulators() {
    ArrayList<AttributeValueManipulator> attributeValueManipulators = new ArrayList<>();
    for (AttributeValueManipulatorBuilder am : Lookup.getDefault().lookupAll(AttributeValueManipulatorBuilder.class)) {
        attributeValueManipulators.add(am.getAttributeValueManipulator());
    }
    sortManipulators(attributeValueManipulators);
    return attributeValueManipulators.toArray(new AttributeValueManipulator[0]);
}
Also used : AttributeValueManipulator(org.gephi.datalab.spi.values.AttributeValueManipulator) AttributeValueManipulatorBuilder(org.gephi.datalab.spi.values.AttributeValueManipulatorBuilder) ArrayList(java.util.ArrayList)

Aggregations

AttributeValueManipulator (org.gephi.datalab.spi.values.AttributeValueManipulator)2 ArrayList (java.util.ArrayList)1 JMenu (javax.swing.JMenu)1 DataLaboratoryHelper (org.gephi.datalab.api.DataLaboratoryHelper)1 AttributeValueManipulatorBuilder (org.gephi.datalab.spi.values.AttributeValueManipulatorBuilder)1