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