Search in sources :

Example 1 with IProcessorJar

use of org.eclipse.wst.xsl.jaxp.launching.IProcessorJar 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 IProcessorJar

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

the class ProcessorPreferences method elementAsJars.

private static IProcessorJar[] elementAsJars(Element element) {
    // $NON-NLS-1$
    Element[] jarEls = PreferenceUtil.getChildElements(element, "jar");
    List<ProcessorJar> jars = new ArrayList<ProcessorJar>(jarEls.length);
    for (Element jarEl : jarEls) {
        Node node = jarEl.getFirstChild();
        if (node != null && node.getNodeType() == Node.TEXT_NODE) {
            String path = ((Text) node).getNodeValue();
            jars.add(new ProcessorJar(Path.fromPortableString(path)));
        }
    }
    return jars.toArray(new IProcessorJar[0]);
}
Also used : IProcessorJar(org.eclipse.wst.xsl.jaxp.launching.IProcessorJar) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) Text(org.w3c.dom.Text)

Example 3 with IProcessorJar

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

the class ProcessorPreferences method jarsAsElement.

private static Element jarsAsElement(Document doc, IProcessorJar[] jars) {
    // $NON-NLS-1$
    Element jarsEl = doc.createElement("jars");
    for (IProcessorJar jar : jars) {
        if (jar != null && jar.getPath() != null) {
            // $NON-NLS-1$
            Element jarEl = doc.createElement("jar");
            Text text = doc.createTextNode(jar.getPath().toPortableString());
            jarEl.appendChild(text);
            jarsEl.appendChild(jarEl);
        }
    }
    return jarsEl;
}
Also used : Element(org.w3c.dom.Element) IProcessorJar(org.eclipse.wst.xsl.jaxp.launching.IProcessorJar) Text(org.w3c.dom.Text)

Example 4 with IProcessorJar

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

the class ProcessorRegistry method addProcessor.

public void addProcessor(String bundleId, String id, String label, String processorTypeId, String classpath, String debuggerId, String supports) {
    IProcessorJar[] jars = ProcessorInstall.createJars(bundleId, classpath);
    contributedInstalls.add(new ProcessorInstall(id, label, processorTypeId, jars, debuggerId, supports, true));
}
Also used : ProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.ProcessorInstall) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IProcessorJar(org.eclipse.wst.xsl.jaxp.launching.IProcessorJar)

Example 5 with IProcessorJar

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

the class ProcessorLibraryBlock method addWorkspace.

private void addWorkspace(IStructuredSelection selection) {
    IDialogSettings dialogSettings = XSLDebugUIPlugin.getDefault().getDialogSettings();
    String lastUsedPath = dialogSettings.get(LAST_WORKSPACE_PATH_SETTING);
    IPath lastPath = null;
    if (lastUsedPath != null) {
        lastPath = Path.fromPortableString(lastUsedPath);
    }
    // IResource currentResource = getResource();
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(tableViewer.getControl().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
    dialog.setTitle(Messages.ProcessorLibraryBlock_WorkspaceFileDialog_Title);
    dialog.setMessage(Messages.ProcessorLibraryBlock_WorkspaceFileDialog_Message);
    dialog.setValidator(validator);
    dialog.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IContainer)
                return true;
            else if (element instanceof IFile) {
                IFile file = (IFile) element;
                String extension = file.getFileExtension();
                if (extension == null)
                    return false;
                // $NON-NLS-1$
                return extension.equals("jar");
            }
            return false;
        }
    });
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (lastPath != null)
        dialog.setInitialSelection(lastPath);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setAllowMultiple(true);
    if (dialog.open() == Window.OK) {
        Object[] elements = dialog.getResult();
        if (elements.length > 0) {
            IProcessorJar[] libs = new IProcessorJar[elements.length];
            for (int i = 0; i < elements.length; i++) {
                IFile jar = (IFile) elements[i];
                libs[i] = JAXPRuntime.createProcessorJar(jar.getFullPath());
            }
            IProcessorJar[] currentJars = install.getProcessorJars();
            IProcessorJar[] newJars = new IProcessorJar[currentJars.length + libs.length];
            System.arraycopy(currentJars, 0, newJars, 0, currentJars.length);
            System.arraycopy(libs, 0, newJars, currentJars.length, libs.length);
            install.setProcessorJars(newJars);
            tableViewer.add(libs);
            lastPath = libs[0].getPath();
            lastPath = lastPath.uptoSegment(lastPath.segmentCount());
            dialogSettings.put(LAST_WORKSPACE_PATH_SETTING, lastPath.toPortableString());
        }
    }
}
Also used : ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IProcessorJar(org.eclipse.wst.xsl.jaxp.launching.IProcessorJar) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) IContainer(org.eclipse.core.resources.IContainer)

Aggregations

IProcessorJar (org.eclipse.wst.xsl.jaxp.launching.IProcessorJar)8 IPath (org.eclipse.core.runtime.IPath)3 IProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)3 Element (org.w3c.dom.Element)3 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 ProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.ProcessorInstall)2 Text (org.w3c.dom.Text)2 File (java.io.File)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1