Search in sources :

Example 16 with App

use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.

the class CurrentlyInstalledAppsPanel method setupAppListener.

/**
 * Registers a listener to the {@link AppManager} to listen for app change events in order to rebuild the table
 */
private void setupAppListener() {
    appListener = new AppsChangedListener() {

        @Override
        public void appsChanged(AppsChangedEvent event) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    Set<App> selectedApps = getSelectedApps();
                    // Clear table
                    DefaultTableModel tableModel = (DefaultTableModel) appsAvailableTable.getModel();
                    for (int rowIndex = tableModel.getRowCount() - 1; rowIndex >= 0; rowIndex--) {
                        tableModel.removeRow(rowIndex);
                    }
                    // Re-populate table
                    populateTable();
                    // Update labels
                    updateLabels();
                    // Re-select previously selected apps
                    for (int rowIndex = 0; rowIndex < tableModel.getRowCount(); rowIndex++) {
                        if (selectedApps.contains(tableModel.getValueAt(rowIndex, 0))) {
                            appsAvailableTable.addRowSelectionInterval(rowIndex, rowIndex);
                        }
                    }
                }
            });
        }
    };
    appManager.addAppListener(appListener);
}
Also used : BundleApp(org.cytoscape.app.internal.manager.BundleApp) App(org.cytoscape.app.internal.manager.App) SimpleApp(org.cytoscape.app.internal.manager.SimpleApp) DefaultTableModel(javax.swing.table.DefaultTableModel) AppsChangedListener(org.cytoscape.app.internal.event.AppsChangedListener) AppsChangedEvent(org.cytoscape.app.internal.event.AppsChangedEvent)

Example 17 with App

use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.

the class CurrentlyInstalledAppsPanel method updateLabels.

/**
 * Update the labels that display the number of currently installed and available apps.
 */
private void updateLabels() {
    int listedCount = 0;
    for (App app : appManager.getApps()) {
        // Count the number of displayed apps
        if (!app.isHidden()) {
            listedCount++;
        } else {
            DebugHelper.print(this, "Hidden app: " + app.getAppName() + ", status: " + app.getStatus());
        }
    }
    appsInstalledLabel.setText(listedCount + " App(s) listed.");
}
Also used : BundleApp(org.cytoscape.app.internal.manager.BundleApp) App(org.cytoscape.app.internal.manager.App) SimpleApp(org.cytoscape.app.internal.manager.SimpleApp)

Example 18 with App

use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.

the class CurrentlyInstalledAppsPanel method getSelectedApps.

/**
 * Obtain the set of {@link App} objects corresponding to currently selected entries in the table of apps
 * @return A set of {@link App} objects corresponding to selected apps in the table
 */
private Set<App> getSelectedApps() {
    Set<App> selectedApps = new HashSet<>();
    int[] selectedRows = appsAvailableTable.getSelectedRows();
    for (int index = 0; index < selectedRows.length; index++) {
        App app = (App) appsAvailableTable.getModel().getValueAt(appsAvailableTable.convertRowIndexToModel(selectedRows[index]), 0);
        selectedApps.add(app);
    }
    return selectedApps;
}
Also used : BundleApp(org.cytoscape.app.internal.manager.BundleApp) App(org.cytoscape.app.internal.manager.App) SimpleApp(org.cytoscape.app.internal.manager.SimpleApp) HashSet(java.util.HashSet)

Example 19 with App

use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.

the class CurrentlyInstalledAppsPanel method populateTable.

/**
 * Populate the table of apps by obtaining the list of currently available apps from the AppManager object.
 */
private void populateTable() {
    DefaultTableModel tableModel = (DefaultTableModel) appsAvailableTable.getModel();
    for (App app : appManager.getApps()) {
        // Hide apps with certain statuses from the table, such as uninstalled ones.
        if (app.isHidden()) {
        // Do nothing
        // DebugHelper.print(this, "Detached app: " + app.getAppName() + ", status: " + app.getStatus());
        } else {
            tableModel.addRow(new Object[] { app, app.getAppFile() != null ? app.getAppName() : app.getAppName() + " (File moved)", app.getVersion(), app.getReadableStatus() });
        }
    }
    updateLabels();
}
Also used : BundleApp(org.cytoscape.app.internal.manager.BundleApp) App(org.cytoscape.app.internal.manager.App) SimpleApp(org.cytoscape.app.internal.manager.SimpleApp) DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 20 with App

use of org.cytoscape.app.internal.manager.App in project cytoscape-impl by cytoscape.

the class ListUpdatesTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setTitle("Listing available apps");
    WebQuerier webQuerier = appManager.getWebQuerier();
    Set<App> apps = appManager.getInstalledApps();
    updates = webQuerier.checkForUpdates(apps, appManager);
}
Also used : App(org.cytoscape.app.internal.manager.App) WebQuerier(org.cytoscape.app.internal.net.WebQuerier)

Aggregations

App (org.cytoscape.app.internal.manager.App)25 WebApp (org.cytoscape.app.internal.net.WebApp)11 BundleApp (org.cytoscape.app.internal.manager.BundleApp)8 SimpleApp (org.cytoscape.app.internal.manager.SimpleApp)8 ArrayList (java.util.ArrayList)4 File (java.io.File)3 HashSet (java.util.HashSet)3 TaskIterator (org.cytoscape.work.TaskIterator)3 Dimension (java.awt.Dimension)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 BoxLayout (javax.swing.BoxLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 JTextArea (javax.swing.JTextArea)2 DefaultTableModel (javax.swing.table.DefaultTableModel)2 Release (org.cytoscape.app.internal.net.WebApp.Release)2 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)2