Search in sources :

Example 1 with IBeanPropertyAccessors

use of org.talend.commons.utils.data.bean.IBeanPropertyAccessors in project tdi-studio-se by Talend.

the class HL7MetadataEmfTableEditorView method getDbColumnNameAccessor.

@Override
protected IBeanPropertyAccessors<MetadataColumn, String> getDbColumnNameAccessor() {
    return new IBeanPropertyAccessors<MetadataColumn, String>() {

        public String get(MetadataColumn bean) {
            return bean.getOriginalField();
        }

        public void set(MetadataColumn bean, String value) {
            bean.setOriginalField(value);
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                linker.getManager().updateRelationMapping(key, bean, false);
            // if (columns.indexOf(bean) > 0) {
            // columns.get(columns.indexOf(bean)).setOriginalField(value);
            // }
            }
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with IBeanPropertyAccessors

use of org.talend.commons.utils.data.bean.IBeanPropertyAccessors in project tdi-studio-se by Talend.

the class OutputDataMapTableView method getMapSettingValueAccess.

@Override
protected IBeanPropertyAccessors<GlobalMapEntry, Object> getMapSettingValueAccess(final CellEditor cellEditor) {
    return new IBeanPropertyAccessors<GlobalMapEntry, Object>() {

        public Object get(GlobalMapEntry bean) {
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (cellEditor instanceof ComboBoxCellEditor) {
                ComboBoxCellEditor functComboBox = (ComboBoxCellEditor) cellEditor;
                functComboBox.setItems(new String[] { "true", "false" });
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    functComboBox.setItems(new String[] { BUILT_IN, REPOSITORY });
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                }
            } else if (cellEditor instanceof CustomDialogCellEditor) {
                CustomDialogCellEditor customDialogCellEditor = (CustomDialogCellEditor) cellEditor;
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_TYPE);
                    enableDiaplayViewer(outputTable.isRepository());
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                } else if (SCHEMA_ID.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_ID);
                    return getSchemaDisplayName(outputTable.getId());
                }
            }
            return "";
        }

        public void set(GlobalMapEntry bean, Object value) {
            if (value == null) {
                return;
            }
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (OUTPUT_REJECT.equals(bean.getName())) {
                outputTable.setReject(Boolean.valueOf(value.toString()));
            } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                outputTable.setRejectInnerJoin(Boolean.valueOf(value.toString()));
            } else if (SCHEMA_TYPE.equals(bean.getName())) {
                outputTable.setRepository(REPOSITORY.equals(value));
                showSchemaIDSetting(REPOSITORY.equals(value));
                enableDiaplayViewer(REPOSITORY.equals(value));
            } else if (SCHEMA_ID.equals(bean.getName())) {
                outputTable.setId(String.valueOf(value));
            }
            refreshCondensedImage(outputTable, bean.getName());
        }
    };
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 3 with IBeanPropertyAccessors

use of org.talend.commons.utils.data.bean.IBeanPropertyAccessors in project tdi-studio-se by Talend.

the class RepositoryWebService method ctrate.

public void ctrate() {
    wsdlComposite = new Composite(uiParent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 20;
    layout.marginHeight = 20;
    wsdlComposite.setLayout(layout);
    wsdlComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    // WSDL URL
    Composite wsdlUrlcomposite = new Composite(wsdlComposite, SWT.NONE);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalIndent = 2;
    layoutData.verticalSpan = 1;
    wsdlUrlcomposite.setLayoutData(layoutData);
    layout = new GridLayout(4, false);
    wsdlUrlcomposite.setLayout(layout);
    wsdlField = new LabelledFileField(wsdlUrlcomposite, ExternalWebServiceUIProperties.FILE_LABEL, ExternalWebServiceUIProperties.FILE_EXTENSIONS, 1, SWT.BORDER) {

        @Override
        protected void setFileFieldValue(String result) {
            if (result != null) {
                getTextControl().setText(TalendTextUtils.addQuotes(PathUtils.getPortablePath(result)));
                getDataFromNet();
                isFirst = false;
            }
        }
    };
    wsdlField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            // TODO Auto-generated method stub
            URLValue = wsdlField.getText();
            connection.setWSDL(URLValue);
        }
    });
    // add a listener for ctrl+space.
    TalendProposalUtils.installOn(wsdlField.getTextControl(), connector.getProcess(), connector);
    //$NON-NLS-1$
    String wsdlUrl = (String) connector.getElementParameter("ENDPOINT").getValue();
    if (wsdlUrl != null) {
        wsdlField.setText(wsdlUrl);
    }
    refreshbut = new Button(wsdlUrlcomposite, SWT.PUSH | SWT.CENTER);
    refreshbut.setImage(ImageProvider.getImage(EImage.REFRESH_ICON));
    GridData butData = new GridData();
    butData.verticalSpan = 1;
    refreshbut.setLayoutData(butData);
    // add port name UI
    Composite wsdlPortcomposite = new Composite(wsdlComposite, SWT.NONE);
    GridData portlayoutData = new GridData(GridData.FILL_HORIZONTAL);
    portlayoutData.verticalIndent = 2;
    portlayoutData.verticalSpan = 3;
    wsdlPortcomposite.setLayoutData(portlayoutData);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 1;
    wsdlPortcomposite.setLayout(layout);
    portNameLabel = new Label(wsdlPortcomposite, SWT.NONE);
    //$NON-NLS-1$
    portNameLabel.setText(Messages.getString("WebServiceUI.Port"));
    GridData portLabelGridData = new GridData();
    portLabelGridData.verticalAlignment = SWT.TOP;
    portNameLabel.setLayoutData(portLabelGridData);
    Composite portTabComposite = new Composite(wsdlPortcomposite, SWT.BORDER);
    portTabComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    portTabComposite.setLayout(new FillLayout());
    //$NON-NLS-1$
    ExtendedTableModel<PortNames> portModel = new ExtendedTableModel<PortNames>("PORTNAMELIST", allPortNames);
    portListTableView = new AbstractDataTableEditorView<PortNames>(portTabComposite, SWT.NONE, portModel, false, true, false) {

        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<PortNames> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setHeaderVisible(false);
            newTableViewerCreator.setVerticalScroll(true);
            newTableViewerCreator.setReadOnly(true);
        }

        @Override
        protected void createColumns(TableViewerCreator<PortNames> tableViewerCreator, Table table) {
            TableViewerCreatorColumn rowColumn = new TableViewerCreatorColumn(tableViewerCreator);
            //$NON-NLS-1$
            rowColumn.setTitle(Messages.getString("WebServiceUI.COLUMN"));
            rowColumn.setBeanPropertyAccessors(new IBeanPropertyAccessors<PortNames, String>() {

                public String get(PortNames bean) {
                    return bean.getPortName();
                }

                public void set(PortNames bean, String value) {
                    bean.setPortName(value);
                }
            });
            rowColumn.setWeight(60);
            rowColumn.setModifiable(true);
            rowColumn.setMinimumWidth(60);
            rowColumn.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
        }
    };
    // WSDL Operation
    Composite wsdlOperationcomposite = new Composite(wsdlComposite, SWT.NONE);
    GridData operationlayoutData = new GridData(GridData.FILL_BOTH);
    operationlayoutData.verticalIndent = 2;
    operationlayoutData.verticalSpan = 5;
    wsdlOperationcomposite.setLayoutData(operationlayoutData);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 3;
    wsdlOperationcomposite.setLayout(layout);
    // wsdlOperationcomposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    operationLabel = new Label(wsdlOperationcomposite, SWT.NONE);
    //$NON-NLS-1$
    operationLabel.setText(Messages.getString("WebServiceUI.Operation"));
    GridData opertionLabelGridData = new GridData();
    opertionLabelGridData.verticalAlignment = SWT.TOP;
    operationLabel.setLayoutData(opertionLabelGridData);
    Composite tabComposite = new Composite(wsdlOperationcomposite, SWT.BORDER);
    GridData tabGridData = new GridData(GridData.FILL_BOTH);
    // tabGridData.verticalSpan = 3;
    tabComposite.setLayoutData(tabGridData);
    tabComposite.setLayout(new FillLayout());
    //$NON-NLS-1$
    ExtendedTableModel<Function> funModel = new ExtendedTableModel<Function>("FUNCTIONLIST", allfunList);
    listTableView = new AbstractDataTableEditorView<Function>(tabComposite, SWT.NONE, funModel, false, true, false) {

        @Override
        protected void setTableViewerCreatorOptions(TableViewerCreator<Function> newTableViewerCreator) {
            super.setTableViewerCreatorOptions(newTableViewerCreator);
            newTableViewerCreator.setHeaderVisible(false);
            newTableViewerCreator.setVerticalScroll(true);
            newTableViewerCreator.setReadOnly(true);
        }

        @Override
        protected void createColumns(TableViewerCreator<Function> tableViewerCreator, Table table) {
            TableViewerCreatorColumn rowColumn = new TableViewerCreatorColumn(tableViewerCreator);
            //$NON-NLS-1$
            rowColumn.setTitle(Messages.getString("WebServiceUI.COLUMN"));
            rowColumn.setBeanPropertyAccessors(new IBeanPropertyAccessors<Function, String>() {

                public String get(Function bean) {
                    return bean.getName();
                }

                public void set(Function bean, String value) {
                    bean.setName(value);
                }
            });
            rowColumn.setWeight(60);
            rowColumn.setModifiable(true);
            rowColumn.setMinimumWidth(60);
            rowColumn.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
        }
    };
    addListenerForWSDLCom();
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) LabelledFileField(org.talend.commons.ui.swt.formtools.LabelledFileField) FillLayout(org.eclipse.swt.layout.FillLayout) PortNames(org.talend.designer.webservice.ws.wsdlinfo.PortNames) Function(org.talend.designer.webservice.ws.wsdlinfo.Function) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 4 with IBeanPropertyAccessors

use of org.talend.commons.utils.data.bean.IBeanPropertyAccessors in project tdi-studio-se by Talend.

the class CheckColumnSelectionListener method widgetSelected.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
     */
@Override
public void widgetSelected(SelectionEvent e) {
    if (tableViewerCreator != null && tableViewerCreator.isReadOnly()) {
        return;
    }
    // TableItem items[] = tableViewerCreator.getTable().getItems();
    // String columnId = tableViewerCreatorColumn.getId();
    // boolean modified = false;
    // for (TableItem tableItem : items) {
    // tableViewerCreator.getCellModifier().modify(tableItem, columnId, checked ? false : true);
    // if (!modified) {
    // modified = true;
    // }
    // }
    // if (modified) {
    // this.param.getValue();
    // if (checked) {
    // checked = false;
    // } else {
    // checked = true;
    // }
    // tableViewerCreatorColumn.getTableColumn().setImage(
    // checked ? ImageProvider.getImage(EImage.CHECKED_ICON) : ImageProvider.getImage(EImage.UNCHECKED_ICON));
    // this.param.setValue(new Boolean(checked));
    // }
    String columnId = tableViewerCreatorColumn.getId();
    TableViewerCreatorColumnNotModifiable column = tableViewerCreator.getColumn(columnId);
    IBeanPropertyAccessors accessor = column.getBeanPropertyAccessors();
    List inputList = tableViewerCreator.getInputList();
    for (int i = 0; i < inputList.size(); i++) {
        if (tableViewerCreator instanceof TableViewerCreator && column instanceof TableViewerCreatorColumn) {
            ((TableViewerCreator) tableViewerCreator).setBeanValue((TableViewerCreatorColumn) column, inputList.get(i), checked ? false : true, true);
        } else {
            accessor.set(inputList.get(i), checked ? false : true);
        }
    }
    if (checked) {
        checked = false;
    } else {
        checked = true;
    }
    tableViewerCreatorColumn.getTableColumn().setImage(checked ? ImageProvider.getImage(EImage.CHECKED_ICON) : ImageProvider.getImage(EImage.UNCHECKED_ICON));
    this.param.setValue(new Boolean(checked));
    tableViewerCreator.refreshTableEditorControls();
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) List(java.util.List) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 5 with IBeanPropertyAccessors

use of org.talend.commons.utils.data.bean.IBeanPropertyAccessors in project tdi-studio-se by Talend.

the class AutoConversionTypesEditorView method configureTypeColumn.

private void configureTypeColumn(TableViewerCreator<AutoConversionType> tableViewerCreator, TableViewerCreatorColumn column) {
    IBeanPropertyAccessors<AutoConversionType, Boolean> nullableAccessors = new IBeanPropertyAccessors<AutoConversionType, Boolean>() {

        @Override
        public Boolean get(AutoConversionType bean) {
            return Boolean.TRUE;
        }

        @Override
        public void set(AutoConversionType bean, Boolean value) {
            return;
        }
    };
    CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors);
    String[] arrayTalendTypes = new String[0];
    try {
        arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
    } catch (NoClassDefFoundError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    } catch (ExceptionInInitializerError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
    CCombo typeCombo = (CCombo) typeComboEditor.getControl();
    typeCombo.setEditable(false);
    column.setCellEditor(typeComboEditor, comboValueAdapter);
}
Also used : AutoConversionType(org.talend.core.model.metadata.types.AutoConversionType) CCombo(org.eclipse.swt.custom.CCombo) JavaTypeComboValueAdapter(org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors)

Aggregations

IBeanPropertyAccessors (org.talend.commons.utils.data.bean.IBeanPropertyAccessors)8 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)5 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)4 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)3 List (java.util.List)2 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 Table (org.eclipse.swt.widgets.Table)2 JavaTypeComboValueAdapter (org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)2 ArrayList (java.util.ArrayList)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 CCombo (org.eclipse.swt.custom.CCombo)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1