Example usage for org.eclipse.jface.databinding.swt IWidgetValueProperty observeDelayed

List of usage examples for org.eclipse.jface.databinding.swt IWidgetValueProperty observeDelayed

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt IWidgetValueProperty observeDelayed.

Prototype

public ISWTObservableValue<T> observeDelayed(int delay, S widget);

Source Link

Document

Returns an ISWTObservableValue observing this value property on the given widget, which delays notification of value changes until at least delay milliseconds have elapsed since that last change event, or until a FocusOut event is received from the widget (whichever happens first).

Usage

From source file:at.bestsolution.e4.addressbook.ui.swt.AddressForm.java

License:Open Source License

public void bindControls(EditingDomain editingDomain, DataBindingContext dbc, IObservableValue master) {
    this.dbc = dbc;
    this.master = master;
    this.editingDomain = editingDomain;

    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);
    IViewerValueProperty sProp = ViewerProperties.singleSelection();

    {/*  w  ww . j a va  2  s  . com*/
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                AddressbookPackage.Literals.ADDRESS__STREET);
        dbc.bindValue(tProp.observeDelayed(PersonForm.DELAY, w_street), mProp.observeDetail(master));
    }

    {
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                AddressbookPackage.Literals.ADDRESS__ZIP);
        dbc.bindValue(tProp.observeDelayed(PersonForm.DELAY, w_zip), mProp.observeDetail(master));
    }

    {
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                AddressbookPackage.Literals.ADDRESS__CITY);
        dbc.bindValue(tProp.observeDelayed(PersonForm.DELAY, w_city), mProp.observeDetail(master));
    }

    {
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                FeaturePath.fromList(AddressbookPackage.Literals.ADDRESS__COUNTRY));
        dbc.bindValue(sProp.observe(v_country), mProp.observeDetail(master));
    }

    bindState();

    IWidgetValueProperty eProp = WidgetProperties.enabled();

    for (Control c : getChildren()) {
        EMFUpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy();
        modelToTarget.setConverter(new Converter(Address.class, boolean.class) {

            @Override
            public Object convert(Object fromObject) {
                return fromObject != null;
            }
        });

        final Binding b = dbc.bindValue(eProp.observe(c), master,
                new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), modelToTarget);
        master.addValueChangeListener(new IValueChangeListener() {

            @Override
            public void handleValueChange(ValueChangeEvent event) {
                if (event.diff.getNewValue() == null)
                    b.updateModelToTarget();
            }
        });
    }
}

From source file:at.bestsolution.e4.addressbook.ui.swt.PersonForm.java

License:Open Source License

private void bindControls(EditingDomain editingDomain) {
    EMFDataBindingContext dbc = new EMFDataBindingContext();

    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);

    {/*from ww w  .ja va 2s. com*/
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                AddressbookPackage.Literals.PERSON__FIRSTNAME);
        dbc.bindValue(tProp.observeDelayed(PersonForm.DELAY, w_firstName), mProp.observeDetail(master));
    }

    {
        IEMFValueProperty mProp = EMFEditProperties.value(editingDomain,
                AddressbookPackage.Literals.PERSON__LASTNAME);
        dbc.bindValue(tProp.observeDelayed(PersonForm.DELAY, w_lastName), mProp.observeDetail(master));
    }

    {
        IEMFValueProperty mProp = EMFEditProperties
                .list(editingDomain, AddressbookPackage.Literals.PERSON__ADDRESSES)
                .value(new ElementAccessImpl(AddressType.PRIVATE));
        IObservableValue value = mProp.observeDetail(master);
        privateAddressForm.bindControls(dbc, value);
    }

    {
        IEMFValueProperty mProp = EMFEditProperties
                .list(editingDomain, AddressbookPackage.Literals.PERSON__ADDRESSES)
                .value(new ElementAccessImpl(AddressType.BUSINESS));
        IObservableValue value = mProp.observeDetail(master);

        IWidgetValueProperty cProp = WidgetProperties.selection();

        EMFUpdateValueStrategy targetToModel = new EMFUpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER);
        EMFUpdateValueStrategy modelToTarget = new EMFUpdateValueStrategy();
        modelToTarget.setConverter(new Converter(Address.class, boolean.class) {

            @Override
            public Object convert(Object fromObject) {
                return fromObject != null;
            }
        });
        dbc.bindValue(cProp.observe(w_hasBusinessAddress), value, targetToModel, modelToTarget);

        businessAddressForm.bindControls(dbc, value);
    }
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddFontDialog.java

License:Open Source License

@Override
protected Control createDialogContent(Composite parent) {
    o = ParametersFactory.eINSTANCE.createKeyValuePair();
    Composite area = new Composite(parent, SWT.NONE);
    area.setLayout(new GridLayout(1, false));
    area.setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setText("Add font ");
    setTitle("Add font");
    setMessage("Enter informations about the font to add");

    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(3, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);

    {//from ww w . j av a2 s  . com
        Label l = new Label(container, SWT.NONE);
        l.setText("Font name*:");
        tFontName = new Text(container, SWT.BORDER);
        GridData tFontGD = new GridData(GridData.FILL_HORIZONTAL);
        tFontGD.horizontalSpan = 2;
        tFontName.setLayoutData(tFontGD);
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__KEY);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tFontName), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("File*:");

        tFile = new Text(container, SWT.BORDER);
        tFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        tFile.setEditable(false);
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__VALUE);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tFile), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
        Button b = new Button(container, SWT.NONE);
        b.setText("Browse ...");
        b.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog(getShell(), false,
                        resourceContainer, IResource.FILE) {
                    @Override
                    protected IStatus validateItem(final Object item) {
                        IFile f = (IFile) item;
                        if (f.getParent() instanceof IProject) {
                            return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID,
                                    "The selected resource has to be part of the source folder");
                        }
                        if (!f.getName().endsWith(".ttf")) {
                            return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID,
                                    "The selected resource does not seem to be a font");
                        }
                        return super.validateItem(item);
                    }
                };

                if (d.open() == ResourceSelectionDialog.OK) {
                    Object[] rv = d.getResult();
                    if (rv.length == 1) {
                        IFile f = (IFile) rv[0];
                        IJavaElement j = JavaCore.create(f.getParent());
                        if (j instanceof IPackageFragment) {
                            IPackageFragment p = (IPackageFragment) j;
                            tFile.setText(p.getElementName().replace('.', '/') + "/" + f.getName());
                        } else if (j instanceof IPackageFragmentRoot) {
                            IPackageFragmentRoot p = (IPackageFragmentRoot) j;
                            tFile.setText(f.getName());
                        } else {
                            MessageDialog.openInformation(getShell(), "Not valid",
                                    "The selected resource has to be part of the source folder");
                        }
                    }
                }
            }
        });

    }
    return area;
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddIconDialog.java

License:Open Source License

@Override
protected Control createDialogContent(final Composite parent) {
    o = ParametersFactory.eINSTANCE.createIcon();
    Composite area = new Composite(parent, SWT.NONE);
    area.setLayout(new GridLayout(1, false));
    area.setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setText("Add icon");
    setTitle("Add icon");
    setMessage("Enter informations about the icon to add");

    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    IViewerValueProperty selProp = ViewerProperties.singleSelection();
    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);

    {//w  w  w .ja va2s .c  o m
        Label l = new Label(container, SWT.NONE);
        l.setText("Kind:");

        ComboViewer v = new ComboViewer(container, SWT.READ_ONLY);
        v.setLabelProvider(new LabelProvider());
        v.setContentProvider(ArrayContentProvider.getInstance());
        v.setInput(IconType.VALUES);
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__KIND);
        dbContext.bindValue(selProp.observe(v), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("URL*:");

        tUrl = new Text(container, SWT.BORDER);
        tUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__HREF);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tUrl), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("Depth:");

        ComboViewer v = new ComboViewer(container, SWT.READ_ONLY);
        v.setLabelProvider(new LabelProvider());
        v.setContentProvider(ArrayContentProvider.getInstance());
        // TODO not hard coded here
        v.setInput(new String[] { "8", "24", "32" });
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__DEPTH);
        dbContext.bindValue(selProp.observe(v), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("Width:");

        tWidth = new Text(container, SWT.BORDER);
        tWidth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__WIDTH);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tWidth), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("Height:");

        tHeight = new Text(container, SWT.BORDER);
        tHeight.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__HEIGHT);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tHeight), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    return area;
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddMetaInfFileDialog.java

License:Open Source License

@Override
protected Control createDialogContent(Composite parent) {
    o = ParametersFactory.eINSTANCE.createKeyValuePair();
    Composite area = new Composite(parent, SWT.NONE);
    area.setLayout(new GridLayout(1, false));
    area.setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setText("Add META-INF file");
    setTitle("Add META-INF file");
    setMessage("Enter informations about the META-INF file to add");

    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(4, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);

    {/*from   w  ww .j  a  v a 2  s.c o m*/
        Label l = new Label(container, SWT.NONE);
        l.setText("Service Folder*:");

        tFolder = new Text(container, SWT.BORDER);
        tFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        GridData tFolderGD = new GridData(GridData.FILL_HORIZONTAL);
        tFolderGD.horizontalSpan = 3;
        tFolder.setLayoutData(tFolderGD);
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__KEY);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tFolder), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("File*:");

        tFile = new Text(container, SWT.BORDER);
        tFile.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        tFile.setEditable(false);
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, KEY_VALUE_PAIR__VALUE);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tFile), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
        Button bFilesystem = new Button(container, SWT.NONE);
        bFilesystem.setText("Filesystem ...");
        bFilesystem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                FileDialog d = new FileDialog(getShell());
                String val = d.open();
                if (val != null) {
                    tFile.setText(val);
                }
            }
        });
        Button bWorkspace = new Button(container, SWT.NONE);
        bWorkspace.setText("Workspace ...");
        bWorkspace.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog(getShell(), false,
                        resourceContainer, IResource.FILE) {
                    @Override
                    protected IStatus validateItem(final Object item) {
                        IFile f = (IFile) item;
                        if (f.getParent() instanceof IProject) {
                            return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID,
                                    "The selected resource has to be part of the source folder");
                        }
                        return super.validateItem(item);
                    }
                };
                if (d.open() == ResourceSelectionDialog.OK) {
                    Object[] rv = d.getResult();
                    if (rv.length == 1) {
                        IFile f = (IFile) rv[0];
                        tFile.setText("${workspace}/" + f.getProject().getName() + "/"
                                + f.getProjectRelativePath().toString());
                    }
                }
            }
        });
    }
    return area;
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddSplashDialog.java

License:Open Source License

@Override
protected Control createDialogContent(final Composite parent) {
    o = ParametersFactory.eINSTANCE.createSplash();
    Composite area = new Composite(parent, SWT.NONE);
    area.setLayout(new GridLayout(1, false));
    area.setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setText("Add splash icon");
    setTitle("Add splash");
    setMessage("Enter informations about the splash to add");

    Composite container = new Composite(area, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    IViewerValueProperty selProp = ViewerProperties.singleSelection();
    IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify);

    {//from w  ww . j av  a  2 s . com
        Label l = new Label(container, SWT.NONE);
        l.setText("Mode*:");

        ComboViewer v = new ComboViewer(container, SWT.READ_ONLY);
        v.setLabelProvider(new LabelProvider());
        v.setContentProvider(ArrayContentProvider.getInstance());
        v.setInput(SplashMode.values());
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, SPLASH__MODE);
        dbContext.bindValue(selProp.observe(v), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }

    {
        Label l = new Label(container, SWT.NONE);
        l.setText("URL*:");

        tUrl = new Text(container, SWT.BORDER);
        tUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        IEMFValueProperty prop = EMFEditProperties.value(editingDomain, SPLASH__HREF);
        dbContext.bindValue(tProp.observeDelayed(DELAY, tUrl), prop.observe(o),
                new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST),
                new EMFUpdateValueStrategy());
    }
    return area;
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java

License:Open Source License

private void createPageOverview(final AntTask task) {
    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);/*from   w w  w . j a v  a  2 s .c  om*/
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
            JavaFXUIPlugin.PLUGIN_ID + ".JFXBuildConfigurationEditor_overview");

    bean.setValue(task);

    toolkit = new FormToolkit(composite.getDisplay());

    final Form form = toolkit.createForm(composite);
    form.setText("FX Build Configuration");
    form.setImage(getTitleImage());
    form.getBody().setLayout(new FillLayout());
    toolkit.decorateFormHeading(form);

    initToolbar(form);

    ScrolledForm scrolledForm = toolkit.createScrolledForm(form.getBody());
    scrolledForm.getBody().setLayout(new GridLayout(2, false));
    Composite sectionParent = scrolledForm.getBody();

    dbc = new DataBindingContext();
    IWidgetValueProperty textModify = WidgetProperties.text(SWT.Modify);
    IWidgetValueProperty selChange = WidgetProperties.selection();

    {
        Section section = toolkit.createSection(sectionParent,
                Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        section.setText("Build && Package Properties");
        section.setDescription("The following properties are needed to build the JavaFX-Application");
        section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Composite sectionClient = toolkit.createComposite(section);
        sectionClient.setLayout(new GridLayout(4, false));

        {
            toolkit.createLabel(sectionClient, "Build Directory*:");
            final Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            toolkit.createButton(sectionClient, "Filesystem ...", SWT.PUSH)
                    .addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent e) {
                            String dir = handleBuildFilesystemDirectorySelection(t.getShell());
                            if (dir != null) {
                                t.setText(dir);
                            }
                        }
                    });
            toolkit.createButton(sectionClient, "Workspace ...", SWT.PUSH)
                    .addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent e) {
                            String dir = handleBuildWorkbenchDirectorySelection(t.getShell());
                            if (dir != null) {
                                t.setText(dir);
                            }
                        }
                    });
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ANT_TASK__BUILD_DIRECTORY);
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Vendor name*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__INFO, INFO__VENDOR));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Application title*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__APPLICATION, APPLICATION__NAME));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Application version*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__APPLICATION, APPLICATION__VERSION));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Application class*:");
            final Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
            Button b = toolkit.createButton(sectionClient, "Browse ...", SWT.PUSH);
            b.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String name = handleRootclassSelection(t.getShell());
                    if (name != null) {
                        t.setText(name);
                    }
                }
            });
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__APPLICATION, APPLICATION__MAINCLASS));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Preloader class:");
            final Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
            Button b = toolkit.createButton(sectionClient, "Browse ...", SWT.PUSH);
            b.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String name = handlePreloaderclassSelection(t.getShell());
                    if (name != null) {
                        t.setText(name);
                    }
                }
            });
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__APPLICATION, APPLICATION__PRELOADERCLASS));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Splash:");
            final Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 2, 1));
            Button b = toolkit.createButton(sectionClient, "Browse ...", SWT.PUSH);
            b.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String name = handleSplashImage(t.getShell());
                    if (name != null) {
                        t.setText(name);
                    }
                }
            });
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__SPLASH_IMAGE));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Manifest-Attributes:")
                    .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
            Composite container = toolkit.createComposite(sectionClient);
            GridLayout gl = new GridLayout(2, false);
            gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0;
            container.setLayout(gl);
            GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL);
            gdContainer.horizontalSpan = 2;
            container.setLayoutData(gdContainer);

            Composite tableContainer = toolkit.createComposite(container);
            Table t = toolkit.createTable(tableContainer,
                    SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            t.setHeaderVisible(true);
            t.setLinesVisible(true);

            GridData gdTable = new GridData(GridData.FILL_HORIZONTAL);
            gdTable.heightHint = t.getHeaderHeight() + t.getItemHeight() * 5;
            tableContainer.setLayoutData(gdTable);

            TableColumnLayout tablelayout = new TableColumnLayout();
            final TableViewer v = new TableViewer(t);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = t.getHeaderHeight() + t.getItemHeight() * 5;
            v.getControl().setLayoutData(gd);
            v.setContentProvider(ArrayContentProvider.getInstance());

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(final Object element) {
                        return ((Param) element).getName();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(33));
                c.getColumn().setText("Name");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(final Object element) {
                        return ((Param) element).getValue();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(67));
                c.getColumn().setText("Value");
            }
            tableContainer.setLayout(tablelayout);
            v.setInput(task.getManifestEntries());

            Composite buttonComp = toolkit.createComposite(sectionClient);
            buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
            buttonComp.setLayout(new GridLayout());

            {
                Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        if (handleAddManifestAttr(getSite().getShell())) {
                            v.setInput(task.getManifestEntries());
                            v.setSelection(new StructuredSelection(
                                    task.getManifestEntries().get(task.getManifestEntries().size() - 1)));
                        }
                    }
                });
            }

            {
                Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        Param value = (Param) ((IStructuredSelection) v.getSelection()).getFirstElement();
                        if (value != null) {
                            if (handleRemoveManifestAttr(value)) {
                                v.setInput(task.getManifestEntries());
                            }
                        } else {
                            MessageDialog.openWarning(getSite().getShell(), "Warning",
                                    "Please select an entry");
                        }
                    }
                });
            }
            {
                toolkit.createLabel(sectionClient, "Toolkit Type:")
                        .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
                ComboViewer c = new ComboViewer(sectionClient);
                c.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
                c.setContentProvider(new ArrayContentProvider());
                c.setInput(ApplicationToolkitType.VALUES);
                IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                        FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__APPLICATION, APPLICATION__TOOLKIT));
                dbc.bindValue(selChange.observe(c.getCombo()), prop.observeDetail(bean));
            }
            {
                Button b = toolkit.createButton(sectionClient, "Convert CSS into binary form", SWT.CHECK);
                b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 4, 1));
                IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                        FeaturePath.fromList(ANT_TASK__CSS_TO_BIN));
                dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
            }
        }

        section.setClient(sectionClient);
    }

    {
        Section section = toolkit.createSection(sectionParent,
                Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        section.setText("Building & Exporting");
        section.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, true, 1, 2));

        Composite sectionClient = toolkit.createComposite(section);
        sectionClient.setLayout(new GridLayout(1, false));

        {
            FormText text = toolkit.createFormText(sectionClient, false);
            text.setText(
                    "<p>To generate build instructions and export the project: <li style=\"bullet\" bindent=\"1\">Generate <a href=\"generateAnt\">ant build.xml</a> only</li><li style=\"bullet\" bindent=\"2\">Generate <a href=\"generateAndRun\">ant build.xml and run</a></li>&#160;</p>",
                    true, false);
            text.addHyperlinkListener(new IHyperlinkListener() {

                @Override
                public void linkExited(final HyperlinkEvent e) {

                }

                @Override
                public void linkEntered(HyperlinkEvent e) {
                }

                @Override
                public void linkActivated(HyperlinkEvent e) {
                    try {
                        if ("generateAndRun".equals(e.getHref())) {
                            executeExport();
                        } else {
                            executeGenerateAnt();
                        }
                    } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            });
        }

        section.setClient(sectionClient);
    }

    int index = addPage(composite);
    setPageText(index, "Overview");
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java

License:Open Source License

private void createPageDeploy(final AntTask task) {
    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);/*ww  w . j a  v a2 s .  c  o  m*/
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
            JavaFXUIPlugin.PLUGIN_ID + ".JFXBuildConfigurationEditor_deploy");

    // TODO
    final WritableValue bean = new WritableValue();
    bean.setValue(task);

    toolkit = new FormToolkit(composite.getDisplay());

    final Form form = toolkit.createForm(composite);
    form.setText("FX Build Configuration");
    form.setImage(getTitleImage());
    form.getBody().setLayout(new FillLayout());
    toolkit.decorateFormHeading(form);

    initToolbar(form);

    ScrolledForm scrolledForm = toolkit.createScrolledForm(form.getBody());
    scrolledForm.getBody().setLayout(new GridLayout(2, false));
    Composite sectionParent = scrolledForm.getBody();

    dbc = new DataBindingContext();
    IWidgetValueProperty textModify = WidgetProperties.text(SWT.Modify);
    IWidgetValueProperty selChange = WidgetProperties.selection();

    {
        Section section = toolkit.createSection(sectionParent,
                Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        section.setText("Deploy Properties");
        section.setDescription("The following properties are needed to create a Java Webstart Deployment");
        section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Composite sectionClient = toolkit.createComposite(section);
        final int COLUMN_COUNT = 3;
        sectionClient.setLayout(new GridLayout(COLUMN_COUNT, false));

        {
            toolkit.createLabel(sectionClient, "Applet Width*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = COLUMN_COUNT - 1;
            t.setLayoutData(gd);
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__WIDTH));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Applet Height*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = COLUMN_COUNT - 1;
            t.setLayoutData(gd);
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__HEIGHT));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            Button b = toolkit.createButton(sectionClient, "Embed JNLP", SWT.CHECK);
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__EMBEDJNLP));
            dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
        }

        {
            Button b = toolkit.createButton(sectionClient, "Treat files as extensions", SWT.CHECK);
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__EXTENSION));
            dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
        }

        {
            Button b = toolkit.createButton(sectionClient, "Include deployment toolkit", SWT.CHECK);
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__INCLUDE_DT));
            dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
        }

        {
            Button b = toolkit.createButton(sectionClient, "Native Package", SWT.CHECK);
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__NATIVE_PACKAGE));
            dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
        }

        {
            Button b = toolkit.createButton(sectionClient, "Offline allowed", SWT.CHECK);
            b.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, COLUMN_COUNT, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__OFFLINE_ALLOWED));
            dbc.bindValue(selChange.observe(b), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Placeholder Ref.*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = COLUMN_COUNT - 1;
            t.setLayoutData(gd);
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__PLACEHOLDERREF));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Placeholder ID*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = COLUMN_COUNT - 1;
            t.setLayoutData(gd);
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__PLACEHOLDERID));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "HTML Template:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__TEMPLATE, TEMPLATE__FILE));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
            Button b = toolkit.createButton(sectionClient, "Workspace ...", SWT.NONE);
            b.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    FilteredResourcesSelectionDialog d = new FilteredResourcesSelectionDialog(
                            getSite().getShell(), false,
                            ((IFileEditorInput) getEditorInput()).getFile().getProject(), IResource.FILE) {
                        @Override
                        protected IStatus validateItem(final Object item) {
                            IFile f = (IFile) item;
                            if (f.getParent() instanceof IProject) {
                                return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID,
                                        "The selected resource has to be part of the source folder");
                            }
                            if (!f.getName().endsWith(JavaFXUIPlugin.FILEEXTENSION_HTML_TEMPLATE)) {
                                return new Status(IStatus.ERROR, JavaFXUIPlugin.PLUGIN_ID,
                                        "The selected resource does not seem to be a html file");
                            }
                            return super.validateItem(item);
                        }
                    };

                    if (d.open() == ResourceSelectionDialog.OK) {
                        Object[] rv = d.getResult();
                        if (rv.length == 1) {
                            IFile f = (IFile) rv[0];
                            IJavaElement j = JavaCore.create(f.getParent());
                            String template = null;
                            if (j instanceof IPackageFragment) {
                                IPackageFragment p = (IPackageFragment) j;
                                template = p.getElementName().replace('.', '/') + "/" + f.getName();
                            } else if (j instanceof IPackageFragmentRoot) {
                                IPackageFragmentRoot p = (IPackageFragmentRoot) j;
                                template = f.getName();
                            } else {
                                MessageDialog.openInformation(getSite().getShell(), "Not valid",
                                        "The selected resource has to be part of the source folder");
                            }
                            if (template != null) {
                                if (getTask().getDeploy().getTemplate() == null) {
                                    Command cmd = new SetCommand(editingDomain, getTask().getDeploy(),
                                            DEPLOY__TEMPLATE, ParametersFactory.eINSTANCE.createTemplate());
                                    if (cmd.canExecute()) {
                                        cmd.execute();
                                    }
                                }
                                Command cmd = new SetCommand(editingDomain, getTask().getDeploy().getTemplate(),
                                        TEMPLATE__FILE, template);
                                if (cmd.canExecute()) {
                                    cmd.execute();
                                }
                            }
                        }
                    }
                }
            });
        }

        {
            toolkit.createLabel(sectionClient, "Template Output File:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = COLUMN_COUNT - 1;
            t.setLayoutData(gd);
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__DEPLOY, DEPLOY__TEMPLATE, TEMPLATE__TO_FILE));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Webstart Splash:")
                    .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
            Composite container = toolkit.createComposite(sectionClient);
            GridLayout gl = new GridLayout(2, false);
            gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0;
            container.setLayout(gl);
            GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL);
            gdContainer.horizontalSpan = COLUMN_COUNT - 1;
            container.setLayoutData(gdContainer);

            Composite tableContainer = toolkit.createComposite(container);
            Table t = toolkit.createTable(tableContainer,
                    SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            t.setHeaderVisible(true);
            t.setLinesVisible(true);

            GridData gdTable = new GridData(GridData.FILL_HORIZONTAL);
            gdTable.heightHint = t.getItemHeight() * 5;
            tableContainer.setLayoutData(gdTable);

            TableColumnLayout tablelayout = new TableColumnLayout();

            final TableViewer v = new TableViewer(t);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = t.getItemHeight() * 5;
            v.getControl().setLayoutData(gd);
            v.setContentProvider(ArrayContentProvider.getInstance());

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(final Object element) {
                        return ((Splash) element).getMode().getName();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 100, false));
                c.getColumn().setText("Mode");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(final Object element) {
                        return ((Splash) element).getHref();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(90));
                c.getColumn().setText("URL");
            }
            tableContainer.setLayout(tablelayout);
            v.setInput(task.getDeploy().getInfo().getSplash());

            Composite buttonComp = toolkit.createComposite(container);
            buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
            buttonComp.setLayout(new GridLayout());

            {
                Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        if (handleAddSplash()) {
                            v.setInput(task.getDeploy().getInfo().getSplash());
                            v.setSelection(new StructuredSelection(task.getDeploy().getInfo().getSplash()
                                    .get(task.getDeploy().getInfo().getSplash().size() - 1)));
                        }
                    }
                });
            }

            {
                Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        Splash value = (Splash) ((IStructuredSelection) v.getSelection()).getFirstElement();
                        if (value != null) {
                            if (handleRemoveSplash(value)) {
                                v.setInput(getTask().getDeploy().getInfo().getSplash());
                            }
                        } else {
                            MessageDialog.openWarning(getSite().getShell(), "Warning",
                                    "Please select an entry");
                        }
                    }
                });
            }
        }

        {
            toolkit.createLabel(sectionClient, "Webstart Icons:")
                    .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
            Composite container = toolkit.createComposite(sectionClient);
            GridLayout gl = new GridLayout(2, false);
            gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0;
            container.setLayout(gl);
            GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL);
            gdContainer.horizontalSpan = COLUMN_COUNT - 1;
            container.setLayoutData(gdContainer);

            Composite tableContainer = toolkit.createComposite(container);
            Table t = toolkit.createTable(tableContainer,
                    SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            t.setHeaderVisible(true);
            t.setLinesVisible(true);

            GridData gdTable = new GridData(GridData.FILL_HORIZONTAL);
            gdTable.heightHint = t.getItemHeight() * 5;
            tableContainer.setLayoutData(gdTable);

            TableColumnLayout tablelayout = new TableColumnLayout();

            final TableViewer v = new TableViewer(t);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = t.getItemHeight() * 5;
            v.getControl().setLayoutData(gd);
            v.setContentProvider(ArrayContentProvider.getInstance());

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((Icon) element).getDepth();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false));
                c.getColumn().setText("Depth");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((Icon) element).getKind().getName();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 100, false));
                c.getColumn().setText("Kind");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((Icon) element).getWidth();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false));
                c.getColumn().setText("Width");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((Icon) element).getHeight();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(10, 50, false));
                c.getColumn().setText("Height");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((Icon) element).getHref();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(60));
                c.getColumn().setText("Url");
            }
            tableContainer.setLayout(tablelayout);
            v.setInput(task.getDeploy().getInfo().getIcon());

            Composite buttonComp = toolkit.createComposite(container);
            buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
            buttonComp.setLayout(new GridLayout());

            {
                Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        if (handleAddIcon()) {
                            v.setInput(task.getDeploy().getInfo().getIcon());
                            v.setSelection(new StructuredSelection(task.getDeploy().getInfo().getIcon()
                                    .get(task.getDeploy().getInfo().getIcon().size() - 1)));
                        }
                    }
                });
            }

            {
                Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        Icon value = (Icon) ((IStructuredSelection) v.getSelection()).getFirstElement();
                        if (value != null) {
                            if (handleRemoveIcon(value)) {
                                v.setInput(task.getDeploy().getInfo().getIcon());
                            }
                        } else {
                            MessageDialog.openWarning(getSite().getShell(), "Warning",
                                    "Please select an entry");
                        }
                    }
                });
            }
        }

        {
            toolkit.createLabel(sectionClient, "Additional META-INF files:")
                    .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
            Composite container = toolkit.createComposite(sectionClient);
            GridLayout gl = new GridLayout(2, false);
            gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0;
            container.setLayout(gl);
            GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL);
            gdContainer.horizontalSpan = COLUMN_COUNT - 1;
            container.setLayoutData(gdContainer);

            Composite tableContainer = toolkit.createComposite(container);
            Table t = toolkit.createTable(tableContainer,
                    SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            t.setHeaderVisible(true);
            t.setLinesVisible(true);

            GridData gdTable = new GridData(GridData.FILL_HORIZONTAL);
            gdTable.heightHint = t.getItemHeight() * 5;
            tableContainer.setLayoutData(gdTable);

            TableColumnLayout tablelayout = new TableColumnLayout();

            final TableViewer v = new TableViewer(t);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = t.getItemHeight() * 5;
            v.getControl().setLayoutData(gd);
            v.setContentProvider(ArrayContentProvider.getInstance());

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((KeyValuePair) element).getKey();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(33));
                c.getColumn().setText("Folder");
            }

            {
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((KeyValuePair) element).getValue();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(67));
                c.getColumn().setText("File");
            }
            tableContainer.setLayout(tablelayout);
            v.setInput(task.getFiles());

            Composite buttonComp = toolkit.createComposite(container);
            buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
            buttonComp.setLayout(new GridLayout());

            {
                Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        if (handleAddMetaInfFile()) {
                            v.setInput(task.getFiles());
                            v.setSelection(
                                    new StructuredSelection(task.getFiles().get(task.getFiles().size() - 1)));
                        }
                    }
                });
            }

            {
                Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        KeyValuePair value = (KeyValuePair) ((IStructuredSelection) v.getSelection())
                                .getFirstElement();
                        if (value != null) {
                            if (handleRemoveMetaInfFile(value)) {
                                v.setInput(task.getFiles());
                            }
                        } else {
                            MessageDialog.openWarning(getSite().getShell(), "Warning",
                                    "Please select an entry");
                        }
                    }
                });
            }
        }

        {
            toolkit.createLabel(sectionClient, "Fonts:")
                    .setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
            Composite container = toolkit.createComposite(sectionClient);
            GridLayout gl = new GridLayout(2, false);
            gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginWidth = 0;
            container.setLayout(gl);
            GridData gdContainer = new GridData(GridData.FILL_HORIZONTAL);
            gdContainer.horizontalSpan = COLUMN_COUNT - 1;
            container.setLayoutData(gdContainer);

            Composite tableContainer = toolkit.createComposite(container);
            Table t = toolkit.createTable(tableContainer,
                    SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
            t.setHeaderVisible(true);
            t.setLinesVisible(true);

            GridData gdTable = new GridData(GridData.FILL_HORIZONTAL);
            gdTable.heightHint = t.getItemHeight() * 5;
            tableContainer.setLayoutData(gdTable);

            TableColumnLayout tablelayout = new TableColumnLayout();

            final TableViewer v = new TableViewer(t);
            GridData gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.heightHint = t.getItemHeight() * 5;
            v.getControl().setLayoutData(gd);
            final ArrayContentProvider cp = new ArrayContentProvider();
            v.setContentProvider(cp);

            {
                IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                        ParametersPackage.Literals.KEY_VALUE_PAIR__KEY);
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                TableColumn tc = c.getColumn();
                tc.setText("Font name");
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((KeyValuePair) element).getKey();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(33));
            }

            {
                IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                        ParametersPackage.Literals.KEY_VALUE_PAIR__VALUE);
                TableViewerColumn c = new TableViewerColumn(v, SWT.NONE);
                TableColumn tc = c.getColumn();
                tc.setText("File");
                c.setLabelProvider(new ColumnLabelProvider() {
                    @Override
                    public String getText(Object element) {
                        return ((KeyValuePair) element).getValue();
                    }
                });
                tablelayout.setColumnData(c.getColumn(), new ColumnWeightData(67));
            }
            tableContainer.setLayout(tablelayout);
            v.setInput(task.getFonts());

            Composite buttonComp = toolkit.createComposite(container);
            buttonComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false));
            buttonComp.setLayout(new GridLayout());

            {
                Button b = toolkit.createButton(buttonComp, "Add ...", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        if (handleAddFont()) {
                            final KeyValuePair newFont = task.getFonts().get(task.getFonts().size() - 1);
                            v.refresh();
                            v.setSelection(new StructuredSelection(newFont));
                        }
                    }
                });
            }

            {
                Button b = toolkit.createButton(buttonComp, "Remove", SWT.PUSH);
                b.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
                b.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(final SelectionEvent e) {
                        KeyValuePair value = (KeyValuePair) ((IStructuredSelection) v.getSelection())
                                .getFirstElement();
                        if (value != null) {
                            if (handleRemoveFont(value)) {
                                v.setInput(task.getFonts());
                            }
                        } else {
                            MessageDialog.openWarning(getSite().getShell(), "Warning",
                                    "Please select an entry");
                        }
                    }
                });
            }
        }
        section.setClient(sectionClient);
    }
    int index = addPage(composite);
    setPageText(index, "Deploy");
}

From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java

License:Open Source License

private void createPageSigning(AntTask task) {
    Composite composite = new Composite(getContainer(), SWT.NONE);
    FillLayout layout = new FillLayout();
    composite.setLayout(layout);// www.  j  ava  2 s.  c  om
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
            JavaFXUIPlugin.PLUGIN_ID + ".JFXBuildConfigurationEditor_signing");

    final WritableValue bean = new WritableValue();
    bean.setValue(task);

    toolkit = new FormToolkit(composite.getDisplay());

    final Form form = toolkit.createForm(composite);
    form.setText("FX Build Configuration");
    form.setImage(getTitleImage());
    form.getBody().setLayout(new FillLayout());
    toolkit.decorateFormHeading(form);

    initToolbar(form);

    ScrolledForm scrolledForm = toolkit.createScrolledForm(form.getBody());
    scrolledForm.getBody().setLayout(new GridLayout(2, false));
    Composite sectionParent = scrolledForm.getBody();

    dbc = new DataBindingContext();
    IWidgetValueProperty textModify = WidgetProperties.text(SWT.Modify);

    {
        Section section = toolkit.createSection(sectionParent,
                Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
        section.setText("Signing Properties");
        section.setDescription("Information for signing result jar");
        section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Composite sectionClient = toolkit.createComposite(section);
        sectionClient.setLayout(new GridLayout(4, false));

        {
            toolkit.createLabel(sectionClient, "Alias*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__SIGNJAR, SIGN_JAR__ALIAS));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Key-Password*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__SIGNJAR, SIGN_JAR__KEYPASS));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Keystore*:");
            final Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            toolkit.createButton(sectionClient, "Filesystem ...", SWT.PUSH)
                    .addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent e) {
                            String v = handleKeyStoreFilesystemSelection(t.getShell());
                            if (v != null) {
                                t.setText(v);
                            }
                        }
                    });
            toolkit.createButton(sectionClient, "Workspace ...", SWT.PUSH)
                    .addSelectionListener(new SelectionAdapter() {
                        @Override
                        public void widgetSelected(final SelectionEvent e) {
                            String v = handleKeyStoreWorkspaceSelection(t.getShell());
                            if (v != null) {
                                t.setText(v);
                            }
                        }
                    });
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__SIGNJAR, SIGN_JAR__KEYSTORE));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Store-Password*:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__SIGNJAR, SIGN_JAR__STOREPASS));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        {
            toolkit.createLabel(sectionClient, "Storetype:");
            Text t = toolkit.createText(sectionClient, "", SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 3, 1));
            IEMFValueProperty prop = EMFEditProperties.value(editingDomain,
                    FeaturePath.fromList(ANT_TASK__SIGNJAR, SIGN_JAR__STORETYPE));
            dbc.bindValue(textModify.observeDelayed(DELAY, t), prop.observeDetail(bean));
        }

        section.setClient(sectionClient);
    }

    int index = addPage(composite);
    setPageText(index, "Signing");
}

From source file:com.iks.hto.karteikastensystem.simple.rcp.databinding.FormBuilder.java

License:Open Source License

/**
 * Build a two column form with the elements added
 * //w w w .ja  v  a  2 s.  co  m
 * @param dbc
 *            the databinding context
 * @param parent
 *            the parent the form is created on
 * @param object
 *            the object to bind
 * @param nachSeite
 * @return the form container
 */
public Composite build(DataBindingContext dbc, Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(2, false));

    IWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);
    IWidgetValueProperty comboProp = new ComboTextProperty();

    for (Entry e : entries) {

        Label l = new Label(container, SWT.NONE);
        l.setText(e.label);

        IObservableValue uiObs = null;
        if (e.type.equals(TEXT_TYPE)) {
            Text t = new Text(container, SWT.BORDER);
            t.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

            uiObs = textProp.observeDelayed(400, t);

        } else if (e.type.equals(COMBO_TYPE)) {
            Combo cb = new Combo(container, SWT.DROP_DOWN);
            cb.setItems(e.options);
            cb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

            uiObs = comboProp.observeDelayed(400, cb);
        } else if (e.type.equals(ONLY_LABEL_TYPE)) {
            Label dummy = new Label(container, SWT.NONE);
            dummy.setText("");
        }

        IObservableValue mObs;

        if (e.bindTo != null) {
            if (e.bindTo instanceof IObservableValue) {
                mObs = e.property.observeDetail((IObservableValue) e.bindTo);
            } else {
                mObs = e.property.observe(e.bindTo);
            }

            // TODO: Hier findet das Binding statt!!! Inkl. Update-strategie
            // und
            // Validation
            dbc.bindValue(uiObs, mObs,
                    new EMFUpdateValueStrategy().setBeforeSetValidator(new EmptyStringValidator(e.nullMessage)),
                    null);
        }
    }

    return container;
}