Search in sources :

Example 1 with IProcessorInstall

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

the class JAXPJavaLaunchConfigurationDelegate method getVMArguments.

@Override
public String getVMArguments(ILaunchConfiguration configuration) throws CoreException {
    String vmargs = super.getVMArguments(configuration);
    IProcessorInstall install = getProcessorInstall(configuration, mode);
    if (install != null && !install.getProcessorType().isJREDefault()) {
        // clear the endorsed dir
        File tempDir = getEndorsedDir();
        if (tempDir.exists()) {
            File[] children = tempDir.listFiles();
            for (File child : children) {
                child.delete();
            }
            tempDir.delete();
        }
        tempDir.mkdir();
        // move the required jars to the endorsed dir
        IProcessorJar[] jars = install.getProcessorJars();
        for (int i = 0; i < jars.length; i++) {
            URL entry = jars[i].asURL();
            if (entry == null)
                throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XSLTLaunchConfigurationDelegate_23 + jars[i], null));
            // $NON-NLS-1$ //$NON-NLS-2$
            File file = new File(tempDir, "END_" + i + ".jar");
            moveFile(entry, file);
        }
        // add the endorsed dir
        // $NON-NLS-1$ //$NON-NLS-2$
        vmargs += " -Djava.endorsed.dirs=\"" + tempDir.getAbsolutePath() + "\"";
        String tfactory = getTransformerFactory(install);
        if (tfactory != null)
            // $NON-NLS-1$
            vmargs += " -Djavax.xml.transform.TransformerFactory=" + tfactory;
    // if (ILaunchManager.DEBUG_MODE.equals(mode))
    // {
    // // in debug mode, set the logging to ERROR. This prevents the
    // console from popping up on top of the result view!
    // try
    // {
    // URL url =
    // FileLocator.resolve(FileLocator.find(Platform.getBundle(JAXPLaunchingPlugin.PLUGIN_ID),
    // new Path("/log4j.debug.properties"), null));
    // vmargs += " -Dlog4j.configuration=\""+url.toExternalForm()+"\""; //$NON-NLS-1$
    // }
    // catch (IOException e)
    // {
    // JAXPLaunchingPlugin.log(e);
    // }
    // }
    }
    return vmargs;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IProcessorJar(org.eclipse.wst.xsl.jaxp.launching.IProcessorJar) File(java.io.File) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) URL(java.net.URL)

Example 2 with IProcessorInstall

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

the class JAXPJavaLaunchConfigurationDelegate method getClasspath.

@Override
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
    // get the classpath defined by the user
    String[] userClasspath = super.getClasspath(configuration);
    // get the classpath required for the transformation
    IProcessorInvoker invoker = getProcessorInvokerDescriptor(configuration);
    List<String> invokerCP = new ArrayList<String>();
    for (String entry : invoker.getClasspathEntries()) {
        invokerCP.add(entry);
    }
    // add the debugger...
    IProcessorInstall install = getProcessorInstall(configuration, mode);
    if (ILaunchManager.DEBUG_MODE.equals(mode) && install.getDebugger() != null) {
        String[] jars = install.getDebugger().getClassPath();
        for (String jar : jars) {
            invokerCP.add(jar);
        }
    }
    String[] invokerClasspath = invokerCP.toArray(new String[0]);
    // add them together
    String[] classpath = new String[userClasspath.length + invokerClasspath.length];
    System.arraycopy(invokerClasspath, 0, classpath, 0, invokerClasspath.length);
    System.arraycopy(userClasspath, 0, classpath, invokerClasspath.length, userClasspath.length);
    return classpath;
}
Also used : IProcessorInvoker(org.eclipse.wst.xsl.jaxp.launching.IProcessorInvoker) ArrayList(java.util.ArrayList) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)

Example 3 with IProcessorInstall

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

the class ProcessorPreferences method getAsXML.

public String getAsXML() throws ParserConfigurationException, IOException, TransformerException {
    Document doc = PreferenceUtil.getDocument();
    // $NON-NLS-1$
    Element config = doc.createElement("processorSettings");
    doc.appendChild(config);
    // Set the defaultVM attribute on the top-level node
    if (defaultProcessorId != null) {
        // $NON-NLS-1$
        config.setAttribute("defaultProcessor", defaultProcessorId);
    }
    for (Iterator<IProcessorInstall> iter = processors.iterator(); iter.hasNext(); ) {
        IProcessorInstall install = iter.next();
        if (!install.isContributed()) {
            Element vmTypeElement = installAsElement(doc, install);
            config.appendChild(vmTypeElement);
        }
    }
    // Serialize the Document and return the resulting String
    return PreferenceUtil.serializeDocument(doc);
}
Also used : Element(org.w3c.dom.Element) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) Document(org.w3c.dom.Document)

Example 4 with IProcessorInstall

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

the class ProcessorsPreferencePage method createContents.

@Override
protected Control createContents(Composite ancestor) {
    initializeDialogUnits(ancestor);
    noDefaultAndApplyButton();
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    ancestor.setLayout(layout);
    processorsBlock = new InstalledProcessorsBlock();
    processorsBlock.createControl(ancestor);
    Control control = processorsBlock.getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 1;
    control.setLayoutData(data);
    // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp...
    initDefaultInstall();
    processorsBlock.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IProcessorInstall install = getCurrentDefaultProcessor();
            if (install == null) {
                setValid(false);
                setErrorMessage(Messages.ProcessorsPreferencePage_2);
            } else {
                setValid(true);
                setErrorMessage(null);
            }
        }
    });
    applyDialogFont(ancestor);
    return ancestor;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 5 with IProcessorInstall

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

the class ProcessorsPreferencePage method performOk.

@Override
public boolean performOk() {
    processorsBlock.saveColumnSettings();
    final boolean[] ok = new boolean[1];
    try {
        final IProcessorInstall[] installs = processorsBlock.getProcessors();
        final IProcessorInstall defaultProcessor = getCurrentDefaultProcessor();
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    JAXPRuntime.saveProcessorPreferences(installs, defaultProcessor, monitor);
                } catch (CoreException e) {
                    XSLDebugUIPlugin.log(e);
                }
                ok[0] = !monitor.isCanceled();
            }
        };
        XSLDebugUIPlugin.getDefault().getWorkbench().getProgressService().busyCursorWhile(runnable);
    } catch (InvocationTargetException e) {
        XSLDebugUIPlugin.log(e);
    } catch (InterruptedException e) {
        XSLDebugUIPlugin.log(e);
    }
    return ok[0];
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

IProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 ProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.ProcessorInstall)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Font (org.eclipse.swt.graphics.Font)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 IProcessorInvoker (org.eclipse.wst.xsl.jaxp.launching.IProcessorInvoker)2 IProcessorJar (org.eclipse.wst.xsl.jaxp.launching.IProcessorJar)2 IProcessorType (org.eclipse.wst.xsl.jaxp.launching.IProcessorType)2 ITransformerFactory (org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory)2 Element (org.w3c.dom.Element)2