Search in sources :

Example 21 with App

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

the class ResolveAppDependenciesTask method resolveAppDependencies.

private void resolveAppDependencies(App appToInstall) throws Exception {
    CyVersion version = appManager.getCyVersion();
    if (!appToInstall.isCompatible(version))
        throw new Exception("Unable to install " + appToInstall.getAppName() + ".\nIt is incompatible with this version of Cytoscape (" + version.getVersion() + ").");
    taskMonitor.setStatusMessage("Resolving dependencies for " + appToInstall.getAppName() + "...");
    for (App installedApp : appManager.getInstalledApps()) {
        if (installedApp.getAppName().equals(appToInstall.getAppName())) {
            appsToReplace.put(appToInstall, installedApp);
            break;
        }
    }
    dependencyStack.push(appToInstall.getAppName());
    if (appToInstall.getDependencies() != null)
        for (App.Dependency dep : appToInstall.getDependencies()) {
            if (dependencyStack.contains(dep.getName()))
                throw new Exception("Invalid circular dependency: " + dep.getName());
            else if (findAppForDep(dep, appsToInstall) != null)
                continue;
            else if (findAppForDep(dep, appManager.getInstalledApps()) != null)
                continue;
            else {
                App dependencyApp = findAppForDep(dep, appQueue);
                if (dependencyApp != null) {
                    appQueue.remove(dependencyApp);
                } else {
                    Set<WebApp> webApps = appManager.getWebQuerier().getAllApps();
                    if (webApps == null)
                        throw new Exception("Cannot access the App Store to resolve dependencies. Please check your internet connection.");
                    WebApp webApp = findWebAppForDep(dep, webApps);
                    if (webApp == null)
                        throw new Exception("Cannot find dependency: " + dependencyStack.firstElement() + " requires " + dep.getName() + ", which is not available in the App Store");
                    List<Release> releases = webApp.getReleases();
                    Release latestRelease = releases.get(releases.size() - 1);
                    if (WebQuerier.compareVersions(dep.getVersion(), latestRelease.getReleaseVersion()) >= 0) {
                        taskMonitor.setStatusMessage("Downloading dependency for " + dependencyStack.firstElement() + ": " + webApp.getFullName());
                        File appFile = appManager.getWebQuerier().downloadApp(webApp, null, new File(appManager.getDownloadedAppsPath()), status);
                        dependencyApp = appManager.getAppParser().parseApp(appFile);
                    } else
                        throw new Exception("Cannot find dependency: " + dependencyStack.firstElement() + " requires " + dep.getName() + " " + dep.getVersion() + " or later, latest release in App Store is " + latestRelease.getReleaseVersion());
                }
                resolveAppDependencies(dependencyApp);
            }
        }
    dependencyStack.pop();
    appsToInstall.add(appToInstall);
}
Also used : App(org.cytoscape.app.internal.manager.App) WebApp(org.cytoscape.app.internal.net.WebApp) Set(java.util.Set) CyVersion(org.cytoscape.application.CyVersion) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) File(java.io.File) Release(org.cytoscape.app.internal.net.WebApp.Release) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 22 with App

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

the class InstallAppsFromFileTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setTitle("Install from File");
    taskMonitor.setTitle("");
    List<App> apps = new ArrayList<App>();
    for (File appFile : appFiles) {
        App app = appManager.getAppParser().parseApp(appFile);
        apps.add(app);
    }
    taskMonitor.setStatusMessage("Starting install...");
    insertTasksAfterCurrentTask(new ResolveAppDependenciesTask(apps, appManager, promptToReplace));
}
Also used : App(org.cytoscape.app.internal.manager.App) ArrayList(java.util.ArrayList) File(java.io.File)

Example 23 with App

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

the class WebQuerier method checkForUpdates.

public Set<Update> checkForUpdates(Set<App> apps, AppManager appManager) {
    Set<Update> updates = new HashSet<Update>();
    Update update;
    for (App app : apps) {
        for (String url : appsByUrl.keySet()) {
            update = checkForUpdate(app, url, appManager);
            if (update != null) {
                updates.add(update);
                break;
            }
        }
    }
    return updates;
}
Also used : App(org.cytoscape.app.internal.manager.App) HashSet(java.util.HashSet)

Example 24 with App

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

the class AppStoreTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    WebApp webApp = null;
    if (app != null) {
        webApp = getWebApp(app);
        url = APP_STORE + "apps/" + app;
    } else {
        url = APP_STORE;
    }
    // Do we have access to the CyBrowser?
    App cyBrowser = getApp("cybrowser");
    // System.out.println("cybrowser: "+cyBrowser);
    if (useCybrowser == true && cyBrowser != null && cyBrowser.getStatus() == App.AppStatus.INSTALLED) {
        CommandExecutorTaskFactory commandTF = serviceRegistrar.getService(CommandExecutorTaskFactory.class);
        TaskManager<?, ?> taskManager = serviceRegistrar.getService(TaskManager.class);
        // Yes, use it!
        Map<String, Object> args = new HashMap<>();
        args.put("url", url);
        args.put("id", "AppStore");
        TaskIterator ti = commandTF.createTaskIterator("cybrowser", "dialog", args, null);
        taskManager.execute(ti);
    } else {
        // No, use the standard open browser
        OpenBrowser openBrowser = serviceRegistrar.getService(OpenBrowser.class);
        openBrowser.openURL(url);
    }
}
Also used : App(org.cytoscape.app.internal.manager.App) WebApp(org.cytoscape.app.internal.net.WebApp) TaskIterator(org.cytoscape.work.TaskIterator) OpenBrowser(org.cytoscape.util.swing.OpenBrowser) CommandExecutorTaskFactory(org.cytoscape.command.CommandExecutorTaskFactory) HashMap(java.util.HashMap) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 25 with App

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

the class AbstractAppTask method getApp.

protected App getApp(String appName) {
    List<App> matchingApps = new ArrayList<App>();
    for (App app : appList) {
        if (appName.equalsIgnoreCase(app.getAppName()))
            if (app.getStatus() == AppStatus.INSTALLED)
                return app;
        matchingApps.add(app);
    }
    if (matchingApps.size() == 0)
        return null;
    // OK, we have multiple matching apps.  Find the latest version
    // and return that one
    Collections.sort(matchingApps, new VersionCompare());
    return matchingApps.get(matchingApps.size() - 1);
}
Also used : App(org.cytoscape.app.internal.manager.App) WebApp(org.cytoscape.app.internal.net.WebApp) ArrayList(java.util.ArrayList)

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