Example usage for org.eclipse.jface.fieldassist DecoratedField addFieldDecoration

List of usage examples for org.eclipse.jface.fieldassist DecoratedField addFieldDecoration

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist DecoratedField addFieldDecoration.

Prototype

public void addFieldDecoration(FieldDecoration decoration, int position, boolean showOnFocus) 

Source Link

Document

Adds an image decoration to the field.

Usage

From source file:org.springframework.ide.eclipse.webflow.ui.graph.dialogs.ActionPropertiesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/*from w w w .  j a v  a2  s.  c o  m*/
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    TabFolder folder = new TabFolder(composite, SWT.NULL);
    folder.setLayoutData(new GridData(GridData.FILL_BOTH));
    TabItem item1 = new TabItem(folder, SWT.NULL);
    item1.setText("General");
    item1.setImage(getImage());
    TabItem item2 = new TabItem(folder, SWT.NULL);

    Group groupActionType = new Group(folder, SWT.NULL);
    GridLayout layoutAttMap = new GridLayout();
    layoutAttMap.marginWidth = 3;
    layoutAttMap.marginHeight = 3;
    groupActionType.setLayout(layoutAttMap);
    if (WebflowModelXmlUtils.isVersion1Flow(action)) {
        groupActionType.setText(" Action ");
    } else {
        groupActionType.setText(" Render ");
    }
    GridData grid = new GridData();
    groupActionType.setLayoutData(grid);

    Composite nameGroup = new Composite(groupActionType, SWT.NULL);
    nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout1 = new GridLayout();
    layout1.numColumns = 3;
    layout1.marginWidth = 5;
    nameGroup.setLayout(layout1);
    nameLabel = new Label(nameGroup, SWT.NONE);
    if (WebflowModelXmlUtils.isVersion1Flow(action)) {
        nameLabel.setText("Name");
    } else {
        nameLabel.setText("Fragments");
    }
    nameText = new Text(nameGroup, SWT.SINGLE | SWT.BORDER);
    if (this.action != null && this.action.getName() != null) {
        this.nameText.setText(this.action.getName());
    }
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    new Label(nameGroup, SWT.NONE);

    if (WebflowModelXmlUtils.isVersion1Flow(action)) {
        // Label field.
        beanLabel = new Label(nameGroup, SWT.NONE);
        beanLabel.setText("Bean");
        GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = LABEL_WIDTH;
        beanLabel.setLayoutData(gridData);

        // Create a decorated field with a required field decoration.
        DecoratedField beanField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER,
                new TextControlCreator());
        FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        beanField.addFieldDecoration(requiredFieldIndicator, SWT.TOP | SWT.LEFT, true);
        beanText = (Text) beanField.getControl();
        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        beanField.getLayoutControl().setLayoutData(data);

        if (this.action != null && this.action.getBean() != null) {
            beanText.setText(this.action.getBean());
        }
        beanText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                if (validator != null) {
                    validator.validateInput();
                }
            }
        });

        DialogUtils.attachContentAssist(beanText, WebflowUtils.getBeansFromEditorInput().toArray());

        browseBeanButton = new Button(nameGroup, SWT.PUSH);
        browseBeanButton.setText("...");
        browseBeanButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        browseBeanButton.addSelectionListener(buttonListener);

        methodLabel = new Label(nameGroup, SWT.NONE);
        methodLabel.setText("Method");

        // Create a decorated field with a required field decoration.
        DecoratedField methodField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER,
                new TextControlCreator());
        FieldDecoration requiredFieldIndicator1 = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        methodField.addFieldDecoration(requiredFieldIndicator1, SWT.TOP | SWT.LEFT, true);
        methodText = (Text) methodField.getControl();
        data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        methodField.getLayoutControl().setLayoutData(data);

        if (this.action != null && this.action.getMethod() != null) {
            this.methodText.setText(this.action.getMethod());
        }
        methodText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                validateInput();
            }
        });

        DialogUtils.attachContentAssist(methodText,
                WebflowUtils.getActionMethods(this.actionClone.getNode()).toArray());

        browseMethodButton = new Button(nameGroup, SWT.PUSH);
        browseMethodButton.setText("...");
        browseMethodButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        browseMethodButton.addSelectionListener(buttonListener);
    }
    // add the indent after getting the decorated field
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
    nameText.setLayoutData(data);

    item1.setControl(groupActionType);

    properties = new PropertiesComposite(this, item2, getShell(), (IAttributeEnabled) this.actionClone);
    item2.setControl(properties.createDialogArea(folder));

    applyDialogFont(parentComposite);

    return parentComposite;
}

From source file:org.springframework.ide.eclipse.webflow.ui.graph.dialogs.BeanActionPropertiesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;//  w  w w.  j a v a 2  s .  c o m
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    TabFolder folder = new TabFolder(composite, SWT.NULL);
    folder.setLayoutData(new GridData(GridData.FILL_BOTH));
    TabItem item1 = new TabItem(folder, SWT.NULL);
    item1.setText("General");
    item1.setImage(getImage());
    TabItem item2 = new TabItem(folder, SWT.NULL);

    Group groupActionType = new Group(folder, SWT.NULL);
    GridLayout layoutAttMap = new GridLayout();
    layoutAttMap.marginWidth = 3;
    layoutAttMap.marginHeight = 3;
    groupActionType.setLayout(layoutAttMap);
    groupActionType.setText(" Action ");
    GridData grid = new GridData();
    groupActionType.setLayoutData(grid);

    Composite nameGroup = new Composite(groupActionType, SWT.NULL);
    nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout1 = new GridLayout();
    layout1.numColumns = 3;
    layout1.marginWidth = 5;
    nameGroup.setLayout(layout1);
    nameLabel = new Label(nameGroup, SWT.NONE);
    nameLabel.setText("Name");
    nameText = new Text(nameGroup, SWT.SINGLE | SWT.BORDER);
    if (this.action != null && this.action.getName() != null) {
        this.nameText.setText(this.action.getName());
    }
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    new Label(nameGroup, SWT.NONE);

    // Label field.
    beanLabel = new Label(nameGroup, SWT.NONE);
    beanLabel.setText("Bean");
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = LABEL_WIDTH;
    beanLabel.setLayoutData(gridData);

    // Create a decorated field with a required field decoration.
    DecoratedField beanField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER, new TextControlCreator());
    FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    beanField.addFieldDecoration(requiredFieldIndicator, SWT.TOP | SWT.LEFT, true);
    beanText = (Text) beanField.getControl();
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    beanField.getLayoutControl().setLayoutData(data);

    if (this.action != null && this.action.getBean() != null) {
        beanText.setText(this.action.getBean());
    }
    beanText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (validator != null) {
                validator.validateInput();
            }
        }
    });

    DialogUtils.attachContentAssist(beanText, WebflowUtils.getBeansFromEditorInput().toArray());

    browseBeanButton = new Button(nameGroup, SWT.PUSH);
    browseBeanButton.setText("...");
    browseBeanButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    browseBeanButton.addSelectionListener(buttonListener);

    methodLabel = new Label(nameGroup, SWT.NONE);
    methodLabel.setText("Method");

    // Create a decorated field with a required field decoration.
    DecoratedField methodField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER,
            new TextControlCreator());
    FieldDecoration requiredFieldIndicator1 = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    methodField.addFieldDecoration(requiredFieldIndicator1, SWT.TOP | SWT.LEFT, true);
    methodText = (Text) methodField.getControl();
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    methodField.getLayoutControl().setLayoutData(data);

    if (this.action != null && this.action.getMethod() != null) {
        this.methodText.setText(this.action.getMethod());
    }
    methodText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    DialogUtils.attachContentAssist(methodText,
            WebflowUtils.getActionMethods(this.actionClone.getNode()).toArray());

    browseMethodButton = new Button(nameGroup, SWT.PUSH);
    browseMethodButton.setText("...");
    browseMethodButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    browseMethodButton.addSelectionListener(buttonListener);

    // add the indent after getting the decorated field
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
    nameText.setLayoutData(data);

    Group groupPropertyType = new Group(groupActionType, SWT.NULL);
    GridLayout layoutPropMap = new GridLayout();
    layoutPropMap.marginWidth = 3;
    layoutPropMap.marginHeight = 3;
    groupPropertyType.setLayout(layoutPropMap);
    groupPropertyType.setText(" Method Arguments ");
    groupPropertyType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite tableAndButtons = new Composite(groupPropertyType, SWT.NONE);
    tableAndButtons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout2 = new GridLayout();
    layout2.marginHeight = 0;
    layout2.marginWidth = 0;
    layout2.numColumns = 2;
    tableAndButtons.setLayout(layout2);

    Table configsTable = new Table(tableAndButtons,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    // data.widthHint = 250;
    data.heightHint = 70;
    configsTable.setLayoutData(data);
    TableColumn columnName = new TableColumn(configsTable, SWT.NONE);
    columnName.setText("Expression");
    columnName.setWidth(150);
    TableColumn columnType = new TableColumn(configsTable, SWT.NONE);
    columnType.setText("Type");
    columnType.setWidth(200);
    configsTable.setHeaderVisible(true);

    configsViewer = new TableViewer(configsTable);
    String[] columnNames = new String[] { "Expression", "Type" };
    configsViewer.setColumnProperties(columnNames);
    configsViewer.setContentProvider(new MethodArgumentContentProvider(this.methodArguments, configsViewer));
    configsViewer.setLabelProvider(new ModelTableLabelProvider());
    configsViewer.setCellModifier(new TableCellModifier());
    configsViewer.setInput(this.action);
    configsTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            handleTableSelectionChanged();
        }
    });
    Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
    GridLayout layout4 = new GridLayout();
    layout4.marginHeight = 0;
    layout4.marginWidth = 0;
    buttonArea.setLayout(layout4);
    buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
    addButton = new Button(buttonArea, SWT.PUSH);
    addButton.setText("Add");
    GridData data1 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data1.widthHint = 40;
    addButton.setLayoutData(data1);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IArgument property = new Argument();
            property.createNew(actionClone);
            MethodArgumentEditorDialog dialog = new MethodArgumentEditorDialog(getParentShell(), property);
            if (dialog.open() == Dialog.OK) {
                methodArguments.add(property);
                configsViewer.refresh(true);
            }
        }
    });
    editButton = new Button(buttonArea, SWT.PUSH);
    editButton.setText("Edit");
    data1 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data1.widthHint = 40;
    editButton.setLayoutData(data1);
    editButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) configsViewer.getSelection();
            if (selection.getFirstElement() != null) {
                if (selection.getFirstElement() instanceof IArgument) {
                    IArgument property = (IArgument) selection.getFirstElement();
                    MethodArgumentEditorDialog dialog = new MethodArgumentEditorDialog(getParentShell(),
                            property);
                    if (dialog.open() == Dialog.OK) {
                        configsViewer.refresh(true);
                    }
                }
            }
        }
    });

    removeButton = new Button(buttonArea, SWT.PUSH);
    removeButton.setText("Delete");
    GridData data2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data1.widthHint = 40;
    removeButton.setLayoutData(data2);
    removeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) configsViewer.getSelection();
            if (selection.getFirstElement() != null) {
                if (selection.getFirstElement() instanceof IArgument) {
                    IArgument property = (IArgument) selection.getFirstElement();
                    methodArguments.remove(property);
                    configsViewer.refresh(true);
                }
            }
        }
    });
    removeButton.setEnabled(false);
    editButton.setEnabled(false);

    Group groupMethodResult = new Group(groupActionType, SWT.NULL);
    layoutAttMap = new GridLayout();
    layoutAttMap.marginWidth = 3;
    layoutAttMap.marginHeight = 3;
    layoutAttMap.numColumns = 3;
    layoutAttMap.marginWidth = 5;
    groupMethodResult.setLayout(layoutAttMap);
    groupMethodResult.setText(" Method Result ");
    groupMethodResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    resultNameLabel = new Label(groupMethodResult, SWT.NONE);
    resultNameLabel.setText("Name");
    resultNameText = new Text(groupMethodResult, SWT.SINGLE | SWT.BORDER);
    if (this.action != null && this.action.getMethodResult() != null) {
        this.resultNameText.setText(this.action.getMethodResult().getName());
    }
    resultNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    resultNameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    new Label(groupMethodResult, SWT.NONE);

    // Label field.
    scopeLabel = new Label(groupMethodResult, SWT.NONE);
    scopeLabel.setText("Scope");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = LABEL_WIDTH;
    scopeLabel.setLayoutData(gridData);

    // Add the text box for action classname.
    scopeText = new Combo(groupMethodResult, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
    scopeText.setItems(new String[] { "", "request", "flash", "flow", "conversation", "default" });
    if (this.action != null && this.action.getMethodResult() != null
            && this.action.getMethodResult().getScope() != null) {
        scopeText.setText(this.action.getMethodResult().getScope());
    }
    scopeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    scopeText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validator.validateInput();
        }
    });

    new Label(groupMethodResult, SWT.NONE);

    item1.setControl(groupActionType);

    properties = new PropertiesComposite(this, item2, getShell(), (IAttributeEnabled) this.actionClone);
    item2.setControl(properties.createDialogArea(folder));

    applyDialogFont(parentComposite);

    return parentComposite;
}

From source file:org.springframework.ide.eclipse.webflow.ui.graph.dialogs.ExceptionHandlerPropertiesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/*from ww  w  .j av a  2 s  .  co  m*/
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite nameGroup = new Composite(composite, SWT.NULL);
    nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout1 = new GridLayout();
    layout1.numColumns = 3;
    layout1.marginWidth = 5;
    nameGroup.setLayout(layout1);

    // Label field.
    beanLabel = new Label(nameGroup, SWT.NONE);
    beanLabel.setText("Bean");
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gridData.widthHint = LABEL_WIDTH;
    beanLabel.setLayoutData(gridData);

    // Create a decorated field with a required field decoration.
    DecoratedField beanField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER, new TextControlCreator());
    FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    beanField.addFieldDecoration(requiredFieldIndicator, SWT.TOP | SWT.LEFT, true);
    beanText = (Text) beanField.getControl();
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    beanField.getLayoutControl().setLayoutData(data);
    if (this.action != null && this.action.getBean() != null) {
        beanText.setText(this.action.getBean());
    }
    beanText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (validator != null) {
                validator.validateInput();
            }
        }
    });

    DialogUtils.attachContentAssist(beanText, WebflowUtils.getBeansFromEditorInput().toArray());

    browseBeanButton = new Button(nameGroup, SWT.PUSH);
    browseBeanButton.setText("...");
    browseBeanButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    browseBeanButton.addSelectionListener(buttonListener);

    applyDialogFont(parentComposite);
    return parentComposite;
}

From source file:org.springframework.ide.eclipse.webflow.ui.graph.dialogs.SubFlowStatePropertiesDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;//from w w w. j a va2  s. c o  m
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    TabFolder folder = new TabFolder(composite, SWT.NULL);
    TabItem item1 = new TabItem(folder, SWT.NULL);
    item1.setText("General");
    item1.setImage(getImage());
    TabItem item2 = new TabItem(folder, SWT.NULL);
    TabItem item3 = new TabItem(folder, SWT.NULL);
    TabItem item4 = new TabItem(folder, SWT.NULL);
    TabItem item5 = new TabItem(folder, SWT.NULL);
    TabItem item6 = new TabItem(folder, SWT.NULL);

    Group groupActionType = new Group(folder, SWT.NULL);
    GridLayout layoutAttMap = new GridLayout();
    layoutAttMap.marginWidth = 3;
    layoutAttMap.marginHeight = 3;
    groupActionType.setLayout(layoutAttMap);
    groupActionType.setText(" Subflow State ");
    GridData grid = new GridData();
    groupActionType.setLayoutData(grid);

    Composite nameGroup = new Composite(groupActionType, SWT.NULL);
    nameGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout1 = new GridLayout();
    layout1.numColumns = 3;
    layout1.marginWidth = 5;
    nameGroup.setLayout(layout1);
    nameLabel = new Label(nameGroup, SWT.NONE);
    nameLabel.setText("State id");
    nameText = new Text(nameGroup, SWT.SINGLE | SWT.BORDER);
    if (this.state != null && this.state.getId() != null) {
        this.nameText.setText(this.state.getId());
    }
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    new Label(nameGroup, SWT.NONE);

    flowLabel = new Label(nameGroup, SWT.NONE);
    if (WebflowModelXmlUtils.isVersion1Flow(state)) {
        flowLabel.setText("Flow");
    } else {
        flowLabel.setText("Subflow");
    }

    // Create a decorated field with a required field decoration.
    DecoratedField flowField = new DecoratedField(nameGroup, SWT.SINGLE | SWT.BORDER, new TextControlCreator());
    FieldDecoration requiredFieldIndicator = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    flowField.addFieldDecoration(requiredFieldIndicator, SWT.TOP | SWT.LEFT, true);
    flowText = (Text) flowField.getControl();
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    flowField.getLayoutControl().setLayoutData(data);
    if (this.state != null && this.state.getFlow() != null) {
        this.flowText.setText(this.state.getFlow());
    }
    flowText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    // add the indent after getting the decorated field
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
    nameText.setLayoutData(data);

    DialogUtils.attachContentAssist(flowText, WebflowUtils.getWebflowConfigNames());

    browseFlowButton = new Button(nameGroup, SWT.PUSH);
    browseFlowButton.setText("...");
    browseFlowButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    browseFlowButton.addSelectionListener(buttonListener);

    if (!WebflowModelXmlUtils.isVersion1Flow(state)) {
        parentLabel = new Label(nameGroup, SWT.NONE);
        parentLabel.setText("Parent state id");
        parentText = new Text(nameGroup, SWT.SINGLE | SWT.BORDER);
        if (this.state != null && this.state.getParent() != null) {
            this.parentText.setText(this.state.getParent());
        }
        parentText.setLayoutData(data);
        parentText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                validateInput();
            }
        });

        new Label(nameGroup, SWT.NONE);
    }

    item1.setControl(groupActionType);

    // add attribute mapper

    item2.setText("Attribute Mapper");
    item2.setImage(WebflowUIImages.getImage(WebflowUIImages.IMG_OBJS_ATTRIBUTE_MAPPER));

    Composite attributeMapperGroup = new Composite(folder, SWT.NULL);
    attributeMapperGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    layout1 = new GridLayout();
    layout1.numColumns = 1;
    layout1.marginWidth = 0;
    layout1.marginHeight = 0;
    attributeMapperGroup.setLayout(layout1);

    Group attributeMapperType = new Group(attributeMapperGroup, SWT.NULL);
    layoutAttMap = new GridLayout();
    layoutAttMap.marginWidth = 3;
    layoutAttMap.marginHeight = 3;
    attributeMapperType.setText(" Attribute Mapper ");
    attributeMapperType.setLayoutData(new GridData(GridData.FILL_BOTH));
    attributeMapperType.setLayout(layoutAttMap);

    Composite attributeMapperTypeGroup = new Composite(attributeMapperType, SWT.NULL);
    attributeMapperTypeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout1 = new GridLayout();
    layout1.numColumns = 3;
    layout1.marginWidth = 5;
    attributeMapperTypeGroup.setLayout(layout1);

    attributeMapperBeanLabel = new Label(attributeMapperTypeGroup, SWT.NONE);
    attributeMapperBeanLabel.setText("Bean");

    // Create a decorated field with a required field decoration.
    DecoratedField beanField = new DecoratedField(attributeMapperTypeGroup, SWT.SINGLE | SWT.BORDER,
            new TextControlCreator());
    FieldDecoration requiredFieldIndicator3 = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    beanField.addFieldDecoration(requiredFieldIndicator3, SWT.TOP | SWT.LEFT, true);
    attributeMapperBeanText = (Text) beanField.getControl();
    data = new GridData(GridData.FILL_HORIZONTAL);
    beanField.getLayoutControl().setLayoutData(data);
    if (this.state != null && this.state.getAttributeMapper() != null
            && this.state.getAttributeMapper().getBean() != null) {
        this.attributeMapperBeanText.setText(this.state.getAttributeMapper().getBean());
    }
    if (this.state != null && this.state.getSubflowAttributeMapper() != null) {
        this.attributeMapperBeanText.setText(this.state.getSubflowAttributeMapper());
    }
    attributeMapperBeanText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });

    DialogUtils.attachContentAssist(attributeMapperBeanText, WebflowUtils.getBeansFromEditorInput().toArray());

    browseBeanButton = new Button(attributeMapperTypeGroup, SWT.PUSH);
    browseBeanButton.setText("...");
    browseBeanButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    browseBeanButton.addSelectionListener(buttonListener);

    TabFolder folder2 = new TabFolder(attributeMapperGroup, SWT.NULL);
    folder2.setLayoutData(new GridData(GridData.FILL_BOTH));
    TabItem item21 = new TabItem(folder2, SWT.NULL);
    TabItem item22 = new TabItem(folder2, SWT.NULL);

    inputMapperComposite = new InputMapperComposite(this, item21, getShell(), this.inputAttributes,
            this.inputMapping, this.stateClone.getAttributeMapper().getInputMapper());
    item21.setControl(inputMapperComposite.createDialogArea(folder2));

    outputMapperComposite = new OutputMapperComposite(this, item22, getShell(), this.outputAttributes,
            this.outputMapping, this.stateClone.getAttributeMapper().getOutputMapper());
    item22.setControl(outputMapperComposite.createDialogArea(folder2));

    item2.setControl(attributeMapperGroup);

    entryActionsComposite = new ActionComposite(this, item3, getShell(), this.entryActions,
            this.stateClone.getEntryActions(), IActionElement.ACTION_TYPE.ENTRY_ACTION);
    item3.setControl(entryActionsComposite.createDialogArea(folder));

    exitActionsComposite = new ActionComposite(this, item4, getShell(), this.exitActions,
            this.stateClone.getExitActions(), IActionElement.ACTION_TYPE.EXIT_ACTION);
    item4.setControl(exitActionsComposite.createDialogArea(folder));

    exceptionHandlerComposite = new ExceptionHandlerComposite(this, item5, getShell(), this.exceptionHandler,
            this.stateClone);
    item5.setControl(exceptionHandlerComposite.createDialogArea(folder));

    properties = new PropertiesComposite(this, item6, getShell(), (IAttributeEnabled) this.stateClone);
    item6.setControl(properties.createDialogArea(folder));

    applyDialogFont(parentComposite);

    if (this.index >= 0) {
        folder.setSelection(this.index);
    }

    return parentComposite;
}

From source file:org.talend.camel.designer.generator.RouteComponentController.java

License:Open Source License

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow,
        final int nbInRow, final int top, final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    FormData data;/*from   www. j ava  2  s .c  o  m*/

    IElementParameter processTypeParameter = param.getChildParameters()
            .get(EParameterName.ROUTE_COMPONENT_TYPE_ID.getName());

    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER | SWT.READ_ONLY,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();

    labelText = (Text) dField.getControl();

    labelText.setData(PARAMETER_NAME, param.getName());

    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(false);
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    addDragAndDropTarget(labelText);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / (nbInRow + 1)), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }

    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }

    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / (nbInRow + 1), 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);

    Button btn;
    Point btnSize;

    btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); //$NON-NLS-1$
    btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    btn.addSelectionListener(listenerSelection);
    btn.setData(PARAMETER_NAME, param.getName() + STRING + processTypeParameter.getName());
    btn.setEnabled(!param.isReadOnly());
    data = new FormData();
    data.left = new FormAttachment(cLayout, 0);
    data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btn.setLayoutData(data);

    hashCurControls.put(param.getName() + STRING + processTypeParameter.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(Math.max(initialSize.y, btnSize.y) + ITabbedPropertyConstants.VSPACE);
    return btn;
}

From source file:org.talend.camel.designer.generator.RouteResourceController.java

License:Open Source License

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow,
        final int nbInRow, final int top, final Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    FormData data;//w  ww  .j  a va2s  .co m

    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER | SWT.READ_ONLY,
            new SelectAllTextControlCreator());
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();

    labelText = (Text) dField.getControl();

    labelText.setData(PARAMETER_NAME, param.getName());

    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(false);
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    addDragAndDropTarget(labelText);

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment(((numInRow - 1) * MAX_PERCENT) / (nbInRow + 1), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }

    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }

    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / (nbInRow + 1), 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);

    Button btn;
    Point btnSize;

    btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); //$NON-NLS-1$
    btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    btn.addSelectionListener(listenerSelection);
    btn.setData(PARAMETER_NAME, param.getName());
    btn.setEnabled(!param.isReadOnly());
    data = new FormData();
    data.left = new FormAttachment(cLayout, 0);
    data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btn.setLayoutData(data);

    hashCurControls.put(param.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Control lastControlUsed = btn;
    lastControlUsed = addVersionCombo(subComposite,
            param.getChildParameters().get(EParameterName.ROUTE_RESOURCE_TYPE_VERSION.getName()),
            lastControlUsed, numInRow + 1, nbInRow, top);
    dynamicProperty.setCurRowSize(Math.max(initialSize.y, btnSize.y) + ITabbedPropertyConstants.VSPACE);
    return btn;
}

From source file:org.talend.camel.designer.generator.RouteResourceController.java

License:Open Source License

/**
 * /*from   w  ww  .  ja  va2  s. co  m*/
 * @param subComposite
 * @param param
 * @param lastControl
 * @param numInRow
 * @param nbInRow
 * @param top
 * @return
 */
private Control addVersionCombo(Composite subComposite, IElementParameter param, Control lastControl,
        int numInRow, int nbInRow, int top) {
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        decoration.setDescription(""); //$NON-NLS-1$
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setItems(getListToDisplay(param));
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    combo.setData(PARAMETER_NAME, param.getName());
    if (elem instanceof Node) {
        combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment(((numInRow - 1) * MAX_PERCENT) / nbInRow, 0);
    }

    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }

    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), combo);

    return cLayout;
}

From source file:org.talend.component.ui.wizard.controller.ComponentRefController.java

License:Open Source License

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow,
        final int nbInRow, final int top, final Control lastControl) {

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }//from   w  w  w .j av a2s . c om
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        decoration.setDescription(Messages.getString("ComboController.valueFromRepository")); //$NON-NLS-1$
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            Command cmd = createCommand(event);
            executeCommand(cmd);
        }
    });
    combo.setData(PARAMETER_NAME, param.getName());
    int nbLines = param.getNbLines();
    if (nbLines > 5) {
        combo.setVisibleItemCount(nbLines);
    }
    if (elem instanceof Node) {
        combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }

    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }

    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), combo);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}

From source file:org.talend.component.ui.wizard.controller.NameAndLabelsReferenceController.java

License:Open Source License

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow,
        final int nbInRow, final int top, final Control lastControl) {
    this.curParameter = param;
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    FormData data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {/*from   ww w .j  av a 2  s  .  c  o  m*/
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }

    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH); //$NON-NLS-1$

    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));

    data = new FormData();
    data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
    data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, MODULE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    // btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Command cmd = createCommand((Button) e.getSource());
            executeCommand(cmd);
        }
    });

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        decoration.setDescription(Messages.getString("FileController.decoration.description")); //$NON-NLS-1$
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    Text moduleText = (Text) dField.getControl();
    moduleText.setData(PARAMETER_NAME, param.getName());
    moduleText.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());

    addDragAndDropTarget(moduleText);
    if (elem instanceof Node) {
        moduleText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    hashCurControls.put(param.getName(), moduleText);

    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment(btnEdit, 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    cLayout.setLayoutData(data);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);

    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);

    return btnEdit;
}

From source file:org.talend.designer.core.generic.controller.ComponentRefController.java

License:Open Source License

@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow,
        final int nbInRow, final int top, final Control lastControl) {

    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }/* w  w  w .  j a v a  2s.  co  m*/
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        decoration.setDescription(Messages.getString("ComboController.valueFromRepository")); //$NON-NLS-1$
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }

    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());

    GenericElementParameter gParam = (GenericElementParameter) param;
    ComponentReferenceProperties props = (ComponentReferenceProperties) gParam.getWidget().getContent();
    props.componentInstanceId.setTaggedValue(IGenericConstants.ADD_QUOTES, true);

    combo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            if (!(event.getSource() instanceof CCombo)) {
                return;
            }
            Command cmd = createComboCommand(event, gParam, props);
            executeCommand(cmd);
        }
    });
    combo.setData(PARAMETER_NAME, param.getName());
    int nbLines = param.getNbLines();
    if (nbLines > 5) {
        combo.setVisibleItemCount(nbLines);
    }
    if (elem instanceof Node) {
        combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }

    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }

    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    // *********************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();

    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }

    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }

    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), combo);

    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}