use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class InvertSelectedNodesTaskTest method testRun.
@Test
public void testRun() throws Exception {
final CyTable nodeTable = mock(CyTable.class);
when(net.getDefaultNodeTable()).thenReturn(nodeTable);
UndoSupport undoSupport = mock(UndoSupport.class);
// more setup
when(r3.get("selected", Boolean.class)).thenReturn(false);
when(r4.get("selected", Boolean.class)).thenReturn(true);
final CyEventHelper eventHelper = mock(CyEventHelper.class);
// run the task
Task t = new InvertSelectedNodesTask(undoSupport, net, networkViewManager, eventHelper);
t.run(tm);
// check that the expected rows were set
verify(r3, times(1)).set("selected", true);
verify(r4, times(1)).set("selected", false);
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class NewNetworkSelectedNodesEdgesTaskFactoryTest method testObserver.
@Test
public void testObserver() throws Exception {
NetworkViewTestSupport viewSupport = new NetworkViewTestSupport();
NetworkTestSupport networkSupport = new NetworkTestSupport();
CyNetworkFactory networkFactory = networkSupport.getNetworkFactory();
UndoSupport undoSupport = mock(UndoSupport.class);
CyRootNetworkManager crnf = new CyRootNetworkManagerImpl();
CyNetworkViewFactory cnvf = viewSupport.getNetworkViewFactory();
CyNetworkManager netmgr = mock(CyNetworkManager.class);
CyNetworkViewManager networkViewManager = mock(CyNetworkViewManager.class);
CyNetworkNaming naming = mock(CyNetworkNaming.class);
VisualMappingManager vmm = mock(VisualMappingManager.class);
CyApplicationManager appManager = mock(CyApplicationManager.class);
CyEventHelper eventHelper = mock(CyEventHelper.class);
CyGroupManager groupMgr = mock(CyGroupManager.class);
RenderingEngineManager renderingEngineMgr = mock(RenderingEngineManager.class);
CyLayoutAlgorithm defLayout = mock(CyLayoutAlgorithm.class);
CyLayoutAlgorithmManager layoutMgr = mock(CyLayoutAlgorithmManager.class);
when(layoutMgr.getDefaultLayout()).thenReturn(defLayout);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(CyLayoutAlgorithmManager.class)).thenReturn(layoutMgr);
NewNetworkSelectedNodesEdgesTaskFactoryImpl factory = new NewNetworkSelectedNodesEdgesTaskFactoryImpl(undoSupport, crnf, cnvf, netmgr, networkViewManager, naming, vmm, appManager, eventHelper, groupMgr, renderingEngineMgr, serviceRegistrar);
CyNetwork network = networkFactory.createNetwork();
CyNode node = network.addNode();
network.getRow(node).set(CyNetwork.SELECTED, true);
TaskObserver observer = mock(TaskObserver.class);
TaskMonitor taskMonitor = mock(TaskMonitor.class);
TaskIterator iterator = factory.createTaskIterator(network);
while (iterator.hasNext()) {
Task t = iterator.next();
t.run(taskMonitor);
if (t instanceof ObservableTask)
observer.taskFinished((ObservableTask) t);
}
verify(observer, times(1)).taskFinished(any(ObservableTask.class));
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class UnHideAllEdgesTaskFactoryTest method testRun.
@Test
public void testRun() throws Exception {
UndoSupport undoSupport = mock(UndoSupport.class);
CyEventHelper eventHelper = mock(CyEventHelper.class);
VisualMappingManager vmMgr = mock(VisualMappingManager.class);
CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
when(serviceRegistrar.getService(UndoSupport.class)).thenReturn(undoSupport);
when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
when(serviceRegistrar.getService(VisualMappingManager.class)).thenReturn(vmMgr);
UnHideAllEdgesTaskFactoryImpl factory = new UnHideAllEdgesTaskFactoryImpl(serviceRegistrar);
CyNetworkView view = mock(CyNetworkView.class);
TaskIterator ti = factory.createTaskIterator(view);
assertNotNull(ti);
assertTrue(ti.hasNext());
Task t = ti.next();
assertNotNull(t);
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class AllFactoryTest method testInvertSelectedNodesTaskFactory.
@Test
public void testInvertSelectedNodesTaskFactory() {
final CyEventHelper eventHelper = mock(CyEventHelper.class);
executeTest(new InvertSelectedNodesTaskFactoryImpl(undoSupport, networkViewManager, eventHelper));
}
use of org.cytoscape.event.CyEventHelper in project cytoscape-impl by cytoscape.
the class PreferencesDialog method initGUI.
private void initGUI() throws Exception {
closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
for (String key : itemChangedMap.keySet()) {
if (itemChangedMap.get(key)) {
PropertyUpdatedEvent event = new PropertyUpdatedEvent(cyPropMap.get(key));
eventHelper.fireEvent(event);
itemChangedMap.put(key, false);
}
}
dispose();
}
});
propsTablePane.getViewport().add(prefsTable, null);
prefsTable.setPreferredScrollableViewportSize(new Dimension(400, 200));
final JPanel propsTablePanel = new JPanel();
propsTablePanel.setBorder(LookAndFeelUtil.createTitledBorder("Properties"));
{
final GroupLayout layout = new GroupLayout(propsTablePanel);
propsTablePanel.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addComponent(cmbPropCategories, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(propsTablePane, DEFAULT_SIZE, DEFAULT_SIZE, 460).addGroup(Alignment.CENTER, layout.createSequentialGroup().addComponent(addPropBtn).addComponent(modifyPropBtn).addComponent(deletePropBtn)));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(cmbPropCategories, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(propsTablePane, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(addPropBtn).addComponent(modifyPropBtn).addComponent(deletePropBtn)));
}
final JPanel contentPane = new JPanel();
{
final GroupLayout layout = new GroupLayout(contentPane);
contentPane.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
// #3534
final JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton, "Linkout");
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.TRAILING, true).addComponent(propsTablePanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(buttonPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(propsTablePanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(buttonPanel));
}
setContentPane(contentPane);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), closeButton.getAction(), closeButton.getAction());
getRootPane().setDefaultButton(closeButton);
}
Aggregations