Search in sources :

Example 11 with IProcessorInstall

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

the class InstalledProcessorsBlock method removeProcessors.

private void removeProcessors() {
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    IProcessorInstall[] vms = new IProcessorInstall[selection.size()];
    Iterator<?> iter = selection.iterator();
    int i = 0;
    while (iter.hasNext()) {
        vms[i] = (IProcessorInstall) iter.next();
        i++;
    }
    removeProcessors(vms);
}
Also used : IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 12 with IProcessorInstall

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

the class InstalledProcessorsBlock method createControl.

public void createControl(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);
    Font font = ancestor.getFont();
    parent.setFont(font);
    fControl = parent;
    GridData data;
    Label tableLabel = new Label(parent, SWT.NONE);
    tableLabel.setText(Messages.InstalledProcessorsBlock_0);
    data = new GridData();
    data.horizontalSpan = 2;
    tableLabel.setLayoutData(data);
    tableLabel.setFont(font);
    Table fTable = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 450;
    fTable.setLayoutData(data);
    fTable.setFont(font);
    fTable.setHeaderVisible(true);
    fTable.setLinesVisible(true);
    TableColumn column1 = new TableColumn(fTable, SWT.NONE);
    column1.setWidth(180);
    column1.setResizable(true);
    column1.setText(Messages.InstalledProcessorsBlock_1);
    column1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sortByName();
        }
    });
    TableColumn column2 = new TableColumn(fTable, SWT.NONE);
    column2.setWidth(90);
    column2.setResizable(true);
    column2.setText(Messages.InstalledProcessorsBlock_2);
    column2.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sortByType();
        }
    });
    TableColumn column4 = new TableColumn(fTable, SWT.NONE);
    column4.setWidth(180);
    column4.setResizable(true);
    column4.setText(Messages.InstalledProcessorsBlock_4);
    column4.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sortByVersion();
        }
    });
    tableViewer = new CheckboxTableViewer(fTable);
    tableViewer.setLabelProvider(new VMLabelProvider());
    tableViewer.setContentProvider(new ProcessorsContentProvider());
    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent evt) {
            enableButtons();
        }
    });
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                setCheckedInstall((IProcessorInstall) event.getElement());
            } else {
                setCheckedInstall(null);
            }
        }
    });
    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent e) {
            if (!tableViewer.getSelection().isEmpty()) {
                editProcessor();
            }
        }
    });
    fTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                removeProcessors();
            }
        }
    });
    Composite buttons = new Composite(parent, SWT.NULL);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    buttons.setFont(font);
    fAddButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_5);
    fAddButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event evt) {
            addProcessor();
        }
    });
    fEditButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_6);
    fEditButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event evt) {
            editProcessor();
        }
    });
    fRemoveButton = createPushButton(buttons, Messages.InstalledProcessorsBlock_7);
    fRemoveButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event evt) {
            removeProcessors();
        }
    });
    // copied from ListDialogField.CreateSeparator()
    Label separator = new Label(buttons, SWT.NONE);
    separator.setVisible(false);
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.verticalAlignment = GridData.BEGINNING;
    gd.heightHint = 4;
    separator.setLayoutData(gd);
    fillWithWorkspaceProcessors();
    enableButtons();
    restoreColumnSettings();
}
Also used : Table(org.eclipse.swt.widgets.Table) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 13 with IProcessorInstall

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

the class ProcessorBlock method performApply.

public void performApply(ILaunchConfigurationWorkingCopy configuration) {
    boolean usePreferences = usePreferencesRadio.getSelection();
    configuration.setAttribute(JAXPLaunchConfigurationConstants.ATTR_USE_DEFAULT_PROCESSOR, usePreferences);
    if (!usePreferences) {
        IProcessorInstall runprocessor = (IProcessorInstall) ((IStructuredSelection) runComboViewer.getSelection()).getFirstElement();
        configuration.setAttribute(JAXPLaunchConfigurationConstants.ATTR_PROCESSOR, runprocessor.getId());
        configuration.setAttribute(JAXPLaunchConfigurationConstants.ATTR_TRANSFORMER_FACTORY, currentFactory == null ? null : currentFactory.getFactoryClass());
    }
}
Also used : IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall)

Example 14 with IProcessorInstall

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

the class ProcessorBlock method initializeFrom.

public void initializeFrom(ILaunchConfiguration configuration) {
    try {
        boolean useDefaultProcessor = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_USE_DEFAULT_PROCESSOR, true);
        if (useDefaultProcessor) {
            usePreferencesRadio.setSelection(true);
            overridePreferencesRadio.setSelection(false);
            preferencesSelected();
        } else {
            usePreferencesRadio.setSelection(false);
            overridePreferencesRadio.setSelection(true);
            overrideSelected();
            IProcessorInstall runInstall = null;
            String runId = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_PROCESSOR, (String) null);
            if (runId != null)
                runInstall = JAXPRuntime.getProcessor(runId);
            if (runInstall == null)
                runInstall = getRunProcessorPreference();
            runComboViewer.setSelection(new StructuredSelection(runInstall));
            String factoryId = configuration.getAttribute(JAXPLaunchConfigurationConstants.ATTR_TRANSFORMER_FACTORY, (String) null);
            if (factoryId == null) {
                currentFactory = runInstall.getProcessorType().getDefaultTransformerFactory();
            } else {
                for (ITransformerFactory tf : runInstall.getProcessorType().getTransformerFactories()) {
                    if (tf.getFactoryClass().equals(factoryId)) {
                        currentFactory = tf;
                        break;
                    }
                }
            }
            if (currentFactory == null) {
                currentFactory = runInstall.getProcessorType().getDefaultTransformerFactory();
            }
            if (currentFactory != null) {
                factoryComboViewer.setSelection(new StructuredSelection(currentFactory), true);
            }
        }
    } catch (CoreException e) {
        XSLDebugUIPlugin.log(e);
    }
}
Also used : ITransformerFactory(org.eclipse.wst.xsl.jaxp.launching.ITransformerFactory) CoreException(org.eclipse.core.runtime.CoreException) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 15 with IProcessorInstall

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

the class InstalledProcessorsBlock method removeProcessors.

public void removeProcessors(IProcessorInstall[] theInstalls) {
    IStructuredSelection prev = (IStructuredSelection) getSelection();
    for (IProcessorInstall element : theInstalls) {
        processors.remove(element);
    }
    tableViewer.refresh();
    IStructuredSelection curr = (IStructuredSelection) getSelection();
    if (!curr.equals(prev)) {
        IProcessorInstall[] installs = getProcessors();
        if (curr.size() == 0 && installs.length == 1) {
            // pick a default install automatically
            setSelection(new StructuredSelection(installs[0]));
        } else {
            fireSelectionChanged();
        }
    }
}
Also used : IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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