Search in sources :

Example 1 with AbstractCyApp

use of org.cytoscape.app.AbstractCyApp 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)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 AbstractCyApp (org.cytoscape.app.AbstractCyApp)1 AppInstallException (org.cytoscape.app.internal.exception.AppInstallException)1