Search in sources :

Example 56 with CyApplicationManager

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);
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager)

Example 57 with CyApplicationManager

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());
                }
            });
        }
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyNetwork(org.cytoscape.model.CyNetwork)

Example 58 with CyApplicationManager

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();
    }
}
Also used : CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) CyTableManager(org.cytoscape.model.CyTableManager)

Example 59 with CyApplicationManager

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);
}
Also used : NetworkSearchMediator(org.cytoscape.internal.view.NetworkSearchMediator) SettingsAction(org.cytoscape.internal.layout.ui.SettingsAction) CytoscapeToolBar(org.cytoscape.internal.view.CytoscapeToolBar) ExportNetworkAction(org.cytoscape.internal.actions.ExportNetworkAction) ToolBarEnableUpdater(org.cytoscape.internal.view.ToolBarEnableUpdater) CytoscapeDesktop(org.cytoscape.internal.view.CytoscapeDesktop) SelectNodeViewUpdater(org.cytoscape.internal.select.SelectNodeViewUpdater) RedoAction(org.cytoscape.internal.undo.RedoAction) CloseWindowAction(org.cytoscape.internal.actions.CloseWindowAction) HelpReportABugTaskFactory(org.cytoscape.internal.view.help.HelpReportABugTaskFactory) RowViewTracker(org.cytoscape.internal.select.RowViewTracker) StarterPanelAction(org.cytoscape.internal.actions.StarterPanelAction) DetachedViewToolBarAction(org.cytoscape.internal.actions.DetachedViewToolBarAction) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) DestroyNetworkViewsAction(org.cytoscape.internal.actions.DestroyNetworkViewsAction) ArrangeTaskFactory(org.cytoscape.internal.view.help.ArrangeTaskFactory) NetworkViewMainPanel(org.cytoscape.internal.view.NetworkViewMainPanel) LayoutSettingsManager(org.cytoscape.internal.layout.ui.LayoutSettingsManager) DestroyNetworksAction(org.cytoscape.internal.actions.DestroyNetworksAction) CyApplicationManager(org.cytoscape.application.CyApplicationManager) SessionIO(org.cytoscape.internal.io.SessionIO) NetworkViewMediator(org.cytoscape.internal.view.NetworkViewMediator) LayoutMenuPopulator(org.cytoscape.internal.layout.ui.LayoutMenuPopulator) NetworkSearchBar(org.cytoscape.internal.view.NetworkSearchBar) ExitAction(org.cytoscape.internal.actions.ExitAction) SelectEdgeViewUpdater(org.cytoscape.internal.select.SelectEdgeViewUpdater) BookmarkDialogFactory(org.cytoscape.internal.dialogs.BookmarkDialogFactory) PrintAction(org.cytoscape.internal.actions.PrintAction) NetworkMainPanel(org.cytoscape.internal.view.NetworkMainPanel) CreateNetworkViewsAction(org.cytoscape.internal.actions.CreateNetworkViewsAction) GridViewToggleModel(org.cytoscape.internal.view.GridViewToggleModel) RowsSetViewUpdater(org.cytoscape.internal.select.RowsSetViewUpdater) NetworkMediator(org.cytoscape.internal.view.NetworkMediator) BookmarkAction(org.cytoscape.internal.actions.BookmarkAction) CytoscapeMenuPopulator(org.cytoscape.internal.view.CytoscapeMenuPopulator) RecentSessionManager(org.cytoscape.internal.actions.RecentSessionManager) PreferenceAction(org.cytoscape.internal.actions.PreferenceAction) NetworkSelectionMediator(org.cytoscape.internal.view.NetworkSelectionMediator) ExportImageAction(org.cytoscape.internal.actions.ExportImageAction) CommandToolDialog(org.cytoscape.internal.command.CommandToolDialog) CytoPanelAction(org.cytoscape.internal.actions.CytoPanelAction) HelpAboutTaskFactory(org.cytoscape.internal.view.help.HelpAboutTaskFactory) UndoMonitor(org.cytoscape.internal.util.undo.UndoMonitor) PreferencesDialogFactory(org.cytoscape.internal.dialogs.PreferencesDialogFactory) CytoscapeMenus(org.cytoscape.internal.view.CytoscapeMenus) CytoscapeMenuBar(org.cytoscape.internal.view.CytoscapeMenuBar) HelpUserManualTaskFactory(org.cytoscape.internal.view.help.HelpUserManualTaskFactory) HelpContactHelpDeskTaskFactory(org.cytoscape.internal.view.help.HelpContactHelpDeskTaskFactory) CyDesktopManager(org.cytoscape.internal.view.CyDesktopManager) UndoAction(org.cytoscape.internal.undo.UndoAction)

Example 60 with CyApplicationManager

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);
}
Also used : ActionEvent(java.awt.event.ActionEvent) Point(java.awt.Point) ValidatedObjectAndEditString(org.cytoscape.browser.internal.util.ValidatedObjectAndEditString) CyEdge(org.cytoscape.model.CyEdge) JPopupMenu(javax.swing.JPopupMenu) Point(java.awt.Point) TableCellTaskFactory(org.cytoscape.task.TableCellTaskFactory) JSeparator(javax.swing.JSeparator) CyApplicationManager(org.cytoscape.application.CyApplicationManager) PopupMenuGravityTracker(org.cytoscape.util.swing.PopupMenuGravityTracker) TaskFactory(org.cytoscape.work.TaskFactory) TableColumnTaskFactory(org.cytoscape.task.TableColumnTaskFactory) TableCellTaskFactory(org.cytoscape.task.TableCellTaskFactory) CyNode(org.cytoscape.model.CyNode) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CyApplicationManager (org.cytoscape.application.CyApplicationManager)80 CyNetwork (org.cytoscape.model.CyNetwork)40 CyNetworkView (org.cytoscape.view.model.CyNetworkView)30 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)18 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)16 CyNetworkManager (org.cytoscape.model.CyNetworkManager)14 CyEventHelper (org.cytoscape.event.CyEventHelper)12 CyTable (org.cytoscape.model.CyTable)12 ArrayList (java.util.ArrayList)11 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)10 CyNode (org.cytoscape.model.CyNode)9 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)9 Test (org.junit.Test)9 HashSet (java.util.HashSet)8 CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)8 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)8 TaskIterator (org.cytoscape.work.TaskIterator)8 HashMap (java.util.HashMap)7 CyGroupManager (org.cytoscape.group.CyGroupManager)7 CyTableManager (org.cytoscape.model.CyTableManager)7