use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class CyTableManagerImpl method deleteTableInternal.
void deleteTableInternal(final long suid, boolean force) {
CyTable table;
synchronized (lock) {
table = tables.get(suid);
if (table == null) {
return;
}
}
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(new TableAboutToBeDeletedEvent(this, table));
synchronized (lock) {
table = tables.get(suid);
if (table == null) {
return;
}
if (!force && (table.getMutability() != Mutability.MUTABLE)) {
throw new IllegalArgumentException("can't delete an immutable table.");
}
if (table instanceof CyTableImpl)
((CyTableImpl) table).removeAllVirtColumns();
tables.remove(suid);
}
eventHelper.fireEvent(new TableDeletedEvent(this));
logger.debug("CyTable removed: table ID = " + table.getSUID());
table = null;
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class RenderingEngineManagerTest method setUp.
@Before
public void setUp() throws Exception {
final CyEventHelper eventHelper = mock(CyEventHelper.class);
final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
manager = new RenderingEngineManagerImpl(serviceRegistrar);
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class BrowserTable method selectFromTable.
private void selectFromTable() {
final TableModel model = this.getModel();
if (model instanceof BrowserTableModel == false)
return;
final BrowserTableModel btModel = (BrowserTableModel) model;
if (btModel.getViewMode() != BrowserTableModel.ViewMode.ALL)
return;
final CyTable table = btModel.getDataTable();
final CyColumn pKey = table.getPrimaryKey();
final String pKeyName = pKey.getName();
final int[] rowsSelected = getSelectedRows();
if (rowsSelected.length == 0)
return;
final int selectedRowCount = getSelectedRowCount();
final Set<CyRow> targetRows = new HashSet<CyRow>();
for (int i = 0; i < selectedRowCount; i++) {
// getting the row from data table solves the problem with hidden or
// moved SUID column. However, since the rows might be sorted we
// need to convert the index to model
final ValidatedObjectAndEditString selected = (ValidatedObjectAndEditString) btModel.getValueAt(convertRowIndexToModel(rowsSelected[i]), pKeyName);
targetRows.add(btModel.getRow(selected.getValidatedObject()));
}
// Clear selection for non-global table
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (tableManager.getGlobalTables().contains(table) == false) {
List<CyRow> allRows = btModel.getDataTable().getAllRows();
try {
ignoreRowSetEvents = true;
for (CyRow row : allRows) {
final Boolean val = row.get(CyNetwork.SELECTED, Boolean.class);
if (targetRows.contains(row)) {
row.set(CyNetwork.SELECTED, true);
continue;
}
if (val != null && (val == true))
row.set(CyNetwork.SELECTED, false);
}
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetworkView curView = applicationManager.getCurrentNetworkView();
if (curView != null) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.flushPayloadEvents();
curView.updateView();
}
} finally {
ignoreRowSetEvents = false;
}
repaint();
}
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class TestProxySettings method run.
@Override
public void run(TaskMonitor tm) {
tm.setProgress(0.0);
final CyProperty<Properties> proxyProps = getProxyProperties();
final Properties props = proxyProps.getProperties();
storeProxySettings(props);
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
for (String key : oldSettings.keySet()) {
if (!oldSettings.get(key).equals(props.get(key))) {
eventHelper.fireEvent(new PropertyUpdatedEvent(proxyProps));
break;
}
}
oldSettings.clear();
tm.setProgress(1.0);
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class DeleteSelectedNodesAndEdgesTask method run.
@Override
public void run(final TaskMonitor taskMonitor) {
taskMonitor.setProgress(0.0);
List<CyNode> nodeList = tunables.getNodeList(false);
List<CyEdge> edgeList = tunables.getEdgeList(false);
if (tunables.getNetwork() != null)
network = tunables.getNetwork();
// Delete from the base network so that our changes can be undone:
if (nodeList == null && edgeList == null) {
selectedNodes = CyTableUtil.getNodesInState(network, "selected", true);
taskMonitor.setProgress(0.1);
selectedEdges = new HashSet<CyEdge>(CyTableUtil.getEdgesInState(network, "selected", true));
} else {
if (nodeList != null && nodeList.size() > 0)
selectedNodes = nodeList;
else
selectedNodes = new ArrayList<CyNode>();
if (edgeList != null && edgeList.size() > 0)
selectedEdges = new HashSet<CyEdge>(edgeList);
else
selectedEdges = new HashSet<CyEdge>();
}
taskMonitor.setProgress(0.2);
// Make sure we're not loosing any edges for a possible undo!
for (CyNode selectedNode : selectedNodes) selectedEdges.addAll(network.getAdjacentEdgeList(selectedNode, CyEdge.Type.ANY));
taskMonitor.setProgress(0.3);
final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
final CyNetworkViewManager netViewMgr = serviceRegistrar.getService(CyNetworkViewManager.class);
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
undoSupport.postEdit(new DeleteEdit((CySubNetwork) network, selectedNodes, selectedEdges, netViewMgr, vmMgr, eventHelper));
// Delete the actual nodes and edges:
network.removeEdges(selectedEdges);
taskMonitor.setProgress(0.7);
network.removeNodes(selectedNodes);
taskMonitor.setProgress(0.9);
// Update network views
final Collection<CyNetworkView> views = netViewMgr.getNetworkViews(network);
for (final CyNetworkView netView : views) netView.updateView();
taskMonitor.setProgress(1.0);
}
Aggregations