Search in sources :

Example 1 with AppInstallException

use of org.cytoscape.app.internal.exception.AppInstallException in project cytoscape-impl by cytoscape.

the class AppManager method installApp.

/**
 * Attempts to install an app. Makes a copy of the app file and places it in the directory
 * used to hold all installed and uninstalled apps, if it was not already present there. Then, the
 * app is created by instancing its class that extends {@link AbstractCyApp}.
 *
 * Before the app is installed, it is checked if it contains valid packaging by its isAppValidated() method.
 * Apps that have not been validated are ignored. Also, apps that are already installed are left alone.
 *
 * @param app The {@link App} object representing and providing information about the app to install
 * @throws AppInstallException If there was an error while attempting to install the app such as being
 * unable to copy the app to the installed apps directory or to instance the app's entry point class
 */
public void installApp(App app) throws AppInstallException {
    if (app.isBundledApp())
        return;
    boolean installOnRestart = false;
    if (app instanceof SimpleApp) {
        for (App regApp : apps) {
            if (app.getAppName().equalsIgnoreCase(regApp.getAppName()) && !app.isDetached()) {
                installOnRestart = true;
            }
        }
    }
    if (installOnRestart) {
        try {
            app.moveAppFile(this, new File(getInstallOnRestartAppsPath()));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            throw new AppInstallException("Unable to move app file", e);
        }
        checkForFileChanges();
        apps.add(app);
        app.setStatus(AppStatus.TO_BE_INSTALLED);
        fireAppsChangedEvent();
    } else {
        try {
            app.moveAppFile(this, new File(getInstalledAppsPath()));
        } catch (IOException e) {
            throw new AppInstallException("Unable to move app file", e);
        }
        checkForFileChanges();
    }
}
Also used : AbstractCyApp(org.cytoscape.app.AbstractCyApp) AppInstallException(org.cytoscape.app.internal.exception.AppInstallException) IOException(java.io.IOException) File(java.io.File)

Example 2 with AppInstallException

use of org.cytoscape.app.internal.exception.AppInstallException in project cytoscape-impl by cytoscape.

the class CurrentlyInstalledAppsPanel method enableSelectedButtonActionPerformed.

private void enableSelectedButtonActionPerformed(ActionEvent evt) {
    // Obtain App objects corresponding to currently selected table entries
    Set<App> selectedApps = getSelectedApps();
    for (App app : selectedApps) {
        // Only install apps that are not already installed
        if (app.getStatus() != AppStatus.INSTALLED) {
            try {
                appManager.installApp(app);
            } catch (AppInstallException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    enableSelectedButton.setEnabled(false);
    disableSelectedButton.setEnabled(true);
    uninstallSelectedButton.setEnabled(true);
}
Also used : BundleApp(org.cytoscape.app.internal.manager.BundleApp) App(org.cytoscape.app.internal.manager.App) SimpleApp(org.cytoscape.app.internal.manager.SimpleApp) AppInstallException(org.cytoscape.app.internal.exception.AppInstallException)

Aggregations

AppInstallException (org.cytoscape.app.internal.exception.AppInstallException)2 File (java.io.File)1 IOException (java.io.IOException)1 AbstractCyApp (org.cytoscape.app.AbstractCyApp)1 App (org.cytoscape.app.internal.manager.App)1 BundleApp (org.cytoscape.app.internal.manager.BundleApp)1 SimpleApp (org.cytoscape.app.internal.manager.SimpleApp)1