Search in sources :

Example 6 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 7 with IBeanPropertyAccessors

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

the class SetLoopFunctionDialog method createDialogArea.

public Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(data);
    tableViwer = new AbstractDataTableEditorView<TreeSchemaTableEntry>(composite, SWT.NONE, tableModel, false, true, false) {

        @Override
        protected void createColumns(TableViewerCreator<TreeSchemaTableEntry> tableViewerCreator, Table table) {
            TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
            column.setTitle("Sequence");
            column.setWeight(40);
            column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeSchemaTableEntry, Object>() {

                public Object get(TreeSchemaTableEntry bean) {
                    int index = getExtendedTableModel().getBeansList().indexOf(bean);
                    return getExtendedTableModel().getBeansList().indexOf(bean);
                }

                public void set(TreeSchemaTableEntry bean, Object value) {
                // do nothing
                }
            });
            column = new TableViewerCreatorColumn(tableViewerCreator);
            column.setTitle("Xpath");
            column.setWeight(60);
            String[] items = new String[inputLoops.size()];
            for (int i = 0; i < inputLoops.size(); i++) {
                items[i] = inputLoops.get(i).getXpath();
            }
            CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor("String");
            ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), items, SWT.READ_ONLY);
            column.setModifiable(true);
            column.setCellEditor(cellEditor, comboValueAdapter);
            column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeSchemaTableEntry, Object>() {

                public Object get(TreeSchemaTableEntry bean) {
                    return bean.getXPath();
                }

                public void set(TreeSchemaTableEntry bean, Object value) {
                    for (TreeNode loopNode : inputLoops) {
                        if (loopNode.getXpath().equals(value)) {
                            bean.setTreeNode(loopNode);
                        }
                    }
                }
            });
        }

        @Override
        protected ExtendedToolbarView initToolBar() {
            ExtendedToolbarView toolbarView = new ExtendedToolbarView(getMainComposite(), SWT.NONE, this.getExtendedTableViewer()) {

                @Override
                protected CopyPushButton createCopyPushButton() {
                    return null;
                }

                @Override
                protected AddPushButton createAddPushButton() {
                    return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {

                        @Override
                        public boolean getEnabledState() {
                            return super.getEnabledState();
                        }

                        @Override
                        protected Object getObjectToAdd() {
                            TreeNode loopNodetoAdd = null;
                            for (TreeNode loopNode : inputLoops) {
                                boolean found = false;
                                for (TreeSchemaTableEntry extendedModel : getExtendedTableModel().getBeansList()) {
                                    if (loopNode.getXpath().equals(extendedModel.getXPath())) {
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found) {
                                    loopNodetoAdd = loopNode;
                                    break;
                                }
                            }
                            if (loopNodetoAdd == null && !inputLoops.isEmpty()) {
                                loopNodetoAdd = inputLoops.get(0);
                            }
                            if (loopNodetoAdd != null) {
                                TreeSchemaTableEntry entry = new TreeSchemaTableEntry(loopNodetoAdd);
                                return entry;
                            }
                            return null;
                        }
                    };
                }
            };
            return super.initToolBar();
        }
    };
    tableViwer.setGridDataSize(400, 120);
    statusLabel = new Label(composite, SWT.NONE);
    statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tableModel.addAfterOperationListListener(new IListenableListListener<TreeSchemaTableEntry>() {

        public void handleEvent(ListenableListEvent<TreeSchemaTableEntry> event) {
            updateStatus(true);
        }
    });
    tableModel.setModifiedBeanListenable(tableViwer.getTableViewerCreator());
    tableModel.addModifiedBeanListener(new IModifiedBeanListener<TreeSchemaTableEntry>() {

        public void handleEvent(ModifiedBeanEvent<TreeSchemaTableEntry> event) {
            updateStatus(false);
        }
    });
    return composite;
}
Also used : AddPushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButton) Table(org.eclipse.swt.widgets.Table) AddPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable) InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) AddPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) GridLayout(org.eclipse.swt.layout.GridLayout) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) GridData(org.eclipse.swt.layout.GridData) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) CopyPushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.CopyPushButton) TreeSchemaTableEntry(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEntry) ExtendedToolbarView(org.talend.commons.ui.swt.advanced.dataeditor.ExtendedToolbarView)

Example 8 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