Search in sources :

Example 1 with RuntimeInfoCatalogData

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

the class RuntimePreferencePage method performOk.

@Override
public boolean performOk() {
    if (defaultRuntime == null || defaultRuntime == RuntimeInfo.NO_RUNTIME_INFO) {
        defaultRuntime = (RuntimeInfo) fRuntimeList.getElementAt(0);
    }
    if (erlideRuntime == null) {
        erlideRuntime = defaultRuntime;
    }
    boolean restart = false;
    final RuntimeInfo oldDefault = catalog.getDefaultRuntime();
    if (oldDefault != RuntimeInfo.NO_RUNTIME_INFO && !defaultRuntime.equals(oldDefault)) {
        restart = RestartDialog.openQuestion(getShell());
    }
    catalog.setRuntimes(runtimes, defaultRuntime.getName(), erlideRuntime.getName());
    final RuntimeInfoPreferencesSerializer serializer = new RuntimeInfoPreferencesSerializer();
    serializer.store(new RuntimeInfoCatalogData(runtimes, defaultRuntime.getName(), erlideRuntime.getName()));
    // save column widths
    final IDialogSettings settings = ErlideUIPlugin.getDefault().getDialogSettings();
    saveColumnSettings(settings, RuntimePreferencePage.RUNTIMES_PREFERENCE_PAGE);
    if (restart) {
        new UIJob("restart") {

            @Override
            public IStatus runInUIThread(final IProgressMonitor monitor) {
                PlatformUI.getWorkbench().restart();
                return Status.OK_STATUS;
            }
        }.schedule(100);
    }
    return super.performOk();
}
Also used : RuntimeInfoPreferencesSerializer(org.erlide.backend.runtimeinfo.RuntimeInfoPreferencesSerializer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) RuntimeInfoCatalogData(org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData) UIJob(org.eclipse.ui.progress.UIJob)

Example 2 with RuntimeInfoCatalogData

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

the class RuntimeCore method getRuntimeInfoCatalog.

public static final synchronized IRuntimeInfoCatalog getRuntimeInfoCatalog(final IRuntimeInfoSerializer serializer) {
    if (RuntimeCore.runtimeInfoCatalog == null) {
        final RuntimeInfoCatalogData data = serializer.load();
        RuntimeCore.runtimeInfoCatalog = new RuntimeInfoCatalog();
        RuntimeCore.runtimeInfoCatalog.setRuntimes(data.runtimes, data.defaultRuntimeName, data.erlideRuntimeName);
        final RuntimeInfo runtime = RuntimeCore.runtimeInfoCatalog.getErlideRuntime();
        if (!HostnameChecker.getInstance().detectHostNames(runtime.getOtpHome())) {
            // XXX show troubleshooting page and re-detect
            ErlLogger.error("no matching hostnames found!! Edit ~/.erlide.hosts");
        }
    }
    return RuntimeCore.runtimeInfoCatalog;
}
Also used : IRuntimeInfoCatalog(org.erlide.runtime.runtimeinfo.IRuntimeInfoCatalog) RuntimeInfoCatalog(org.erlide.runtime.runtimeinfo.RuntimeInfoCatalog) RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) RuntimeInfoCatalogData(org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData)

Example 3 with RuntimeInfoCatalogData

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

the class RuntimeInfoPreferencesSerializer method load.

@Override
public synchronized RuntimeInfoCatalogData load() {
    RuntimeInfoCatalogData data = new RuntimeInfoCatalogData();
    data = loadPrefs(data, RuntimeInfoPreferencesSerializer.getDefaultOldRootNode());
    data = loadPrefs(data, defaultRootNode);
    data = loadPrefs(data, RuntimeInfoPreferencesSerializer.getInstanceOldRootNode());
    data = loadPrefs(data, instanceRootNode);
    String dflt = null;
    String ide = null;
    if (!data.runtimes.isEmpty()) {
        dflt = data.defaultRuntimeName != null ? data.defaultRuntimeName : data.runtimes.iterator().next().getName();
        ide = data.erlideRuntimeName != null ? data.erlideRuntimeName : dflt;
    }
    return new RuntimeInfoCatalogData(data.runtimes, dflt, ide);
}
Also used : RuntimeInfoCatalogData(org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData)

Example 4 with RuntimeInfoCatalogData

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

the class RuntimeInfoPreferencesSerializer method loadPrefs.

private RuntimeInfoCatalogData loadPrefs(final RuntimeInfoCatalogData data, final IEclipsePreferences root) {
    String[] children;
    final Collection<RuntimeInfo> runtimes = new ArrayList<>(data.runtimes);
    try {
        children = root.childrenNames();
        for (final String name : children) {
            final RuntimeInfo rt = RuntimeInfoLoader.load(root.node(name));
            runtimes.add(rt);
        }
    } catch (final BackingStoreException e) {
        ErlLogger.warn(e);
    }
    final String defaultRuntimeName = root.get(RuntimeInfoPreferencesSerializer.DEFAULT_KEY, data.defaultRuntimeName);
    final String ideRuntimeName = root.get(RuntimeInfoPreferencesSerializer.ERLIDE_KEY, data.erlideRuntimeName);
    return new RuntimeInfoCatalogData(runtimes, defaultRuntimeName, ideRuntimeName);
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) ArrayList(java.util.ArrayList) BackingStoreException(org.osgi.service.prefs.BackingStoreException) RuntimeInfoCatalogData(org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData)

Aggregations

RuntimeInfoCatalogData (org.erlide.runtime.runtimeinfo.RuntimeInfoCatalogData)4 RuntimeInfo (org.erlide.runtime.runtimeinfo.RuntimeInfo)3 ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)1 UIJob (org.eclipse.ui.progress.UIJob)1 RuntimeInfoPreferencesSerializer (org.erlide.backend.runtimeinfo.RuntimeInfoPreferencesSerializer)1 IRuntimeInfoCatalog (org.erlide.runtime.runtimeinfo.IRuntimeInfoCatalog)1 RuntimeInfoCatalog (org.erlide.runtime.runtimeinfo.RuntimeInfoCatalog)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1