Search in sources :

Example 1 with IProcessorType

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

the class LaunchHelper method hydrateOutputProperties.

public static LaunchProperties hydrateOutputProperties(ILaunchConfiguration configuration) throws CoreException {
    LaunchProperties properties = new LaunchProperties();
    // configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_USE_PROPERTIES_FROM_PREFERENCES,
    boolean usePreferenceProperties = false;
    // true);
    IProcessorType pt = getProcessorInstall(configuration).getProcessorType();
    if (usePreferenceProperties) {
        for (Map.Entry<String, String> entry : pt.getOutputPropertyValues().entrySet()) {
            String name = entry.getKey();
            String value = entry.getValue();
            properties.setProperty(name, value);
        }
    } else {
        String s = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_OUTPUT_PROPERTIES, (String) null);
        if (s != null && s.length() > 0) {
            ByteArrayInputStream inputStream = new ByteArrayInputStream(s.getBytes());
            properties = LaunchProperties.fromXML(inputStream);
        }
    }
    return properties;
}
Also used : LaunchProperties(org.eclipse.wst.xsl.jaxp.launching.LaunchProperties) ByteArrayInputStream(java.io.ByteArrayInputStream) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) Map(java.util.Map)

Example 2 with IProcessorType

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

the class ProcessorTypeRegistry method getProcessorTypes.

public IProcessorType[] getProcessorTypes() {
    if (installTypes == null) {
        List<ProcessorType> types = new ArrayList<ProcessorType>();
        String featureXMLString = JAXPLaunchingPlugin.getDefault().getPluginPreferences().getString(JAXPRuntime.PREF_FEATURE_XML);
        // If the preference was found, load VMs from it into memory
        FeaturePreferences prefs = null;
        if (featureXMLString.length() > 0) {
            try {
                ByteArrayInputStream inputStream = new ByteArrayInputStream(featureXMLString.getBytes());
                prefs = FeaturePreferences.fromXML(inputStream);
            } catch (CoreException e) {
                JAXPLaunchingPlugin.log(e);
            }
        }
        String propXMLString = JAXPLaunchingPlugin.getDefault().getPluginPreferences().getString(JAXPRuntime.PREF_OUTPUT_PROPERTIES_XML);
        // If the preference was found, load VMs from it into memory
        OutputPropertyPreferences outputprefs = null;
        if (propXMLString.length() > 0) {
            try {
                ByteArrayInputStream inputStream = new ByteArrayInputStream(propXMLString.getBytes());
                outputprefs = OutputPropertyPreferences.fromXML(inputStream);
            } catch (CoreException e) {
                JAXPLaunchingPlugin.log(e);
            }
        }
        for (Iterator<IConfigurationElement> iter = elements.iterator(); iter.hasNext(); ) {
            IConfigurationElement element = iter.next();
            String id = element.getAttribute(ProcessorTypeRegistryReader.ATT_ID);
            String label = element.getAttribute(ProcessorTypeRegistryReader.ATT_LABEL);
            Map<String, String> featureValues = new HashMap<String, String>();
            Map<String, String> propertyValues = new HashMap<String, String>();
            if (prefs != null && prefs.getFeaturesValues(id) != null)
                featureValues.putAll(prefs.getFeaturesValues(id));
            if (outputprefs != null && outputprefs.getOutputPropertyValues(id) != null)
                propertyValues.putAll(outputprefs.getOutputPropertyValues(id));
            String outputProperties = element.getAttribute(ProcessorTypeRegistryReader.ATT_OUTPUT_PROPERTIES);
            URL outputPropertiesURL = FileLocator.find(Platform.getBundle(element.getContributor().getName()), new Path(outputProperties), null);
            String featureProperties = element.getAttribute(ProcessorTypeRegistryReader.ATT_ATTRIBUTE_PROPERTIES);
            URL featurePropertiesURL = FileLocator.find(Platform.getBundle(element.getContributor().getName()), new Path(featureProperties), null);
            List<ITransformerFactory> transFactoryList = new ArrayList<ITransformerFactory>();
            IConfigurationElement[] transFactEls = element.getChildren(ProcessorTypeRegistryReader.EL_TRANSFORMER_FACTORY);
            for (IConfigurationElement transFactEl : transFactEls) {
                String transFactoryName = transFactEl.getAttribute(ProcessorTypeRegistryReader.ATT_TRANSFORMER_FACTORY_NAME);
                String transFactoryClass = transFactEl.getAttribute(ProcessorTypeRegistryReader.ATT_TRANSFORMER_FACTORY_CLASS);
                transFactoryList.add(new TransformerFactory(transFactoryName, transFactoryClass));
            }
            types.add(new ProcessorType(id, label, featurePropertiesURL, outputPropertiesURL, featureValues, propertyValues, transFactoryList.toArray(new ITransformerFactory[0])));
        }
        installTypes = types.toArray(new IProcessorType[0]);
    }
    return installTypes;
}
Also used : Path(org.eclipse.core.runtime.Path) ITransformerFactory(org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory) TransformerFactory(org.eclipse.wst.xsl.jaxp.launching.internal.TransformerFactory) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) ProcessorType(org.eclipse.wst.xsl.jaxp.launching.internal.ProcessorType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeaturePreferences(org.eclipse.wst.xsl.jaxp.launching.internal.FeaturePreferences) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) URL(java.net.URL) OutputPropertyPreferences(org.eclipse.wst.xsl.jaxp.launching.internal.OutputPropertyPreferences) ITransformerFactory(org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 3 with IProcessorType

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

the class ProcessorTypeRegistry method getProcessorTypesExclJREDefault.

public IProcessorType[] getProcessorTypesExclJREDefault() {
    IProcessorType[] installTypes = getProcessorTypes();
    List<IProcessorType> exclTypes = new ArrayList<IProcessorType>(installTypes.length - 1);
    for (IProcessorType type : installTypes) {
        if (!type.isJREDefault())
            exclTypes.add(type);
    }
    return exclTypes.toArray(new IProcessorType[0]);
}
Also used : ArrayList(java.util.ArrayList) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType)

Example 4 with IProcessorType

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

the class AddProcessorDialog method createDialogFields.

protected void createDialogFields(Composite parent) {
    GridData gd;
    Label label;
    label = new Label(parent, SWT.NONE);
    label.setText(Messages.AddProcessorDialog_processorName);
    processorNameField = new Text(parent, SWT.BORDER);
    gd = new GridData(SWT.NONE, SWT.NONE, false, false);
    gd.widthHint = convertWidthInCharsToPixels(50);
    gd.horizontalSpan = 2;
    processorNameField.setLayoutData(gd);
    label = new Label(parent, SWT.NONE);
    label.setText(Messages.AddProcessorDialog_processorType);
    processorTypeField = new ComboViewer(parent, SWT.READ_ONLY);
    gd = new GridData();
    gd.horizontalSpan = 2;
    processorTypeField.getCombo().setLayoutData(gd);
    processorTypeField.setContentProvider(new IStructuredContentProvider() {

        private Object input;

        public Object[] getElements(Object inputElement) {
            return (IProcessorType[]) input;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            input = newInput;
        }
    });
    processorTypeField.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IProcessorType) element).getLabel();
        }
    });
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Text(org.eclipse.swt.widgets.Text) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 5 with IProcessorType

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

the class InstalledProcessorsBlock method fillWithWorkspaceProcessors.

protected void fillWithWorkspaceProcessors() {
    List<InstallStandin> standins = new ArrayList<InstallStandin>();
    IProcessorType[] types = JAXPRuntime.getProcessorTypes();
    for (IProcessorType type : types) {
        IProcessorInstall[] installs = JAXPRuntime.getProcessors(type.getId());
        for (IProcessorInstall install : installs) {
            standins.add(new InstallStandin(install));
        }
    }
    setProcessors(standins.toArray(new IProcessorInstall[standins.size()]));
}
Also used : ArrayList(java.util.ArrayList) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) InstallStandin(org.eclipse.wst.xsl.jaxp.debug.ui.internal.tabs.processor.InstallStandin)

Aggregations

IProcessorType (org.eclipse.wst.xsl.jaxp.launching.IProcessorType)8 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ArrayList (java.util.ArrayList)3 ITransformerFactory (org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory)3 Map (java.util.Map)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)2 LabelProvider (org.eclipse.jface.viewers.LabelProvider)2 Viewer (org.eclipse.jface.viewers.Viewer)2 GridData (org.eclipse.swt.layout.GridData)2 Label (org.eclipse.swt.widgets.Label)2 IProcessorInstall (org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 Path (org.eclipse.core.runtime.Path)1 IPreferencePage (org.eclipse.jface.preference.IPreferencePage)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1