Search in sources :

Example 1 with IBackendManager

use of org.erlide.backend.api.IBackendManager in project erlide_eclipse by erlang.

the class BackendFactory method createBackend.

@Override
public synchronized IBackend createBackend(final BackendData data) {
    ErlLogger.debug("Create backend " + data.getNodeName());
    final IBackend b;
    final IOtpNodeProxy runtime = createNodeProxy(data);
    final IBackendManager backendManager = BackendCore.getBackendManager();
    b = data.isInternal() ? new Backend(data, runtime, backendManager) : new ExternalBackend(data, runtime, backendManager);
    b.initialize(data.getContext(), backendManager.getCodeBundles());
    runtime.ensureRunning();
    return b;
}
Also used : IBackend(org.erlide.backend.api.IBackend) IBackendManager(org.erlide.backend.api.IBackendManager) IBackend(org.erlide.backend.api.IBackend) IOtpNodeProxy(org.erlide.runtime.api.IOtpNodeProxy)

Example 2 with IBackendManager

use of org.erlide.backend.api.IBackendManager in project erlide_eclipse by erlang.

the class BuilderHelper method loadModule.

public static void loadModule(@NonNull final IProject project, final String module) {
    try {
        final IBackendManager backendManager = BackendCore.getBackendManager();
        for (final IBackend b : backendManager.getExecutionBackends(project)) {
            ErlLogger.debug(":: loading %s in %s", module, b.getName());
            final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
            final IPath path = project.getLocation().append(erlProject.getProperties().getOutputDir()).append(module + ".beam");
            boolean ok = false;
            final OtpErlangBinary bin = BeamUtil.getBeamBinary(module, path);
            if (bin != null) {
                ok = BeamLoader.loadBeam(b.getOtpRpc(), module, bin);
            }
            if (!ok) {
                ErlLogger.error("Could not load %s", module);
            }
            backendManager.moduleLoaded(b, project, module);
        }
    } catch (final Exception e) {
        ErlLogger.debug(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackendManager(org.erlide.backend.api.IBackendManager) IPath(org.eclipse.core.runtime.IPath) IBackend(org.erlide.backend.api.IBackend) OtpErlangBinary(com.ericsson.otp.erlang.OtpErlangBinary) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) RpcException(org.erlide.runtime.rpc.RpcException)

Example 3 with IBackendManager

use of org.erlide.backend.api.IBackendManager in project erlide_eclipse by erlang.

the class SendToConsoleAction method getConsole.

private IErlangConsole getConsole(@NonNull final IProject aproject) {
    final IBackendManager backendManager = BackendCore.getBackendManager();
    final Set<IBackend> executionBackends = backendManager.getExecutionBackends(aproject);
    final ErlConsoleManager erlConsoleManager = ErlideUIPlugin.getDefault().getErlConsoleManager();
    IErlangConsole result = null;
    for (final IBackend backend : executionBackends) {
        result = erlConsoleManager.getConsole(backend);
        if (result != null) {
            break;
        }
    }
    return result;
}
Also used : IBackendManager(org.erlide.backend.api.IBackendManager) IBackend(org.erlide.backend.api.IBackend) IErlangConsole(org.erlide.ui.console.IErlangConsole) ErlConsoleManager(org.erlide.ui.console.ErlConsoleManager)

Example 4 with IBackendManager

use of org.erlide.backend.api.IBackendManager in project erlide_eclipse by erlang.

the class NodeHelper method getBackends.

/**
 * Returns backends managed by erlide. Depending on argument nodes irrelevant
 * from user's point of view (tracing and ide backends) can be omitted in
 * resulting list.
 *
 * @param ignore
 *            if nodes should be omitted
 * @return list of backends
 */
public static Collection<? extends @NonNull IBackend> getBackends(final boolean ignore) {
    if (!ignore) {
        return BackendCore.getBackendManager().getAllBackends();
    }
    final List<@NonNull IBackend> backends = new ArrayList<>();
    final IBackendManager backendManager = BackendCore.getBackendManager();
    final Set<IBackend> ignored = new HashSet<>();
    IBackend backend;
    if ((backend = backendManager.getIdeBackend()) != null) {
        ignored.add(backend);
    }
    if ((backend = TraceBackend.getInstance().getBackend(false)) != null) {
        ignored.add(backend);
    }
    for (final IBackend erlideBackend : BackendCore.getBackendManager().getAllBackends()) {
        if (!ignored.contains(erlideBackend)) {
            backends.add(erlideBackend);
        }
    }
    return backends;
}
Also used : IBackendManager(org.erlide.backend.api.IBackendManager) IBackend(org.erlide.backend.api.IBackend) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 5 with IBackendManager

use of org.erlide.backend.api.IBackendManager in project erlide_eclipse by erlang.

the class ConsoleTerminateAction method run.

@Override
public void run() {
    try {
        final IBackend backend = fConsole.getBackend();
        final ILaunch launch = backend.getData().getLaunch();
        if (launch != null) {
            terminate(launch);
            final Collection<IProject> projects = Lists.newArrayList(backend.getData().getProjects());
            final IBackendManager backendManager = BackendCore.getBackendManager();
            for (final IProject project : projects) {
                backendManager.removeExecutionBackend(project, backend);
            }
            setEnabled(false);
            fConsole.stop();
        }
        if (!backend.equals(BackendCore.getBackendManager().getIdeBackend())) {
            backend.dispose();
        }
    } catch (final DebugException e) {
        ErlLogger.error(e);
    }
}
Also used : IBackendManager(org.erlide.backend.api.IBackendManager) IBackend(org.erlide.backend.api.IBackend) ILaunch(org.eclipse.debug.core.ILaunch) DebugException(org.eclipse.debug.core.DebugException) IProject(org.eclipse.core.resources.IProject)

Aggregations

IBackendManager (org.erlide.backend.api.IBackendManager)7 IBackend (org.erlide.backend.api.IBackend)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 DebugException (org.eclipse.debug.core.DebugException)1 ILaunch (org.eclipse.debug.core.ILaunch)1 IBackendFactory (org.erlide.backend.api.IBackendFactory)1 ErlModelException (org.erlide.engine.model.ErlModelException)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 IOtpNodeProxy (org.erlide.runtime.api.IOtpNodeProxy)1 RpcException (org.erlide.runtime.rpc.RpcException)1 IRuntimeInfoCatalog (org.erlide.runtime.runtimeinfo.IRuntimeInfoCatalog)1 ErlConsoleManager (org.erlide.ui.console.ErlConsoleManager)1 IErlangConsole (org.erlide.ui.console.IErlangConsole)1