Search in sources :

Example 11 with IBackend

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

the class ConsoleRemoveLaunchAction method getLaunch.

protected ILaunch getLaunch() {
    if (fConsoleView == null) {
        return fLaunch;
    }
    // else get dynamically, as this action was created via plug-in XML view
    // contribution
    final IConsole console = fConsoleView.getConsole();
    if (console instanceof ErlangConsole) {
        final ErlangConsole pconsole = (ErlangConsole) console;
        final IBackend backend = pconsole.getBackend();
        return backend.getData().getLaunch();
    }
    return null;
}
Also used : ErlangConsole(org.erlide.ui.console.ErlangConsole) IBackend(org.erlide.backend.api.IBackend) IConsole(org.eclipse.ui.console.IConsole)

Example 12 with IBackend

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

the class ControlPanelView method createNodeButtonsPanel.

private void createNodeButtonsPanel(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new RowLayout());
    // "Add" button
    Button button = new Button(container, SWT.PUSH | SWT.CENTER);
    button.setText("New node");
    button.setToolTipText("Add new node you want to trace");
    button.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            TraceBackend.getInstance().addTracedNode(new TracedNode());
            nodesTableViewer.refresh();
        }
    });
    // "Remove" button
    button = new Button(container, SWT.PUSH | SWT.CENTER);
    button.setText("Remove node");
    button.setToolTipText("Remove selected node");
    button.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final TracedNode tracedNode = (TracedNode) ((IStructuredSelection) nodesTableViewer.getSelection()).getFirstElement();
            if (tracedNode != null) {
                TraceBackend.getInstance().removeTracedNode(tracedNode);
                nodesTableViewer.refresh();
            }
        }
    });
    // "Add erlide nodes" button
    button = new Button(container, SWT.PUSH | SWT.CENTER);
    button.setText("Add existing nodes");
    button.setToolTipText("Add all Erlang nodes started directly from eclipse");
    button.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            for (final IBackend backend : NodeHelper.getBackends(true)) {
                final TracedNode node = new TracedNode();
                node.setNodeName(backend.getName());
                TraceBackend.getInstance().addTracedNode(node);
            }
            nodesTableViewer.refresh();
        }
    });
    // Pattern config buttons
    final Button loadConfigButton = new Button(container, SWT.PUSH | SWT.CENTER);
    final Button deleteConfigButton = new Button(container, SWT.PUSH | SWT.CENTER);
    final Button saveConfigButton = new Button(container, SWT.PUSH | SWT.CENTER);
    final Button saveAsConfigButton = new Button(container, SWT.PUSH | SWT.CENTER);
    final Label configNameLabel = new Label(container, SWT.NULL);
    configNameLabel.setLayoutData(new RowData(120, SWT.DEFAULT));
    // "Load nodes config" button
    loadConfigButton.setToolTipText("Load nodes configuration...");
    loadConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER));
    loadConfigButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final ElementListSelectionDialog dialog = new SelectConfigurationDialog(parent.getShell(), new LabelProvider());
            dialog.setElements(ConfigurationManager.getNodesConfig());
            dialog.open();
            final String result = (String) dialog.getFirstResult();
            if (result != null) {
                nodesConfigName = result;
                configNameLabel.setText(nodesConfigName);
                TraceBackend.getInstance().loadTracedNodes(ConfigurationManager.loadNodesConfig(nodesConfigName));
                nodesTableViewer.refresh();
            }
        }
    });
    // "Delete nodes configuration" button
    deleteConfigButton.setToolTipText("Delete current node configuration...");
    deleteConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_REMOVE));
    deleteConfigButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (nodesConfigName != null) {
                final MessageBox messageBox = new MessageBox(parent.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
                messageBox.setMessage("Delete \"" + nodesConfigName + "\"?");
                messageBox.setText("Delete configuration");
                if (messageBox.open() == SWT.YES) {
                    ConfigurationManager.removeNodesConfig(nodesConfigName);
                    nodesConfigName = null;
                    configNameLabel.setText("");
                }
            }
        }
    });
    // "Save nodes configuration" button
    saveConfigButton.setToolTipText("Save current nodes configuration");
    saveConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
    saveConfigButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (nodesConfigName != null) {
                if (!ConfigurationManager.saveNodesConfig(nodesConfigName)) {
                    final MessageBox messageBox = new MessageBox(parent.getShell(), SWT.ICON_ERROR | SWT.OK);
                    messageBox.setMessage("Unable to save configuration: " + nodesConfigName);
                    messageBox.setText("Error");
                    messageBox.open();
                }
            }
        }
    });
    // "Save nodes configuration as..." button
    saveAsConfigButton.setToolTipText("Save current nodes configuration as...");
    saveAsConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVEAS_EDIT));
    saveAsConfigButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final String[] configurations = ConfigurationManager.getNodesConfig();
            final Set<String> existingNames = new HashSet<>(Arrays.asList(configurations));
            final InputDialog dialog = new ConfigurationSaveAsDialog(parent.getShell(), "Save nodes configuration", "Enter name for configuration:", nodesConfigName, existingNames);
            if (dialog.open() == Window.OK) {
                if (ConfigurationManager.saveNodesConfig(dialog.getValue())) {
                    nodesConfigName = dialog.getValue();
                    configNameLabel.setText(nodesConfigName);
                } else {
                    final MessageBox messageBox = new MessageBox(parent.getShell(), SWT.ICON_ERROR | SWT.OK);
                    messageBox.setMessage("Unable to save configuration: " + dialog.getValue());
                    messageBox.setText("Error");
                    messageBox.open();
                }
            }
        }
    });
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TracedNode(org.erlide.tracing.core.mvc.model.TracedNode) SelectConfigurationDialog(org.erlide.tracing.core.ui.dialogs.SelectConfigurationDialog) MessageBox(org.eclipse.swt.widgets.MessageBox) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) RowLayout(org.eclipse.swt.layout.RowLayout) IBackend(org.erlide.backend.api.IBackend) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ConfigurationSaveAsDialog(org.erlide.tracing.core.ui.dialogs.ConfigurationSaveAsDialog) NodeLabelProvider(org.erlide.tracing.core.mvc.view.NodeLabelProvider) TracePatternLabelProvider(org.erlide.tracing.core.mvc.view.TracePatternLabelProvider) ProcessLabelProvider(org.erlide.tracing.core.mvc.view.ProcessLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 13 with IBackend

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

the class TraceBackend method createBackend.

private IBackend createBackend() {
    final RuntimeInfo erlideRuntime = BackendCore.getRuntimeInfoCatalog().getErlideRuntime();
    if (erlideRuntime == null) {
        return null;
    }
    final RuntimeInfo info = new RuntimeInfo(erlideRuntime);
    try {
        final BackendData data = getBackendData(info);
        data.setUseStartShell(true);
        final IBackend b = BackendCore.getBackendManager().createExecutionBackend(data);
        return b;
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
    return null;
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) BackendData(org.erlide.backend.api.BackendData) IBackend(org.erlide.backend.api.IBackend) RpcException(org.erlide.runtime.rpc.RpcException)

Example 14 with IBackend

use of org.erlide.backend.api.IBackend 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 15 with IBackend

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

the class ConsoleTerminateAction method update.

@Override
public void update() {
    final IBackend backend = fConsole.getBackend();
    setEnabled(backend.isRunning() && backend != BackendCore.getBackendManager().getIdeBackend());
}
Also used : IBackend(org.erlide.backend.api.IBackend)

Aggregations

IBackend (org.erlide.backend.api.IBackend)25 IBackendManager (org.erlide.backend.api.IBackendManager)6 CoreException (org.eclipse.core.runtime.CoreException)4 IErlProject (org.erlide.engine.model.root.IErlProject)4 RuntimeInfo (org.erlide.runtime.runtimeinfo.RuntimeInfo)4 BackendData (org.erlide.backend.api.BackendData)3 ErlModelException (org.erlide.engine.model.ErlModelException)3 IErlModel (org.erlide.engine.model.root.IErlModel)3 HashSet (java.util.HashSet)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 ILaunch (org.eclipse.debug.core.ILaunch)2 BackendException (org.erlide.backend.api.BackendException)2 RpcException (org.erlide.runtime.rpc.RpcException)2 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1