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

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

Introduction

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

Prototype

public DecoratedField(Composite parent, int style, IControlCreator controlCreator) 

Source Link

Document

Construct a decorated field which is parented by the specified composite and has the given style bits.

Usage

From source file:com.nokia.tools.s60.views.SearchViewPage.java

License:Open Source License

public void createCompositeArea(Composite parent) {
    Composite dialogArea = parent;
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;/*  w  ww. j a  v  a2  s.c  o m*/
    gridLayout.marginWidth = 0;

    dialogArea.setLayout(gridLayout);

    fTypeMethodsSplitter = new SashForm(dialogArea, SWT.VERTICAL);
    fTypeMethodsSplitter.setLayoutData(new GridData(GridData.FILL_BOTH));
    fTypeMethodsSplitter.setLayout(new GridLayout());
    fTypeMethodsSplitter.setVisible(true);

    fTypeMethodsSplitter.addControlListener(new ControlAdapter() {
        public void controlResized(ControlEvent e) {
            SashForm splitter = (SashForm) e.widget;
            if (splitter.getOrientation() == SWT.HORIZONTAL) {
                int widthAll = fTypeMethodsSplitter.getSize().x;
                int patternMargin = ((GridLayout) c1.getLayout()).marginHeight;
                int spacing = ((GridLayout) c1.getLayout()).horizontalSpacing;
                if (widthAll > 0) {
                    if (((patternHorizontalLayoutWidth + 4 * patternMargin + 2 * spacing)) <= widthAll) {
                        horizontalSearchInput = (int) ((patternHorizontalLayoutWidth + 4 * patternMargin
                                + 2 * spacing) * 100 / widthAll);
                    } else {
                        horizontalSearchInput = 100;
                    }
                } else {
                    horizontalSearchInput = 10;
                }
                fTypeMethodsSplitter
                        .setWeights(new int[] { horizontalSearchInput, 100 - horizontalSearchInput });

            } else if (splitter.getOrientation() == SWT.VERTICAL) {
                int heightAll = fTypeMethodsSplitter.getSize().y;
                int verticalSearchInputRatio = 0;
                if (heightAll > 0) {
                    if (verticalSearchInput <= heightAll) {
                        verticalSearchInputRatio = (verticalSearchInput * 100) / heightAll;
                    } else {
                        verticalSearchInputRatio = 100;
                    }

                } else {
                    verticalSearchInputRatio = 20;
                }
                fTypeMethodsSplitter
                        .setWeights(new int[] { verticalSearchInputRatio, 100 - verticalSearchInputRatio });

            }
        }
    });

    c1 = new Composite(fTypeMethodsSplitter, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 3;
    layout.verticalSpacing = 0;
    c1.setLayout(layout);
    c1.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite c2 = new Composite(fTypeMethodsSplitter, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    c2.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    c2.setLayoutData(data);

    tableViewer = new TableViewer(c2,
            SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);

    items = tableViewer.getTable();

    data = new GridData(GridData.FILL_BOTH);
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    data.horizontalAlignment = SWT.BEGINNING;
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;

    items.setLayoutData(data);

    // finds all component names in a system
    initSearchInput();

    decoratedPattern = new DecoratedField(c1, SWT.BORDER, new TextControlCreator());
    FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
    FieldDecoration standardDecoration = registry
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    standardDecoration.setDescription("Press Ctrl+Space to see example search inputs and history");
    decoratedPattern.addFieldDecoration(standardDecoration, SWT.TOP | SWT.LEFT, true);
    initSuggestionsAndHistory();

    pattern = (Text) decoratedPattern.getControl();
    pattern.setToolTipText("* = any string");
    pattern.addFocusListener(new FocusAdapter() {
        // this is to ensure that after opening when user selects pattern
        // input can view all items
        public void focusGained(FocusEvent event) {
            initSearchInput();

            tableViewer.setInput(filteredInput);
            if (tableViewer.getSelection() == null && tableViewer.getElementAt(0) != null) {
                tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0)));
            }

        }
    });
    installContentProposalAdapter(pattern, new TextContentAdapter());

    pattern.addModifyListener(new ModifyListener() {

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

    });

    pattern.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent event) {
            if (event.keyCode == SWT.ARROW_DOWN) {
                tableViewer.scrollDown(0, 1);
                tableViewer.getTable().setFocus();
            } else if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                addToSuggestionsAndHistory(pattern.getText());
                updateInput();
            }

        }
    });

    FormData formData = (FormData) pattern.getLayoutData();
    formData.width = patternVerticalLayoutWidth;

    searchButton = new Button(c1, SWT.PUSH);
    searchButton.setText("&Go to Element");
    searchButton.setLayoutData(new GridData());
    searchButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            initSearchInput();
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            ElementTableItem selectedElement = (ElementTableItem) selection.getFirstElement();

            if (null != selectedElement)
                selectAndFocusElement(selectedElement);
        }
    });

    int heightAll = fTypeMethodsSplitter.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    int heightSearchButton = searchButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    int buttonMargin = ((GridLayout) c1.getLayout()).marginHeight;
    int spacing = ((GridLayout) c1.getLayout()).verticalSpacing;
    verticalSearchInput = (int) (heightSearchButton + 2 * buttonMargin + spacing);

    int verticalSearchInputRatio = (verticalSearchInput * 100) / heightAll;
    fTypeMethodsSplitter.setWeights(new int[] { verticalSearchInputRatio, 100 - verticalSearchInputRatio });

    tableViewer.setSorter(new SearchTableSorter(SearchTableSorter.COLUMN_0));
    items.setLinesVisible(true);
    items.setHeaderVisible(true);

    // 1st column
    TableColumn column = new TableColumn(items, SWT.CENTER, 0);
    column.setText("Name");
    column.setWidth(200);
    column.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateSorter(SearchTableSorter.COLUMN_0, 0);
        }
    });

    // 2nd column
    column = new TableColumn(items, SWT.LEFT, 1);
    column.setText("ID");
    column.setWidth(180);
    column.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateSorter(SearchTableSorter.COLUMN_1, 1);
        }
    });

    // 3rd column
    column = new TableColumn(items, SWT.LEFT, 2);
    column.setText("Info");
    column.setWidth(100);
    column.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateSorter(SearchTableSorter.COLUMN_2, 2);
        }
    });

    // 3rd column
    column = new TableColumn(items, SWT.LEFT, 3);
    column.setText("Resource path");
    column.setWidth(200);
    column.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateSorter(SearchTableSorter.COLUMN_3, 3);
        }
    });

    // 4th column
    column = new TableColumn(items, SWT.LEFT, 4);
    column.setText("Special editing");
    column.setWidth(100);
    column.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateSorter(SearchTableSorter.COLUMN_4, 4);
        }
    });
    items.setSortColumn(items.getColumn(0));
    items.setSortDirection(SWT.UP);
    // 5th column
    /*
     * column = new TableColumn(items, SWT.LEFT, );
     * column.setText("Skinned"); column.setWidth(60);
     * column.addSelectionListener(new SelectionAdapter() { public void
     * widgetSelected(SelectionEvent e) { tableViewer.setSorter(new
     * SearchTableSorter( SearchTableSorter.SKINNED)); } });
     */

    tableViewer.setLabelProvider(new SearchDataLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider() {
        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            super.inputChanged(viewer, oldInput, newInput);
        }

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof IDGroupContainer) {
                IDGroupContainer gc = (IDGroupContainer) inputElement;
                ArrayList<ElementTableItem> allAllowedItems = gc.getAllAllowedItems();
                return allAllowedItems.toArray();
            }
            return super.getElements(inputElement);
        }

        @Override
        public void dispose() {
            super.dispose();
        }

    });

    tableViewer.setInput(container);

    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
            if (previousSelection == null
                    || selection.getFirstElement() != previousSelection.getFirstElement()) {
                previousSelection = selection;
            }
            // TableViewer viewer = (TableViewer)source;
        }

    });

    if (tableViewer.getElementAt(0) != null) {
        tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0)));
    }

    tableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ElementTableItem selectedElement = (ElementTableItem) selection.getFirstElement();

            if (null != selectedElement)
                selectAndFocusElement(selectedElement);
        }

    });
}

From source file:org.apache.ivyde.internal.eclipse.ui.IvyFilePathText.java

License:Apache License

protected Text createText(Composite parent) {
    errorDecoration = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);

    ivyFilePathTextDeco = new DecoratedField(this, SWT.LEFT | SWT.TOP, new IControlCreator() {
        public Control createControl(Composite parent, int style) {
            return new Text(parent, SWT.SINGLE | SWT.BORDER);
        }//from w  w w.  j a va2 s. c  om
    });
    ivyFilePathTextDeco.addFieldDecoration(errorDecoration, SWT.TOP | SWT.LEFT, false);
    ivyFilePathTextDeco.hideDecoration(errorDecoration);

    ivyFilePathText = (Text) ivyFilePathTextDeco.getControl();
    ivyFilePathTextDeco.getLayoutControl()
            .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

    return ivyFilePathText;
}

From source file:org.apache.ivyde.internal.eclipse.ui.SettingsSetupEditor.java

License:Apache License

public SettingsSetupEditor(Composite parent, int style, IProject project) {
    super(parent, style);

    GridLayout layout = new GridLayout();
    setLayout(layout);/*www. j  ava 2  s.  c  o  m*/

    loadOnDemandButton = new Button(this, SWT.CHECK);
    loadOnDemandButton.setText("reload the settings only on demand");
    loadOnDemandButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    settingsEditor = new PathEditor(this, SWT.NONE, "Ivy settings path:", project, "*.xml") {

        protected Text createText(Composite parent) {
            errorDecoration = FieldDecorationRegistry.getDefault()
                    .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);

            settingsTextDeco = new DecoratedField(parent, SWT.LEFT | SWT.TOP, new IControlCreator() {
                public Control createControl(Composite p, int s) {
                    return new Text(p, SWT.SINGLE | SWT.BORDER);
                }
            });
            settingsTextDeco.addFieldDecoration(errorDecoration, SWT.TOP | SWT.LEFT, false);
            // settingsTextDeco.setMarginWidth(2);
            settingsTextDeco.hideDecoration(errorDecoration);
            // this doesn't work well: we want the decoration image to be clickable, but it
            // actually
            // hides the clickable area
            // settingsTextDeco.getLayoutControl().addMouseListener(new MouseAdapter() {
            // public void mouseDoubleClick(MouseEvent e) {
            // super.mouseDoubleClick(e);
            // }
            // public void mouseDown(MouseEvent e) {
            // if (settingsError != null) {
            // settingsError.show(IStatus.ERROR, "IvyDE configuration problem", null);
            // }
            // }
            // });

            Text settingsText = (Text) settingsTextDeco.getControl();
            settingsText.setToolTipText(TOOLTIP_SETTINGS_PATH);
            settingsTextDeco.getLayoutControl()
                    .setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));

            return settingsText;
        }

        protected boolean addButtons(Composite buttons) {
            defaultButton = new Button(buttons, SWT.NONE);
            defaultButton.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, false));
            defaultButton.setText("Default");
            defaultButton.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    getText().setText("");
                }
            });
            return true;
        }

        protected void setFile(String f) {
            try {
                getText().setText(new File(f).toURI().toURL().toExternalForm());
                textUpdated();
            } catch (MalformedURLException ex) {
                // this cannot happen
                IvyPlugin.logError("The file got from the file browser has not a valid URL", ex);
            }
        }

        protected void textUpdated() {
            settingsUpdated();
        }
    };
    settingsEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    ivyUserDirEditor = new PathEditor(this, SWT.NONE, "Ivy user dir:", project, null) {
        protected void textUpdated() {
            settingsUpdated();
        }
    };
    ivyUserDirEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    propFilesEditor = new FileListEditor(this, SWT.NONE, "Property files:", "Property file:", project,
            "*.properties") {
        protected void fileListUpdated() {
            settingsUpdated();
        }
    };
    propFilesEditor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
}

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;//  ww w .j ava 2s  . co  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;//from  ww  w .jav  a2  s.c om
    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;/* w w  w . j a  v a 2s .c o  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 ww  . j  a  v a 2s . 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 w ww . jav  a 2 s.c  om*/

    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.RouteComponentController.java

License:Open Source License

@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, EParameterName.ROUTE_COMPONENT_TYPE.getDisplayName(),
                    SWT.None);//from   w ww  . j a v a2 s  . c  o  m
        }

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

    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}

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;/* www. j a  va  2  s .  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;
}