Search in sources :

Example 16 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class GroupController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, final IElementParameter param) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createGroup(parent, param.getDisplayName());
        }
    });
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 17 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class GroupController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            widgetFactory = getWidgetFactory();
            //$NON-NLS-1$
            return widgetFactory.createGroup(parent, param.getGroupDisplayName() == null ? "" : param.getGroupDisplayName());
        }
    });
    Control groupLayout = dField.getLayoutControl();
    groupLayout.setBackground(subComposite.getBackground());
    FormData data = new FormData();
    data.top = new FormAttachment(0, top);
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.right = new FormAttachment(MAX_PERCENT, 0);
    groupLayout.setLayoutData(data);
    Group group = (Group) dField.getControl();
    group.setLayout(new FormLayout());
    // group.setEnabled(!param.isReadOnly());
    group.setBackground(subComposite.getBackground());
    hashCurControls.put(param.getGroup(), group);
    return group;
}
Also used : FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Group(org.eclipse.swt.widgets.Group) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 18 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class DbTableController method addOpenSqlBulderButton.

/**
     * qzhang Comment method "addOpenSqlBulderButton".
     * 
     * @param subComposite
     * @param param
     * @param top
     * @param numInRow
     * @param nbInRow
     * @return
     */
private Control addOpenSqlBulderButton(Composite subComposite, IElementParameter param, int top, int numInRow, int nbInRow) {
    final DecoratedField dField1 = new DecoratedField(subComposite, SWT.PUSH, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new Button(parent, style);
        }
    });
    Control buttonControl = dField1.getLayoutControl();
    Button openSQLEditorButton = (Button) dField1.getControl();
    openSQLEditorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    openSQLEditorButton.setImage(ImageProvider.getImage(ImageProvider.getImageDesc(EImage.READ_ICON)));
    buttonControl.setBackground(subComposite.getBackground());
    openSQLEditorButton.setEnabled(!param.isReadOnly());
    openSQLEditorButton.setData(NAME, SQLEDITOR);
    openSQLEditorButton.setData(PARAMETER_NAME, param.getName());
    if (param.getFieldType() == EParameterFieldType.DBTABLE) {
        openSQLEditorButton.setEnabled(ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
    }
    openSQLEditorButton.addSelectionListener(openSQLListener);
    return buttonControl;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point)

Example 19 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class SqlMemoController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
    final DecoratedField dField1 = new DecoratedField(subComposite, SWT.PUSH, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new Button(parent, style);
        }
    });
    Control buttonControl = dField1.getLayoutControl();
    openSQLEditorButton = (Button) dField1.getControl();
    openSQLEditorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    openSQLEditorButton.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    buttonControl.setBackground(subComposite.getBackground());
    openSQLEditorButton.setEnabled(true);
    openSQLEditorButton.setData(NAME, SQLEDITOR);
    openSQLEditorButton.setData(PARAMETER_NAME, param.getName());
    openSQLEditorButton.setEnabled(!param.isReadOnly());
    openSQLEditorButton.addSelectionListener(listenerSelection);
    if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
        openSQLEditorButton.setEnabled(ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
    }
    // Added by Marvin Wang on Dec.13, 2012 for bug TDI-7559.
    //$NON-NLS-1$
    IElementParameter typePara = elem.getElementParameter("TYPE");
    if (typePara != null && "Hive".equalsIgnoreCase((String) typePara.getValue())) {
        //$NON-NLS-1$
        openSQLEditorButton.setVisible(false);
    }
    if (typePara != null && "Impala".equalsIgnoreCase((String) typePara.getValue())) {
        //$NON-NLS-1$
        openSQLEditorButton.setVisible(false);
    }
    FormData data1 = new FormData();
    data1.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
    data1.left = new FormAttachment(100, -(ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH));
    data1.top = new FormAttachment(0, top);
    buttonControl.setLayoutData(data1);
    int nbLines = param.getNbLines();
    IControlCreator txtCtrl = new IControlCreator() {

        @Override
        public Control createControl(final Composite parent, final int style) {
            return createColorStyledText(parent, style);
        }
    };
    DecoratedField dField = null;
    if (param.getNbLines() != 1) {
        dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
    } else {
        dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
    }
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    queryText = (ColorStyledText) dField.getControl();
    queryText.setData(PARAMETER_NAME, param.getName());
    editionControlHelper.register(param.getName(), queryText);
    FormData d = (FormData) queryText.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
        nbLines += this.getAdditionalHeightSize() / queryText.getLineHeight();
    }
    d.height = queryText.getLineHeight() * nbLines;
    FormData data;
    queryText.getParent().setSize(subComposite.getSize().x, queryText.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(queryText instanceof ColorStyledText)) {
        queryText.setEnabled(!param.isReadOnly());
    } else {
        queryText.setEditable(!param.isReadOnly());
    }
    if (elem instanceof Node) {
        queryText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    queryText.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (switchParam != null) {
                switchParam.setValue(Boolean.FALSE);
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }
    });
    if (param.isReadOnly() && param.isRepositoryValueUsed()) {
        cLayout.addMouseListener(listenerClick);
    }
    addDragAndDropTarget(queryText);
    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.right = new FormAttachment(buttonControl, -5, SWT.LEFT);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), queryText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) IElementParameter(org.talend.core.model.process.IElementParameter) KeyListener(org.eclipse.swt.events.KeyListener) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 20 with IControlCreator

use of org.eclipse.jface.fieldassist.IControlCreator in project tdi-studio-se by Talend.

the class AS400CheckController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, param.getDisplayName(), SWT.CHECK);
        }
    });
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("CheckController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    cLayout.setBackground(subComposite.getBackground());
    Button checkBtn = (Button) dField.getControl();
    FormData data = new FormData();
    data.top = new FormAttachment(0, top);
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    cLayout.setLayoutData(data);
    hashCurControls.put(param.getName(), checkBtn);
    checkBtn.setEnabled(!param.isReadOnly());
    String propertyType = (String) elem.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
    if (propertyType.equals(EmfComponent.REPOSITORY)) {
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        List<ConnectionItem> metadataConnectionsItem = null;
        try {
            metadataConnectionsItem = factory.getMetadataConnectionsItem();
        } catch (PersistenceException e) {
            throw new RuntimeException(e);
        }
        if (metadataConnectionsItem != null) {
            for (ConnectionItem connectionItem : metadataConnectionsItem) {
                //$NON-NLS-1$
                String value = connectionItem.getProperty().getId() + "";
                if (value.equals(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()))) {
                    boolean b = getConnection(connectionItem).isStandardSQL();
                    checkBtn.setSelection(b);
                }
            }
        }
    } else {
        boolean b = CoreUIPlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.AS400_SQL_SEG);
        checkBtn.setSelection(b);
    }
    if (elem instanceof Node) {
        checkBtn.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    Point initialSize = checkBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) PersistenceException(org.talend.commons.exception.PersistenceException) FormAttachment(org.eclipse.swt.layout.FormAttachment) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)21 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)21 Composite (org.eclipse.swt.widgets.Composite)21 Point (org.eclipse.swt.graphics.Point)20 Control (org.eclipse.swt.widgets.Control)18 FormData (org.eclipse.swt.layout.FormData)12 FormAttachment (org.eclipse.swt.layout.FormAttachment)9 Button (org.eclipse.swt.widgets.Button)9 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)7 CLabel (org.eclipse.swt.custom.CLabel)6 Node (org.talend.designer.core.ui.editor.nodes.Node)6 GC (org.eclipse.swt.graphics.GC)5 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 StyledText (org.eclipse.swt.custom.StyledText)2 Font (org.eclipse.swt.graphics.Font)2 FontData (org.eclipse.swt.graphics.FontData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Display (org.eclipse.swt.widgets.Display)2 Label (org.eclipse.swt.widgets.Label)2