Search in sources :

Example 16 with IProcessorInstall

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

the class InstalledProcessorsBlock method setProcessors.

protected void setProcessors(IProcessorInstall[] vms) {
    processors.clear();
    for (IProcessorInstall element : vms) {
        processors.add(element);
    }
    tableViewer.setInput(processors);
// tableViewer.refresh();
}
Also used : IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)

Example 17 with IProcessorInstall

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

Example 18 with IProcessorInstall

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

the class ProcessorBlock method createControl.

public void createControl(Composite parent) {
    Font font = parent.getFont();
    Composite group = new Composite(parent, SWT.NULL);
    setControl(group);
    group.setLayout(new GridLayout(2, false));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setFont(font);
    // group.setText(ProcessorMessages.ProcessorBlock_0);
    usePreferencesRadio = new Button(group, SWT.RADIO);
    usePreferencesRadio.setText(ProcessorMessages.ProcessorBlock_1);
    usePreferencesRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            preferencesSelected();
            updateLaunchConfigurationDialog();
        }
    });
    alterPreferencesButton = new Button(group, SWT.PUSH);
    alterPreferencesButton.setText(ProcessorMessages.ProcessorBlock_2);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.widthHint = 150;
    alterPreferencesButton.setLayoutData(gd);
    alterPreferencesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IPreferencePage page = new ProcessorsPreferencePage();
            // $NON-NLS-1$
            showPrefPage("org.eclipse.wst.xslt.launching.ui.preferences.ProcessorPreferencePage", page);
        }
    });
    overridePreferencesRadio = new Button(group, SWT.RADIO);
    overridePreferencesRadio.setText(ProcessorMessages.ProcessorBlock_4);
    overridePreferencesRadio.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            overrideSelected();
            updateLaunchConfigurationDialog();
        }
    });
    installedProcessorsButton = new Button(group, SWT.PUSH);
    installedProcessorsButton.setText(ProcessorMessages.ProcessorsComboBlock_1);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.widthHint = 150;
    installedProcessorsButton.setLayoutData(gd);
    installedProcessorsButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IPreferencePage page = new ProcessorsPreferencePage();
            // $NON-NLS-1$
            showPrefPage("org.eclipse.wst.xslt.launching.ui.preferences.ProcessorPreferencePage", page);
        }
    });
    Composite settingsComp = new Composite(group, SWT.NONE);
    GridLayout gl = new GridLayout(3, false);
    gl.marginHeight = 2;
    settingsComp.setLayout(gl);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalIndent = 15;
    gd.horizontalSpan = 2;
    settingsComp.setLayoutData(gd);
    settingsComp.setFont(font);
    Label label = new Label(settingsComp, SWT.NONE);
    label.setText(ProcessorMessages.ProcessorBlock_6);
    runCombo = new Combo(settingsComp, SWT.READ_ONLY | SWT.SINGLE);
    runCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    runComboViewer = new ComboViewer(runCombo);
    runComboViewer.setContentProvider(new ComboContentProvider());
    runComboViewer.setLabelProvider(new ComboLabelProvider());
    runComboViewer.setInput(JAXPRuntime.getProcessors());
    runComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (!sel.isEmpty()) {
                IProcessorInstall processor = (IProcessorInstall) sel.getFirstElement();
                if (processor.getProcessorType().getTransformerFactories().length > 1)
                    factoryComboViewer.getCombo().setVisible(true);
                else
                    factoryComboViewer.getCombo().setVisible(false);
                factoryComboViewer.setInput(processor.getProcessorType());
                boolean found = false;
                for (ITransformerFactory tf : processor.getProcessorType().getTransformerFactories()) {
                    if (tf.equals(currentFactory)) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    currentFactory = processor.getProcessorType().getDefaultTransformerFactory();
                    if (currentFactory != null)
                        factoryComboViewer.setSelection(new StructuredSelection(currentFactory));
                }
            }
            updateLaunchConfigurationDialog();
        }
    });
    Combo factoryCombo = new Combo(settingsComp, SWT.READ_ONLY | SWT.SINGLE);
    factoryCombo.setLayoutData(new GridData(80, SWT.DEFAULT));
    factoryComboViewer = new ComboViewer(factoryCombo);
    factoryComboViewer.setContentProvider(new IStructuredContentProvider() {

        private IProcessorType type;

        public Object[] getElements(Object inputElement) {
            return type.getTransformerFactories();
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            this.type = (IProcessorType) newInput;
        }
    });
    factoryComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            ITransformerFactory f = (ITransformerFactory) element;
            // + " - " + f.getFactoryClass();
            return f.getName();
        }
    });
    factoryComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            currentFactory = (ITransformerFactory) ((IStructuredSelection) event.getSelection()).getFirstElement();
            updateLaunchConfigurationDialog();
        }
    });
// overridePreferencesButton = new Button(group,SWT.CHECK);
// overridePreferencesButton.setText("Override preferences");
// gd = new GridData(SWT.NONE,SWT.NONE,false,false);
// overridePreferencesButton.setLayoutData(gd);
// overridePreferencesButton.addSelectionListener(new SelectionListener(){
// public void widgetDefaultSelected(SelectionEvent e)
// {}
// 
// public void widgetSelected(SelectionEvent e)
// {
// firePreferenceProcessorChanged(overridePreferencesButton.getSelection());
// }
// });
}
Also used : Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) ITransformerFactory(org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ProcessorsPreferencePage(org.eclipse.wst.xsl.jaxp.debug.ui.internal.preferences.ProcessorsPreferencePage) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IProcessorType(org.eclipse.wst.xsl.jaxp.launching.IProcessorType) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IPreferencePage(org.eclipse.jface.preference.IPreferencePage) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 19 with IProcessorInstall

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

the class JAXPJavaLaunchConfigurationDelegate method preLaunchCheck.

@Override
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    this.launchHelper = new LaunchHelper(configuration);
    if (mode.equals(ILaunchManager.DEBUG_MODE)) {
        // TODO don't like having UI code in the launching plugin...where
        // else can it go?
        final IProcessorInstall install = getProcessorInstall(configuration, ILaunchManager.RUN_MODE);
        if (install.getDebugger() == null) {
            final boolean[] result = new boolean[] { false };
            // open a dialog for choosing a different install that does have
            // an associated debugger
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                public void run() {
                    String debuggingInstallId = JAXPLaunchingPlugin.getDefault().getPluginPreferences().getString(JAXPLaunchConfigurationConstants.ATTR_DEFAULT_DEBUGGING_INSTALL_ID);
                    IProcessorInstall processor = JAXPRuntime.getProcessor(debuggingInstallId);
                    IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    String title = Messages.XSLTLaunchConfigurationDelegate_0;
                    String message = Messages.XSLTLaunchConfigurationDelegate_1 + install.getName() + Messages.XSLTLaunchConfigurationDelegate_2 + Messages.XSLTLaunchConfigurationDelegate_3 + processor.getName() + Messages.XSLTLaunchConfigurationDelegate_4;
                    MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, // yes
                    0);
                    // is
                    // the
                    // default
                    result[0] = dialog.open() == 0;
                }
            });
            return result[0];
        } else {
            String debuggerTF = install.getDebugger().getTransformerFactory();
            String installTF = launchHelper.getTransformerFactory() == null ? null : launchHelper.getTransformerFactory().getFactoryClass();
            if (!debuggerTF.equals(installTF)) {
                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                    public void run() {
                        IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                        String title = Messages.JAXPJavaLaunchConfigurationDelegate_0;
                        String message = install.getName() + Messages.JAXPJavaLaunchConfigurationDelegate_1 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_2 + Messages.JAXPJavaLaunchConfigurationDelegate_3 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_4;
                        MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, // yes is the default
                        0);
                        dialog.open();
                    }
                });
            }
        }
    }
    return super.preLaunchCheck(configuration, mode, monitor);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 20 with IProcessorInstall

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

the class JAXPJavaLaunchConfigurationDelegate method launch.

@Override
public synchronized void launch(ILaunchConfiguration configuration, final String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
    this.mode = mode;
    launchHelper.save(getLaunchConfigFile());
    // set the launch name
    IProcessorInstall install = getProcessorInstall(configuration, mode);
    String tfactory = getTransformerFactory(install);
    String name = install.getName();
    if (tfactory != null)
        // $NON-NLS-1$//$NON-NLS-2$
        name += "[" + tfactory + "]";
    // $NON-NLS-1$
    launch.setAttribute("launchName", name);
    // the super.launch will add a Java source director if we set it to null
    // here
    final ISourceLocator configuredLocator = launch.getSourceLocator();
    launch.setSourceLocator(null);
    super.launch(configuration, mode, launch, monitor);
    // now get the java source locator
    final ISourceLocator javaSourceLookupDirector = launch.getSourceLocator();
    // now add our own participant to the java director
    launch.setSourceLocator(new ISourceLocator() {

        public Object getSourceElement(IStackFrame stackFrame) {
            // simply look at one and then the other
            Object sourceElement = javaSourceLookupDirector.getSourceElement(stackFrame);
            if (sourceElement == null)
                sourceElement = configuredLocator.getSourceElement(stackFrame);
            return sourceElement;
        }
    });
    // IJavaDebugTarget javaTarget =
    // (IJavaDebugTarget)launch.getDebugTarget();
    // launch.removeDebugTarget(javaTarget);
    IDebugTarget javaTarget = launch.getDebugTarget();
    IDebugTarget xslTarget = new JAXPDebugTarget(launch, launch.getProcesses()[0], launchHelper);
    // remove java as the primary target and make xsl the primary target
    launch.removeDebugTarget(javaTarget);
    launch.addDebugTarget(xslTarget);
// add this here to make java the non-primary target
// launch.addDebugTarget(javaTarget);
// launch.addDebugTarget(new JavaXSLDebugTarget(launch,
// launch.getProcesses()[0], launchHelper, javaTarget));
}
Also used : JAXPDebugTarget(org.eclipse.wst.xsl.jaxp.launching.model.JAXPDebugTarget) IStackFrame(org.eclipse.debug.core.model.IStackFrame) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) ISourceLocator(org.eclipse.debug.core.model.ISourceLocator)

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