use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class NetworkViewMainPanel method showExportPopup.
private void showExportPopup(JComponent source, CyNetworkView view) {
DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
final JPopupMenu popupMenu = new JPopupMenu();
{
final JMenuItem mi = new JMenuItem("Export as Network...");
mi.addActionListener(evt -> {
ExportNetworkViewTaskFactory factory = serviceRegistrar.getService(ExportNetworkViewTaskFactory.class);
taskMgr.execute(factory.createTaskIterator(view));
});
popupMenu.add(mi);
}
{
final JMenuItem mi = new JMenuItem("Export as Image...");
mi.addActionListener(evt -> {
ExportNetworkImageTaskFactory factory = serviceRegistrar.getService(ExportNetworkImageTaskFactory.class);
taskMgr.execute(factory.createTaskIterator(view));
});
popupMenu.add(mi);
}
popupMenu.show(source, 0, source.getHeight());
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class NetworkViewMainPanel method init.
private void init() {
setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, UIManager.getColor("Separator.foreground")));
setLayout(new BorderLayout());
add(getContentPane(), BorderLayout.CENTER);
// Add Listeners
nullViewPanel.getCreateViewButton().addActionListener(evt -> {
if (nullViewPanel.getNetwork() instanceof CySubNetwork) {
final CreateNetworkViewTaskFactory factory = serviceRegistrar.getService(CreateNetworkViewTaskFactory.class);
final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
taskManager.execute(factory.createTaskIterator(Collections.singleton(nullViewPanel.getNetwork())));
}
});
nullViewPanel.getInfoIconLabel().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!e.isPopupTrigger() && nullViewPanel.getNetworkView() != null) {
final NetworkViewFrame frame = getNetworkViewFrame(nullViewPanel.getNetworkView());
if (frame != null)
showViewFrame(frame);
}
}
});
nullViewPanel.getReattachViewButton().addActionListener(evt -> {
if (nullViewPanel.getNetworkView() != null)
reattachNetworkView(nullViewPanel.getNetworkView());
});
networkViewGrid.addPropertyChangeListener("selectedNetworkViews", evt -> {
// Just fire the same event
firePropertyChange("selectedNetworkViews", evt.getOldValue(), evt.getNewValue());
});
networkViewGrid.addPropertyChangeListener("currentNetworkView", evt -> {
final CyNetworkView curView = (CyNetworkView) evt.getNewValue();
for (NetworkViewContainer vc : getAllNetworkViewContainers()) vc.setCurrent(vc.getNetworkView().equals(curView));
});
Toolkit.getDefaultToolkit().addAWTEventListener(mousePressedAWTEventListener, MouseEvent.MOUSE_EVENT_MASK);
// Update
updateGrid();
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class Util method openSession.
public static void openSession(File file, CyServiceRegistrar serviceRegistrar, TaskObserver observer) {
final OpenSessionTaskFactory taskFactory = serviceRegistrar.getService(OpenSessionTaskFactory.class);
final DialogTaskManager taskManager = serviceRegistrar.getService(DialogTaskManager.class);
if (observer == null)
taskManager.execute(taskFactory.createTaskIterator(file));
else
taskManager.execute(taskFactory.createTaskIterator(file), observer);
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class EnhancedSearchPanel method doSearching.
// Do searching based on the query string from user on text-field
private void doSearching() {
final String queryStr = tfSearchText.getText().trim();
// Ignore if the search term is empty
if (queryStr == null || queryStr.length() == 0)
return;
final CyApplicationManager appManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetwork currentNetwork = appManager.getCurrentNetwork();
if (currentNetwork != null) {
final SearchTaskFactory factory = new SearchTaskFactory(searchMgr, queryStr, serviceRegistrar);
final DialogTaskManager taskMgr = serviceRegistrar.getService(DialogTaskManager.class);
taskMgr.execute(factory.createTaskIterator(currentNetwork));
} else {
logger.error("Could not find network for search");
}
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class MacCyActivator method start.
@Override
public void start(BundleContext context) throws Exception {
final CyServiceRegistrar serviceRegistrar = getService(context, CyServiceRegistrar.class);
final CyShutdown shutdown = getService(context, CyShutdown.class);
final TaskFactory aboutTaskFactory = new HelpAboutTaskFactory(serviceRegistrar);
final DialogTaskManager taskManager = getService(context, DialogTaskManager.class);
final CyShutdownEvent[] lastShutdownEvent = new CyShutdownEvent[1];
CyShutdownListener listener = (CyShutdownEvent e) -> {
lastShutdownEvent[0] = e;
};
registerService(context, listener, CyShutdownListener.class, new Properties());
Application application = Application.getApplication();
application.setQuitHandler((QuitEvent event, QuitResponse response) -> {
shutdown.exit(0);
if (lastShutdownEvent[0] != null && !lastShutdownEvent[0].actuallyShutdown()) {
response.cancelQuit();
}
});
application.setAboutHandler((AboutEvent event) -> {
taskManager.execute(aboutTaskFactory.createTaskIterator());
});
}
Aggregations