Search in sources :

Example 1 with WebApp

use of org.cytoscape.app.internal.net.WebApp in project cytoscape-impl by cytoscape.

the class InstallAppsPanel method updateDescriptionBox.

private void updateDescriptionBox() {
    TreePath selectedPath = resultsTree.getSelectionPath();
    if (selectedPath != null) {
        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) resultsTree.getSelectionPath().getLastPathComponent();
        WebApp selectedApp = (WebApp) selectedNode.getUserObject();
        boolean appAlreadyInstalled = (selectedApp.getCorrespondingApp() != null && selectedApp.getCorrespondingApp().getStatus() == AppStatus.INSTALLED);
        String text = "";
        // text += "<html> <head> </head> <body hspace=\"4\" vspace=\"4\">";
        text += "<html> <body hspace=\"4\" vspace=\"2\">";
        // App hyperlink to web store page
        // text += "<p style=\"margin-top: 0\"> <a href=\"" + selectedApp.getPageUrl() + "\">" + selectedApp.getPageUrl() + "</a> </p>";
        // App name, version
        text += "<b>" + selectedApp.getFullName() + "</b>";
        String latestReleaseVersion = selectedApp.getReleases().get(selectedApp.getReleases().size() - 1).getReleaseVersion();
        text += "<br />" + latestReleaseVersion;
        if (appAlreadyInstalled) {
            if (!selectedApp.getCorrespondingApp().getVersion().equalsIgnoreCase(latestReleaseVersion)) {
                text += " (installed: " + selectedApp.getCorrespondingApp().getVersion() + ")";
            }
        }
        /*
    		text += "<p>";
    		text += "<b>" + selectedApp.getFullName() + "</b>";
    		text += "<br />" + selectedApp.getReleases().get(selectedApp.getReleases().size() - 1).getReleaseVersion();
    		text += "</p>";
    		*/
        text += "<p>";
        // App image
        text += "<img border=\"0\" ";
        text += "src=\"" + appManager.getWebQuerier().getDefaultAppStoreUrl() + selectedApp.getIconUrl() + "\" alt=\"" + selectedApp.getFullName() + "\"/>";
        text += "</p>";
        // App description
        text += "<p>";
        text += (String.valueOf(selectedApp.getDescription()).equalsIgnoreCase("null") ? "App description not found." : selectedApp.getDescription());
        text += "</p>";
        text += "</body> </html>";
        descriptionTextPane.setText(text);
        this.selectedApp = selectedApp;
        if (appAlreadyInstalled) {
            installButton.setEnabled(false);
        } else {
            installButton.setEnabled(true);
        }
        viewOnAppStoreButton.setEnabled(true);
    } else {
        // descriptionTextPane.setText("App description is displayed here.");
        descriptionTextPane.setText("");
        this.selectedApp = null;
        installButton.setEnabled(false);
        viewOnAppStoreButton.setEnabled(false);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 2 with WebApp

use of org.cytoscape.app.internal.net.WebApp in project cytoscape-impl by cytoscape.

the class InstallAppsPanel method queryForApps.

// Queries the currently set app store url for available apps.
private void queryForApps() {
    if (hasTagTreeBeenPopulated)
        return;
    final WebQuerier webQuerier = appManager.getWebQuerier();
    taskManager.execute(new TaskIterator(new Task() {

        // Obtain information for all available apps, then append tag information
        @Override
        public void run(TaskMonitor taskMonitor) throws Exception {
            taskMonitor.setTitle("Getting available apps");
            taskMonitor.setStatusMessage("Obtaining apps from: " + webQuerier.getCurrentAppStoreUrl());
            Set<WebApp> availableApps = webQuerier.getAllApps();
            if (availableApps == null)
                return;
            // Once the information is obtained, update the tree
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    // populateTree(appManager.getWebQuerier().getAllApps());
                    buildTagsTree();
                    fillResultsTree(appManager.getWebQuerier().getAllApps());
                }
            });
        }

        @Override
        public void cancel() {
        }
    }));
}
Also used : Task(org.cytoscape.work.Task) InstallAppsFromFileTask(org.cytoscape.app.internal.task.InstallAppsFromFileTask) InstallAppsFromWebAppTask(org.cytoscape.app.internal.task.InstallAppsFromWebAppTask) ShowInstalledAppsIfChangedTask(org.cytoscape.app.internal.task.ShowInstalledAppsIfChangedTask) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) WebQuerier(org.cytoscape.app.internal.net.WebQuerier) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 3 with WebApp

use of org.cytoscape.app.internal.net.WebApp in project cytoscape-impl by cytoscape.

the class InstallAppsFromWebAppTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setTitle("Install from App Store");
    taskMonitor.setTitle("");
    DownloadStatus status = new DownloadStatus(taskMonitor);
    List<File> appFiles = new ArrayList<File>();
    for (WebApp webApp : webApps) {
        taskMonitor.setStatusMessage("Downloading " + webApp.getFullName());
        // Download app
        File appFile = appManager.getWebQuerier().downloadApp(webApp, null, new File(appManager.getDownloadedAppsPath()), status);
        if (appFile == null) {
            throw new Exception("Unable to find download URL for about-to-be-installed " + webApp.getFullName());
        }
        appFiles.add(appFile);
    }
    insertTasksAfterCurrentTask(new InstallAppsFromFileTask(appFiles, appManager, promptToReplace));
}
Also used : DownloadStatus(org.cytoscape.app.internal.net.DownloadStatus) ArrayList(java.util.ArrayList) File(java.io.File) WebApp(org.cytoscape.app.internal.net.WebApp)

Example 4 with WebApp

use of org.cytoscape.app.internal.net.WebApp in project cytoscape-impl by cytoscape.

the class InstallTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    if (app == null && file == null) {
        taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Neither app name nor file provided");
        return;
    }
    taskMonitor.setTitle("Installing app " + app);
    if (file != null) {
        InstallAppsFromFileTask installTask = new InstallAppsFromFileTask(Collections.singletonList(file), appManager, false);
        insertTasksAfterCurrentTask(installTask);
    } else {
        WebApp appObject = getWebApp(app);
        if (appObject == null) {
            taskMonitor.showMessage(TaskMonitor.Level.ERROR, "Can't find app '" + app + "'");
            return;
        }
        InstallAppsFromWebAppTask installTask = new InstallAppsFromWebAppTask(Collections.singletonList(appObject), appManager, false);
        insertTasksAfterCurrentTask(installTask);
    }
}
Also used : WebApp(org.cytoscape.app.internal.net.WebApp)

Example 5 with WebApp

use of org.cytoscape.app.internal.net.WebApp in project cytoscape-impl by cytoscape.

the class RetrieveTask method getPmidsOfApps.

/**
 * Return a map of app names to their PubMed IDs.
 */
private Map<String, String> getPmidsOfApps() {
    final Map<String, String> pmids = new HashMap<>();
    final Set<WebApp> allApps = webQuerier.getAllApps();
    webQuerier.checkWebAppInstallStatus(allApps, appManager);
    for (final WebApp app : allApps) {
        if (app.getCorrespondingApp() == null || app.getCorrespondingApp().getStatus() != App.AppStatus.INSTALLED)
            continue;
        if (app.getCitation() != null)
            pmids.put(app.getFullName(), app.getCitation());
    }
    return pmids;
}
Also used : HashMap(java.util.HashMap) WebApp(org.cytoscape.app.internal.net.WebApp)

Aggregations

WebApp (org.cytoscape.app.internal.net.WebApp)12 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 App (org.cytoscape.app.internal.manager.App)3 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)3 TaskIterator (org.cytoscape.work.TaskIterator)3 File (java.io.File)2 List (java.util.List)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 InstallAppsFromWebAppTask (org.cytoscape.app.internal.task.InstallAppsFromWebAppTask)2 Task (org.cytoscape.work.Task)2 TaskMonitor (org.cytoscape.work.TaskMonitor)2 Map (java.util.Map)1 Set (java.util.Set)1 TreePath (javax.swing.tree.TreePath)1 DownloadStatus (org.cytoscape.app.internal.net.DownloadStatus)1 Update (org.cytoscape.app.internal.net.Update)1 Release (org.cytoscape.app.internal.net.WebApp.Release)1