Search in sources :

Example 6 with DataLaboratoryHelper

use of org.gephi.datalab.api.DataLaboratoryHelper in project gephi by gephi.

the class EdgesPopupAdapter method createPopup.

@Override
protected JPopupMenu createPopup(Point p) {
    final List<Edge> selectedElements = elementsDataTable.getElementsFromSelectedRows();
    final Edge clickedElement = elementsDataTable.getElementFromRow(table.rowAtPoint(p));
    JPopupMenu contextMenu = new JPopupMenu();
    //First add edges manipulators items:
    DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
    Integer lastManipulatorType = null;
    for (EdgesManipulator em : dlh.getEdgesManipulators()) {
        em.setup(selectedElements.toArray(new Edge[0]), clickedElement);
        if (lastManipulatorType == null) {
            lastManipulatorType = em.getType();
        }
        if (lastManipulatorType != em.getType()) {
            contextMenu.addSeparator();
        }
        lastManipulatorType = em.getType();
        if (em.isAvailable()) {
            contextMenu.add(PopupMenuUtils.createMenuItemFromEdgesManipulator(em, clickedElement, selectedElements.toArray(new Edge[0])));
        }
    }
    //Add AttributeValues manipulators submenu:
    Column column = elementsDataTable.getColumnAtIndex(table.columnAtPoint(p));
    if (column != null) {
        contextMenu.add(PopupMenuUtils.createSubMenuFromRowColumn(clickedElement, column));
    }
    return contextMenu;
}
Also used : DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) Column(org.gephi.graph.api.Column) EdgesManipulator(org.gephi.datalab.spi.edges.EdgesManipulator) Edge(org.gephi.graph.api.Edge) JPopupMenu(javax.swing.JPopupMenu)

Example 7 with DataLaboratoryHelper

use of org.gephi.datalab.api.DataLaboratoryHelper in project gephi by gephi.

the class NodesPopupAdapter method createPopup.

@Override
protected JPopupMenu createPopup(Point p) {
    final List<Node> selectedElements = elementsDataTable.getElementsFromSelectedRows();
    final Node clickedElement = elementsDataTable.getElementFromRow(table.rowAtPoint(p));
    JPopupMenu contextMenu = new JPopupMenu();
    //First add edges manipulators items:
    DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
    Integer lastManipulatorType = null;
    for (NodesManipulator em : dlh.getNodesManipulators()) {
        em.setup(selectedElements.toArray(new Node[0]), clickedElement);
        if (lastManipulatorType == null) {
            lastManipulatorType = em.getType();
        }
        if (lastManipulatorType != em.getType()) {
            contextMenu.addSeparator();
        }
        lastManipulatorType = em.getType();
        if (em.isAvailable()) {
            contextMenu.add(PopupMenuUtils.createMenuItemFromNodesManipulator(em, clickedElement, selectedElements.toArray(new Node[0])));
        }
    }
    //Add AttributeValues manipulators submenu:
    Column column = elementsDataTable.getColumnAtIndex(table.columnAtPoint(p));
    if (column != null) {
        contextMenu.add(PopupMenuUtils.createSubMenuFromRowColumn(clickedElement, column));
    }
    return contextMenu;
}
Also used : DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) Column(org.gephi.graph.api.Column) Node(org.gephi.graph.api.Node) NodesManipulator(org.gephi.datalab.spi.nodes.NodesManipulator) JPopupMenu(javax.swing.JPopupMenu)

Example 8 with DataLaboratoryHelper

use of org.gephi.datalab.api.DataLaboratoryHelper in project gephi by gephi.

the class PopupMenuUtils method createMenuItemFromManipulator.

public static JMenuItem createMenuItemFromManipulator(final Manipulator nm) {
    JMenuItem menuItem = new JMenuItem();
    menuItem.setText(nm.getName());
    if (nm.getDescription() != null && !nm.getDescription().isEmpty()) {
        menuItem.setToolTipText(nm.getDescription());
    }
    menuItem.setIcon(nm.getIcon());
    if (nm.canExecute()) {
        menuItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault();
                dlh.executeManipulator(nm);
            }
        });
    } else {
        menuItem.setEnabled(false);
    }
    return menuItem;
}
Also used : DataLaboratoryHelper(org.gephi.datalab.api.DataLaboratoryHelper) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem)

Aggregations

DataLaboratoryHelper (org.gephi.datalab.api.DataLaboratoryHelper)8 GeneralActionsManipulator (org.gephi.datalab.spi.general.GeneralActionsManipulator)3 Column (org.gephi.graph.api.Column)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JPopupMenu (javax.swing.JPopupMenu)2 PluginGeneralActionsManipulator (org.gephi.datalab.spi.general.PluginGeneralActionsManipulator)2 NodesManipulator (org.gephi.datalab.spi.nodes.NodesManipulator)2 Edge (org.gephi.graph.api.Edge)2 Node (org.gephi.graph.api.Node)2 Dimension (java.awt.Dimension)1 KeyEvent (java.awt.event.KeyEvent)1 JButton (javax.swing.JButton)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 ContextMenuItemManipulator (org.gephi.datalab.spi.ContextMenuItemManipulator)1 AttributeColumnsManipulator (org.gephi.datalab.spi.columns.AttributeColumnsManipulator)1 EdgesManipulator (org.gephi.datalab.spi.edges.EdgesManipulator)1 AttributeValueManipulator (org.gephi.datalab.spi.values.AttributeValueManipulator)1 EdgesDataTable (org.gephi.desktop.datalab.tables.EdgesDataTable)1