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);
}
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.");
}
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;
}
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();
}
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);
}
Aggregations