Search in sources :

Example 6 with RuntimeInfo

use of org.erlide.runtime.runtimeinfo.RuntimeInfo in project erlide_eclipse by erlang.

the class AddRuntimeDialog method doOkPressed.

private void doOkPressed() {
    final RuntimeInfo info = new RuntimeInfo(fName.getText().trim(), fOtpHome.getText().trim(), fArgs.getText().trim(), fCodePath.getElements());
    fRequestor.itemAdded(info);
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo)

Example 7 with RuntimeInfo

use of org.erlide.runtime.runtimeinfo.RuntimeInfo in project erlide_eclipse by erlang.

the class RuntimePreferencePage method detectRuntimes.

protected void detectRuntimes() {
    final Collection<RuntimeInfo> found = RuntimeFinder.guessRuntimeLocations();
    for (final RuntimeInfo i : found) {
        if (!runtimes.contains(i)) {
            runtimes.add(i);
        }
    }
    fRuntimeList.refresh();
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo)

Example 8 with RuntimeInfo

use of org.erlide.runtime.runtimeinfo.RuntimeInfo in project erlide_eclipse by erlang.

the class RuntimePreferencePage method selectSingle.

private void selectSingle() {
    if (runtimes.size() == 1) {
        final RuntimeInfo vm = runtimes.iterator().next();
        fRuntimeList.setChecked(vm, true);
    }
    if (runtimes.size() > 1) {
        final RuntimeInfo vm = runtimes.iterator().next();
        if (fRuntimeList.getCheckedElements().length == 0) {
            fRuntimeList.setChecked(vm, true);
        }
    }
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo)

Example 9 with RuntimeInfo

use of org.erlide.runtime.runtimeinfo.RuntimeInfo in project erlide_eclipse by erlang.

the class RuntimePreferencePage method createMyControl.

private Control createMyControl(final Composite ancestor) {
    final Composite parent = new Composite(ancestor, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);
    final Font font = ancestor.getFont();
    parent.setFont(font);
    GridData data;
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    composite.setLayout(gridLayout);
    final Label erlideLabel = new Label(composite, SWT.NONE);
    erlideLabel.setToolTipText("The erlide runtime is used for IDE purposes, not for running project code. " + "It is the most recent stable version that is installed.");
    final String erlideName = erlideRuntime == null ? "none" : erlideRuntime.getName();
    erlideLabel.setText(RuntimePreferenceMessages.RuntimePreferencePage_erlideLabel_text + " " + erlideName);
    new Label(composite, SWT.NONE);
    new Label(parent, SWT.NONE);
    final Label tableLabel = new Label(parent, SWT.NONE);
    tableLabel.setText("Installed runtimes:");
    data = new GridData();
    data.horizontalSpan = 2;
    tableLabel.setLayoutData(data);
    tableLabel.setFont(font);
    final Table table = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                final RuntimeInfo ri = (RuntimeInfo) e.item.getData();
                defaultRuntime = ri;
            }
        }
    });
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.widthHint = 403;
    table.setLayoutData(data);
    table.setFont(font);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    final TableColumn column1 = new TableColumn(table, SWT.NULL);
    column1.setWidth(80);
    column1.setText(RuntimePreferenceMessages.name);
    column1.setResizable(true);
    column1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            sortByName();
        }
    });
    final TableColumn column2 = new TableColumn(table, SWT.NULL);
    column2.setWidth(150);
    column2.setText("Directory");
    column2.setResizable(true);
    column2.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            sortByDirectory();
        }
    });
    final TableColumn column3 = new TableColumn(table, SWT.NULL);
    column3.setWidth(80);
    column3.setText("Version");
    column3.setResizable(false);
    fRuntimeList = new CheckboxTableViewer(table);
    fRuntimeList.setLabelProvider(new RuntimeLabelProvider());
    fRuntimeList.setContentProvider(new RuntimeContentProvider());
    fRuntimeList.setInput(runtimes);
    if (defaultRuntime == null || defaultRuntime == RuntimeInfo.NO_RUNTIME_INFO) {
        defaultRuntime = RuntimeCore.getRuntimeInfoCatalog().getDefaultRuntime();
    }
    if (defaultRuntime != null) {
        fRuntimeList.setCheckedElements(new Object[] { defaultRuntime });
    }
    // by default, sort by name
    sortByName();
    fRuntimeList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent evt) {
            enableButtons();
        }
    });
    fRuntimeList.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            if (event.getChecked()) {
                setCheckedRuntime((RuntimeInfo) event.getElement());
            } else {
                setCheckedRuntime(null);
            }
        }
    });
    fRuntimeList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(final DoubleClickEvent e) {
            if (!fRuntimeList.getSelection().isEmpty()) {
                editRuntime();
            }
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                removeSelectedRuntimes();
            }
        }
    });
    final Composite buttons = new Composite(parent, SWT.NULL);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    buttons.setFont(font);
    fAddButton = createPushButton(buttons, RuntimePreferenceMessages.add);
    fAddButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            addRuntime();
        }
    });
    fEditButton = createPushButton(buttons, RuntimePreferenceMessages.edit);
    fEditButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            editRuntime();
        }
    });
    fDuplicateButton = createPushButton(buttons, RuntimePreferenceMessages.duplicate);
    fDuplicateButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            duplicateRuntime();
        }
    });
    fRemoveButton = createPushButton(buttons, RuntimePreferenceMessages.remove);
    fRemoveButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            removeSelectedRuntimes();
        }
    });
    fDetectButton = createPushButton(buttons, RuntimePreferenceMessages.detect);
    fDetectButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            detectRuntimes();
        }
    });
    configureTableResizing(parent, buttons, table, column1, column2, column3);
    enableButtons();
    return parent;
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) KeyEvent(org.eclipse.swt.events.KeyEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 10 with RuntimeInfo

use of org.erlide.runtime.runtimeinfo.RuntimeInfo in project erlide_eclipse by erlang.

the class RuntimePreferencePage method duplicateRuntime.

protected void duplicateRuntime() {
    final IStructuredSelection selection = (IStructuredSelection) fRuntimeList.getSelection();
    final RuntimeInfo vm = (RuntimeInfo) selection.getFirstElement();
    if (vm == null) {
        return;
    }
    final RuntimeInfo vm1 = new RuntimeInfo.Builder(vm).withName(vm.getName() + "_copy").build();
    final AddRuntimeDialog dialog = new AddRuntimeDialog(this, getShell(), vm1);
    dialog.setTitle(RuntimePreferenceMessages.edit_title);
    if (dialog.open() != Window.OK) {
        return;
    }
    fRuntimeList.refresh();
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

RuntimeInfo (org.erlide.runtime.runtimeinfo.RuntimeInfo)29 ArrayList (java.util.ArrayList)5 BackendData (org.erlide.backend.api.BackendData)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IBackend (org.erlide.backend.api.IBackend)4 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 RuntimeInfoCatalogData (org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData)3 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Text (org.eclipse.swt.widgets.Text)2 List (java.util.List)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1