Search in sources :

Example 86 with SashForm

use of org.eclipse.swt.custom.SashForm in project bndtools by bndtools.

the class ResolutionSuccessPanel method createControl.

public void createControl(Composite parent) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    composite = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout(1, false);
    composite.setLayout(layout);
    SashForm form = new SashForm(composite, SWT.VERTICAL);
    form.setLayout(new GridLayout(1, false));
    form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridData gd;
    Section sectRequired = toolkit.createSection(form, Section.TITLE_BAR | Section.EXPANDED);
    sectRequired.setText("Required Resources");
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 200;
    gd.heightHint = 150;
    sectRequired.setLayoutData(gd);
    Table tblRequired = toolkit.createTable(sectRequired, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    sectRequired.setClient(tblRequired);
    requiredViewer = new TableViewer(tblRequired);
    requiredViewer.setContentProvider(ArrayContentProvider.getInstance());
    requiredViewer.setLabelProvider(new ResourceLabelProvider());
    requiredViewer.setSorter(new BundleSorter());
    requiredViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            Resource resource = (Resource) sel.getFirstElement();
            reasonsContentProvider.setOptional(false);
            if (result != null)
                reasonsContentProvider.setResolution(result.getResourceWirings());
            reasonsViewer.setInput(resource);
            reasonsViewer.expandToLevel(2);
        }
    });
    sectOptional = toolkit.createSection(form, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    sectOptional.setText("Optional Resources");
    Composite cmpOptional = toolkit.createComposite(sectOptional);
    sectOptional.setClient(cmpOptional);
    cmpOptional.setLayout(new GridLayout(2, false));
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 200;
    gd.heightHint = 150;
    sectOptional.setLayoutData(gd);
    Table tblOptional = toolkit.createTable(cmpOptional, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    tblOptional.setLayoutData(gd);
    optionalViewer = new CheckboxTableViewer(tblOptional);
    optionalViewer.setContentProvider(ArrayContentProvider.getInstance());
    optionalViewer.setLabelProvider(new ResourceLabelProvider());
    optionalViewer.setSorter(new BundleSorter());
    optionalViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            doOptionalReasonUpdate((Resource) sel.getFirstElement());
        }
    });
    optionalViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            Resource resource = (Resource) event.getElement();
            if (!addedOptionals.containsKey(resource)) {
                if (event.getChecked()) {
                    checkedOptional.add(resource);
                } else {
                    checkedOptional.remove(resource);
                }
            }
            presenter.updateButtons();
            updateResolveOptionalButton();
            optionalViewer.setSelection(new ISelection() {

                @Override
                public boolean isEmpty() {
                    return true;
                }
            });
            doOptionalReasonUpdate(resource);
        }
    });
    Composite cmpOptionalButtons = toolkit.createComposite(cmpOptional);
    cmpOptionalButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    GridLayout gl_cmpOptionalButtons = new GridLayout(3, false);
    gl_cmpOptionalButtons.marginHeight = 0;
    gl_cmpOptionalButtons.marginWidth = 0;
    cmpOptionalButtons.setLayout(gl_cmpOptionalButtons);
    btnAddResolveOptional = toolkit.createButton(cmpOptionalButtons, "Update and Resolve", SWT.NONE);
    btnAddResolveOptional.setEnabled(false);
    btnAddResolveOptional.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            doAddResolve();
        }
    });
    btnAddResolveOptional.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
    Button btnAllOptional = toolkit.createButton(cmpOptionalButtons, "Select All", SWT.NONE);
    btnAllOptional.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            optionalViewer.setAllChecked(true);
            checkedOptional.clear();
            for (Object object : optionalViewer.getCheckedElements()) {
                if (!addedOptionals.containsKey(object)) {
                    checkedOptional.add((Resource) object);
                }
            }
            presenter.updateButtons();
            updateResolveOptionalButton();
        }
    });
    btnAllOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    Button btnClearOptional = toolkit.createButton(cmpOptionalButtons, "Clear All", SWT.NONE);
    btnClearOptional.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            optionalViewer.setAllChecked(false);
            checkedOptional.clear();
            presenter.updateButtons();
            updateResolveOptionalButton();
        }
    });
    btnClearOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    Section sectReason = toolkit.createSection(form, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    sectReason.setText("Reasons");
    Tree tblReasons = new Tree(sectReason, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    sectReason.setClient(tblReasons);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 200;
    gd.heightHint = 150;
    sectReason.setLayoutData(gd);
    reasonsViewer = new TreeViewer(tblReasons);
    reasonsViewer.setContentProvider(reasonsContentProvider);
    reasonsViewer.setLabelProvider(new ResolutionTreeLabelProvider());
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Resource(org.osgi.resource.Resource) Section(org.eclipse.ui.forms.widgets.Section) SashForm(org.eclipse.swt.custom.SashForm) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer)

Aggregations

SashForm (org.eclipse.swt.custom.SashForm)86 GridData (org.eclipse.swt.layout.GridData)58 GridLayout (org.eclipse.swt.layout.GridLayout)53 Composite (org.eclipse.swt.widgets.Composite)51 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 FillLayout (org.eclipse.swt.layout.FillLayout)26 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 Label (org.eclipse.swt.widgets.Label)23 CTabItem (org.eclipse.swt.custom.CTabItem)13 Button (org.eclipse.swt.widgets.Button)13 StyledText (org.eclipse.swt.custom.StyledText)12 ArrayList (java.util.ArrayList)11 Table (org.eclipse.swt.widgets.Table)11 ToolBar (org.eclipse.swt.widgets.ToolBar)11 Point (org.eclipse.swt.graphics.Point)10 TableViewer (org.eclipse.jface.viewers.TableViewer)9 Event (org.eclipse.swt.widgets.Event)9 Listener (org.eclipse.swt.widgets.Listener)9 TableColumn (org.eclipse.swt.widgets.TableColumn)9 Tree (org.eclipse.swt.widgets.Tree)9