Search in sources :

Example 1 with ProcessorPreferences

use of org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorPreferences in project webtools.sourceediting by eclipse.

the class ProcessorRegistry method addPersistedVMs.

private void addPersistedVMs() {
    // Try retrieving the VM preferences from the preference store
    String vmXMLString = JAXPLaunchingPlugin.getDefault().getPluginPreferences().getString(JAXPRuntime.PREF_PROCESSOR_XML);
    // If the preference was found, load VMs from it into memory
    if (vmXMLString.length() > 0) {
        try {
            ByteArrayInputStream inputStream = new ByteArrayInputStream(vmXMLString.getBytes());
            ProcessorPreferences prefs = ProcessorPreferences.fromXML(inputStream);
            String defaultProcessorId = prefs.getDefaultProcessorId();
            userInstalls = prefs.getProcessors();
            for (Iterator<IProcessorInstall> iter = userInstalls.iterator(); iter.hasNext(); ) {
                IProcessorInstall install = iter.next();
                if (install.getId().equals(defaultProcessorId)) {
                    defaultProcessor = install;
                }
            }
            if (defaultProcessor == null) {
                for (Iterator<ProcessorInstall> iter = contributedInstalls.iterator(); iter.hasNext(); ) {
                    IProcessorInstall install = iter.next();
                    if (defaultProcessor == null && install.getId().equals(defaultProcessorId)) {
                        defaultProcessor = install;
                    }
                }
            }
        } catch (CoreException e) {
            JAXPLaunchingPlugin.log(e);
        }
    }
    // make the JRE the default default
    if (defaultProcessor == null) {
        defaultProcessor = jreDefaultProcessor;
    }
}
Also used : ProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.ProcessorInstall) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) ProcessorPreferences(org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorPreferences) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)

Example 2 with ProcessorPreferences

use of org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorPreferences in project webtools.sourceediting by eclipse.

the class JAXPRuntime method saveProcessorPreferences.

public static void saveProcessorPreferences(IProcessorInstall[] installs, IProcessorInstall defaultInstall, IProgressMonitor monitor) throws CoreException {
    if (monitor.isCanceled())
        return;
    try {
        monitor.beginTask(Messages.XSLTRuntime_9, 100);
        ProcessorPreferences prefs = new ProcessorPreferences();
        if (defaultInstall != null)
            prefs.setDefaultProcessorId(defaultInstall.getId());
        prefs.setProcessors(new ArrayList<IProcessorInstall>(Arrays.asList(installs)));
        String xml = prefs.getAsXML();
        monitor.worked(40);
        if (monitor.isCanceled())
            return;
        JAXPRuntime.getPreferences().setValue(JAXPRuntime.PREF_PROCESSOR_XML, xml);
        monitor.worked(30);
        if (monitor.isCanceled())
            return;
        JAXPRuntime.savePreferences();
        monitor.worked(30);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, Messages.XSLTRuntime_10, e));
    } finally {
        monitor.done();
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ProcessorPreferences(org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorPreferences) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)2 ProcessorPreferences (org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorPreferences)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)1 ProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.ProcessorInstall)1