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);
}
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();
}
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);
}
}
}
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;
}
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();
}
Aggregations