Search in sources :

Example 31 with FormToolkit

use of org.eclipse.ui.forms.widgets.FormToolkit in project bndtools by bndtools.

the class BundleContentPage method createLeftPanel.

void createLeftPanel(IManagedForm mform, Composite parent) {
    FormToolkit toolkit = mform.getToolkit();
    GeneralInfoPart infoPart = new GeneralInfoPart(parent, toolkit, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
    mform.addPart(infoPart);
    privPkgsPart = new PrivatePackagesPart(parent, toolkit, Section.TITLE_BAR | Section.EXPANDED);
    mform.addPart(privPkgsPart);
    exportPatternListPart = new ExportPatternsListPart(parent, toolkit, Section.TITLE_BAR | Section.EXPANDED);
    mform.addPart(exportPatternListPart);
    // LAYOUT
    GridData gd;
    GridLayout layout;
    layout = new GridLayout(1, false);
    parent.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    infoPart.getSection().setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    privPkgsPart.getSection().setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    exportPatternListPart.getSection().setLayoutData(gd);
}
Also used : GeneralInfoPart(bndtools.editor.contents.GeneralInfoPart) ExportPatternsListPart(bndtools.editor.exports.ExportPatternsListPart) GridLayout(org.eclipse.swt.layout.GridLayout) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) PrivatePackagesPart(bndtools.editor.contents.PrivatePackagesPart) GridData(org.eclipse.swt.layout.GridData)

Example 32 with FormToolkit

use of org.eclipse.ui.forms.widgets.FormToolkit 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

FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)32 Composite (org.eclipse.swt.widgets.Composite)28 GridLayout (org.eclipse.swt.layout.GridLayout)27 GridData (org.eclipse.swt.layout.GridData)23 Button (org.eclipse.swt.widgets.Button)11 Label (org.eclipse.swt.widgets.Label)11 Text (org.eclipse.swt.widgets.Text)9 FillLayout (org.eclipse.swt.layout.FillLayout)7 ManagedForm (org.eclipse.ui.forms.ManagedForm)7 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)7 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)7 MessageHyperlinkAdapter (bndtools.utils.MessageHyperlinkAdapter)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 MDSashForm (bndtools.editor.common.MDSashForm)5 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)5 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)5 Combo (org.eclipse.swt.widgets.Combo)4 FormLayout (org.eclipse.swt.layout.FormLayout)3 Hyperlink (org.eclipse.ui.forms.widgets.Hyperlink)3