use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class NetworkSelectionMediator method updateApplicationManager.
private void updateApplicationManager(final CyNetwork currentNetwork, final CyNetworkView currentView, final Collection<CyNetwork> selectedNetworks, final Collection<CyNetworkView> selectedViews) {
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
appMgr.setSelectedNetworks(new ArrayList<>(selectedNetworks));
appMgr.setCurrentNetwork(currentNetwork);
appMgr.setSelectedNetworkViews(new ArrayList<>(selectedViews));
appMgr.setCurrentNetworkView(currentView);
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class DefaultTableBrowser method handleEvent.
@Override
public void handleEvent(final TableAddedEvent e) {
final CyTable newTable = e.getTable();
if (newTable.isPublic() || showPrivateTables()) {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
final CyNetworkTableManager netTableManager = serviceRegistrar.getService(CyNetworkTableManager.class);
final CyNetwork curNet = applicationManager.getCurrentNetwork();
if (curNet != null && netTableManager.getTables(curNet, objType).containsValue(newTable)) {
invokeOnEDT(() -> {
if (((DefaultComboBoxModel<CyTable>) getTableChooser().getModel()).getIndexOf(newTable) < 0) {
getTableChooser().addItem(newTable);
getToolBar().updateEnableState(getTableChooser());
}
});
}
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class DefaultTableBrowser method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
if (!ignoreSetCurrentTable) {
final CyTable table = (CyTable) getTableChooser().getSelectedItem();
currentTable = table;
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
if (table != null && !table.equals(applicationManager.getCurrentTable())) {
final CyTableManager tableManager = serviceRegistrar.getService(CyTableManager.class);
if (tableManager.getTable(table.getSUID()) != null)
applicationManager.setCurrentTable(table);
}
showSelectedTable();
changeSelectionMode();
}
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class CyActivator method initComponents.
private void initComponents(final BundleContext bc, final CyServiceRegistrar serviceRegistrar) {
CyApplicationManager applicationManager = getService(bc, CyApplicationManager.class);
CyNetworkViewManager netViewManager = getService(bc, CyNetworkViewManager.class);
final CytoscapeMenuBar cytoscapeMenuBar = new CytoscapeMenuBar(serviceRegistrar);
final CytoscapeToolBar cytoscapeToolBar = new CytoscapeToolBar(serviceRegistrar);
cytoscapeMenus = new CytoscapeMenus(cytoscapeMenuBar, cytoscapeToolBar);
toolBarEnableUpdater = new ToolBarEnableUpdater(cytoscapeToolBar, serviceRegistrar);
netSearchBar = new NetworkSearchBar(serviceRegistrar);
netSearchMediator = new NetworkSearchMediator(netSearchBar, serviceRegistrar);
netMainPanel = new NetworkMainPanel(netSearchBar, serviceRegistrar);
netMediator = new NetworkMediator(netMainPanel, serviceRegistrar);
commandToolPanel = new CommandToolDialog(serviceRegistrar);
viewComparator = new ViewComparator(netMainPanel);
gridViewToggleModel = new GridViewToggleModel(GridViewToggleModel.Mode.VIEW);
netViewMainPanel = new NetworkViewMainPanel(gridViewToggleModel, cytoscapeMenus, viewComparator, serviceRegistrar);
netViewMediator = new NetworkViewMediator(netViewMainPanel, netMediator, gridViewToggleModel, serviceRegistrar);
cytoscapeDesktop = new CytoscapeDesktop(cytoscapeMenus, netViewMediator, serviceRegistrar);
final SessionIO sessionIO = new SessionIO();
sessionHandler = new SessionHandler(cytoscapeDesktop, netViewMediator, sessionIO, netMainPanel, serviceRegistrar);
layoutMenuPopulator = new LayoutMenuPopulator(cytoscapeMenuBar, serviceRegistrar);
cytoscapeMenuPopulator = new CytoscapeMenuPopulator(cytoscapeDesktop, serviceRegistrar);
layoutSettingsManager = new LayoutSettingsManager(serviceRegistrar);
helpUserManualTaskFactory = new HelpUserManualTaskFactory(serviceRegistrar);
helpContactHelpDeskTaskFactory = new HelpContactHelpDeskTaskFactory(serviceRegistrar);
helpReportABugTaskFactory = new HelpReportABugTaskFactory(serviceRegistrar);
helpAboutTaskFactory = new HelpAboutTaskFactory(serviceRegistrar);
cyDesktopManager = new CyDesktopManager(netViewMediator);
arrangeGridTaskFactory = new ArrangeTaskFactory(GRID, cyDesktopManager, netViewMediator);
arrangeCascadeTaskFactory = new ArrangeTaskFactory(CASCADE, cyDesktopManager, netViewMediator);
arrangeHorizontalTaskFactory = new ArrangeTaskFactory(HORIZONTAL, cyDesktopManager, netViewMediator);
arrangeVerticalTaskFactory = new ArrangeTaskFactory(VERTICAL, cyDesktopManager, netViewMediator);
preferencesDialogFactory = new PreferencesDialogFactory(serviceRegistrar);
// cy3preferencesDialogFactory = new Cy3PreferencesDialogFactory(serviceRegistrar);
bookmarkDialogFactory = new BookmarkDialogFactory(serviceRegistrar);
undoMonitor = new UndoMonitor(serviceRegistrar);
rowViewTracker = new RowViewTracker();
selecteEdgeViewUpdater = new SelectEdgeViewUpdater(rowViewTracker);
selecteNodeViewUpdater = new SelectNodeViewUpdater(rowViewTracker);
rowsSetViewUpdater = new RowsSetViewUpdater(rowViewTracker, netViewMediator, serviceRegistrar);
recentSessionManager = new RecentSessionManager(serviceRegistrar);
netSelectionMediator = new NetworkSelectionMediator(netMainPanel, netViewMainPanel, serviceRegistrar);
// /// CyActions ////
undoAction = new UndoAction(serviceRegistrar);
redoAction = new RedoAction(serviceRegistrar);
printAction = new PrintAction(applicationManager, netViewManager, serviceRegistrar);
exitAction = new ExitAction(serviceRegistrar);
// cy3preferenceAction = new Cy3PreferenceAction(cytoscapeDesktop, cy3preferencesDialogFactory);
preferenceAction = new PreferenceAction(cytoscapeDesktop, preferencesDialogFactory);
bookmarkAction = new BookmarkAction(cytoscapeDesktop, bookmarkDialogFactory);
settingsAction = new SettingsAction(layoutSettingsManager, serviceRegistrar);
cytoPanelWestAction = new CytoPanelAction(WEST, true, cytoscapeDesktop, 1.0f);
cytoPanelSouthAction = new CytoPanelAction(SOUTH, true, cytoscapeDesktop, 1.1f);
cytoPanelEastAction = new CytoPanelAction(EAST, false, cytoscapeDesktop, 1.2f);
cytoPanelSouthWestAction = new CytoPanelAction(SOUTH_WEST, false, cytoscapeDesktop, 1.3f);
cytoPanelCommandAction = new CytoPanelAction(BOTTOM, false, cytoscapeDesktop, 1.35f);
starterPanelAction = new StarterPanelAction(1.4f, cytoscapeDesktop);
detachedViewToolBarAction = new DetachedViewToolBarAction(1.5f, netViewMediator);
closeWindowAction = new CloseWindowAction(6.1f, netViewMediator);
createNetworkViewsAction = new CreateNetworkViewsAction(3.0f, serviceRegistrar);
destroyNetworkViewsAction = new DestroyNetworkViewsAction(3.1f, serviceRegistrar);
destroyNetworksAction = new DestroyNetworksAction(3.2f, netMainPanel, serviceRegistrar);
exportNetworkAction = new ExportNetworkAction(1000.1f, serviceRegistrar);
exportImageAction = new ExportImageAction(1000.2f, serviceRegistrar);
}
use of org.cytoscape.application.CyApplicationManager in project cytoscape-impl by cytoscape.
the class PopupMenuHelper method createTableCellMenu.
@SuppressWarnings("serial")
public void createTableCellMenu(final CyColumn column, final Object primaryKeyValue, final Class<? extends CyIdentifiable> tableType, final Component invoker, final int x, final int y, final JTable table) {
final JPopupMenu menu = new JPopupMenu();
// Add preset menu items
menu.add(new JMenuItem(new AbstractAction("Edit") {
@Override
public void actionPerformed(ActionEvent e) {
Point point = new Point(x, y);
int row = table.rowAtPoint(point);
int column = table.columnAtPoint(point);
table.editCellAt(row, column);
table.transferFocus();
}
}));
final Object value = column.getTable().getRow(primaryKeyValue).get(column.getName(), column.getType());
if (value != null) {
String urlString = value.toString();
if (urlString != null && (urlString.startsWith("http:") || urlString.startsWith("https:")))
menu.add(getOpenLinkMenu(value.toString()));
}
final PopupMenuGravityTracker tracker = new PopupMenuGravityTracker(menu);
for (final Map.Entry<TableCellTaskFactory, Map<?, ?>> mapEntry : tableCellFactoryMap.entrySet()) {
TableCellTaskFactory taskFactory = mapEntry.getKey();
TaskFactory provisioner = factoryProvisioner.createFor(taskFactory, column, primaryKeyValue);
createMenuItem(provisioner, tracker, mapEntry.getValue(), tableType);
}
if (tableType == CyNode.class || tableType == CyEdge.class) {
menu.add(new JSeparator());
final String name = String.format("Select %s from selected rows", tableType == CyNode.class ? "nodes" : "edges");
final JMenuItem mi = new JMenuItem(new AbstractAction(name) {
@Override
public void actionPerformed(ActionEvent e) {
selectElementsFromSelectedRows(table, tableType);
}
@Override
public boolean isEnabled() {
final CyApplicationManager applicationManager = serviceRegistrar.getService(CyApplicationManager.class);
return table.getSelectedRowCount() > 0 && applicationManager.getCurrentNetwork() != null;
}
});
menu.add(mi);
}
if (menu.getSubElements().length > 0)
menu.show(invoker, x, y);
}
Aggregations