Search in sources :

Example 1 with LoadingContentElement

use of bndtools.model.repo.LoadingContentElement in project bndtools by bndtools.

the class RunFrameworkPart method createSection.

final void createSection(Section section, FormToolkit tk) {
    section.setText("Core Runtime");
    Composite composite = tk.createComposite(section);
    section.setClient(composite);
    Label lblFramework = new Label(composite, SWT.NONE);
    tk.adapt(lblFramework, true, true);
    lblFramework.setText("OSGi Framework:");
    cmbFramework = new Combo(composite, SWT.DROP_DOWN);
    tk.adapt(cmbFramework);
    tk.paintBordersFor(cmbFramework);
    cmbFramework.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    frameworkViewer = new ComboViewer(cmbFramework);
    frameworkViewer.setUseHashlookup(true);
    frameworkViewer.setContentProvider(fwkContentProvider);
    Label lblExecEnv = tk.createLabel(composite, "Execution Env.:");
    cmbExecEnv = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    ControlDecoration eeDecor = new ControlDecoration(cmbExecEnv, SWT.LEFT | SWT.TOP, composite);
    eeDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    eeDecor.setDescriptionText("The runtime Java Virtual Machine will be required/assumed " + "\nto support this Execution Environment");
    eeViewer = new ComboViewer(cmbExecEnv);
    eeViewer.setContentProvider(ArrayContentProvider.getInstance());
    eeViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((EE) element).getEEName();
        }
    });
    eeViewer.setInput(EE.values());
    // Listeners
    cmbFramework.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    markDirty();
                    selectedFramework = cmbFramework.getText();
                }
            });
        }
    });
    frameworkViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    Object element = ((IStructuredSelection) frameworkViewer.getSelection()).getFirstElement();
                    if (element instanceof LoadingContentElement) {
                        return;
                    }
                    markDirty();
                    if (element == null)
                        selectedFramework = null;
                    else
                        selectedFramework = element.toString();
                }
            });
        }
    });
    eeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    markDirty();
                    selectedEE = (EE) ((IStructuredSelection) event.getSelection()).getFirstElement();
                }
            });
        }
    });
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    lblFramework.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    GridData gd;
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 20;
    gd.heightHint = 20;
    cmbFramework.setLayoutData(gd);
    lblExecEnv.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 20;
    gd.heightHint = 20;
    cmbExecEnv.setLayoutData(gd);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) LoadingContentElement(bndtools.model.repo.LoadingContentElement) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

LoadingContentElement (bndtools.model.repo.LoadingContentElement)1 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1