Search in sources :

Example 41 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method setInput.

public void setInput(List<ColumnInfo> inputs) {
    table.setRedraw(false);
    for (ColumnInfo row : inputs) {
        final TableItem item = new TableItem(table, SWT.NONE);
        //$NON-NLS-1$
        item.setText(new String[] { row.name, "" });
        IElementParameter param = row.parameter;
        Object defaultValue = param.getValue();
        item.setData(row);
        if (param.getFieldType() == EParameterFieldType.CHECK) {
            // create check box
            createCheckboxEditor(item, 1, (Boolean) defaultValue);
        } else if (param.getFieldType() == EParameterFieldType.TEXT) {
            // create text input
            createTextEditor(item, 1, (String) defaultValue);
        } else if (param.getFieldType() == EParameterFieldType.CLOSED_LIST || param.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST) {
            // create combo
            int selectIndex = 0;
            Object[] values = param.getListItemsValue();
            for (int i = 0; i < values.length; i++) {
                if (values[i].equals(param.getDefaultClosedListValue())) {
                    selectIndex = i;
                    break;
                }
            }
            createComboEditor(item, 1, param.getListItemsDisplayName(), selectIndex);
        }
    }
    table.setRedraw(true);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 42 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.

public void moveScrollBarZoneAtSelectedTableItem(ITableEntry entry) {
    if (entry != null) {
        DataMapTableView dataMapTableView = mapperManager.retrieveIDataMapTableView(entry.getParent());
        Rectangle tableViewBounds = dataMapTableView.getBounds();
        IDataMapTable table = entry.getParent();
        TableItem tableItem = mapperManager.retrieveTableItem(entry);
        if (table != null && tableItem != null) {
            Rectangle tableItemBounds = tableItem.getBounds();
            int selection = tableViewBounds.y + tableItemBounds.y;
            ScrolledComposite scrollComposite = null;
            if (table instanceof InputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewInputs();
            } else if (table instanceof OutputTable) {
                scrollComposite = uiManager.getScrolledCompositeViewOutputs();
            }
            if (scrollComposite != null) {
                setPositionOfVerticalScrollBarZone(scrollComposite, selection);
            }
        }
    }
}
Also used : InputTable(org.talend.designer.dbmap.model.table.InputTable) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 43 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class TabFolderEditors method addListenersToOutputButtons.

/**
     * DOC amaumont Comment method "addListenersToInputButtons".
     */
private void addListenersToOutputButtons() {
    MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
    outputToolBarButtons = toolBar.getButtons();
    beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {

        public void handleEvent(ExtendedButtonEvent event) {
            TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
            if (tableViewerCreator != null) {
                tableViewerCreator.applyActivatedCellEditor();
            }
        }
    };
    for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
        extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
        if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
            removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
        }
    }
    if (removeButton != null) {
        final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
        tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

            public void handle(LineSelectionEvent e) {
                for (TableItem item : tableViewerCreator.getTable().getSelection()) {
                    if (item.getData() instanceof MetadataColumn) {
                        MetadataColumn column = (MetadataColumn) item.getData();
                        removeButton.getButton().setEnabled(!column.isCustom());
                        break;
                    }
                }
            }
        });
    }
    this.addDisposeListener(new DisposeListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
             */
        public void widgetDisposed(DisposeEvent e) {
            for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
                extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
            }
        }
    });
}
Also used : MetadataColumn(org.talend.core.model.metadata.MetadataColumn) DisposeListener(org.eclipse.swt.events.DisposeListener) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) RemovePushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButton) ExtendedPushButton(org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton) TableItem(org.eclipse.swt.widgets.TableItem) MetadataToolbarEditorView(org.talend.core.ui.metadata.editor.MetadataToolbarEditorView) IExtendedButtonListener(org.talend.commons.ui.swt.extended.table.IExtendedButtonListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)

Example 44 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class DragSourceListenerForWebService method dragSetData.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
     */
public void dragSetData(DragSourceEvent event) {
    if (TableEntriesTransfer.getInstance().isSupportedType(event.dataType)) {
        if (draggableControl instanceof Table) {
            Table draggableTable = (Table) draggableControl;
            TableItem selection = draggableTable.getSelection()[0];
            event.data = selection.getData();
        }
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem)

Example 45 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class DropTargetListenerForWebService method drop.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
     */
public void drop(DropTargetEvent event) {
    if (getTransfer().isSupportedType(event.currentDataType)) {
        // boolean canRemove = true;
        // Parameter pa = TableEntriesTransfer.getInstance().getParameter();
        Table draggableTable = (Table) draggableControl;
        Point point = new Point(event.x, event.y);
        int selevIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTable, point);
        if (selevIndex < 0) {
            return;
        }
        TableItem tabitem = TableEntriesTransfer.getInstance().getTableItem();
        if (tabitem == null) {
            return;
        }
        ExtendedTableModel tabelModel = draggableControlView.getExtendedTableModel();
        if (tabelModel.getBeansList().size() == 0 || tabelModel.getBeansList().size() == selevIndex) {
            // }
            return;
        } else if (tabelModel.getBeansList().size() > 0) {
            if (tabelModel.getBeansList().size() < selevIndex) {
                return;
            }
            Object objData = tabelModel.getBeansList().get(selevIndex);
            if (objData instanceof InputMappingData) {
                InputMappingData inData = (InputMappingData) objData;
                IMetadataColumn inputColumn = null;
                if (tabitem.getData() instanceof IMetadataColumn) {
                    inputColumn = (IMetadataColumn) tabitem.getData();
                    List<IMetadataColumn> columnList = inData.getMetadataColumnList();
                    if (inData.getInputColumnValue() == null || "".equals(inData.getInputColumnValue())) {
                        inData.setInputColumnValue(connector.initInRoWName() + "." + inputColumn.getLabel());
                        columnList.add(inputColumn);
                    } else {
                        inData.setInputColumnValue(inData.getInputColumnValue() + " " + connector.initInRoWName() + "." + inputColumn.getLabel());
                        columnList.add(inputColumn);
                    }
                }
                tabelModel.remove(selevIndex);
                tabelModel.add(inData, selevIndex);
            } else if (objData instanceof OutPutMappingData) {
                OutPutMappingData outData = (OutPutMappingData) objData;
                if (tabitem.getData() instanceof ParameterInfo) {
                    ParameterInfo para = (ParameterInfo) tabitem.getData();
                    if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
                        if (para.getParent() != null) {
                            String name = new ParameterInfoUtil().getParentName(para);
                            outData.setParameterName(name);
                        } else {
                            outData.setParameterName(para.getName());
                        }
                    } else {
                        outData.setParameterName(outData.getParameterName() + " " + para.getName());
                    }
                    outData.getParameterList().add(para);
                // outData.setParameter(para);
                } else if (tabitem.getData() instanceof OutPutMappingData) {
                    if (((OutPutMappingData) tabitem.getData()).getParameter() instanceof ParameterInfo) {
                        ParameterInfo para = ((OutPutMappingData) tabitem.getData()).getParameter();
                        if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
                            if (para.getParent() != null) {
                                String name = "";
                                if (((OutPutMappingData) tabitem.getData()).getParameterName() != null) {
                                    name = ((OutPutMappingData) tabitem.getData()).getParameterName();
                                } else {
                                    name = new ParameterInfoUtil().getParentName(para);
                                }
                                outData.setParameterName(name);
                            } else {
                                outData.setParameterName(para.getName());
                            }
                        } else {
                            outData.setParameterName(outData.getParameterName() + " " + para.getName());
                        }
                        outData.getParameterList().add(para);
                    // outData.setParameter(para);
                    }
                }
                tabelModel.remove(selevIndex);
                tabelModel.add(outData, selevIndex);
            }
        }
        TableItem[] items = draggableTable.getSelection();
        if (items.length <= 0) {
            return;
        }
        TableItem itemTarget = items[0];
        itemTarget.setChecked(true);
        createLinks(itemTarget, tabitem, tabelModel.getName());
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) InputMappingData(org.talend.designer.webservice.data.InputMappingData) OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Point(org.eclipse.swt.graphics.Point) List(java.util.List) ParameterInfoUtil(org.talend.designer.webservice.ui.ParameterInfoUtil) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)475 Point (org.eclipse.swt.graphics.Point)136 Table (org.eclipse.swt.widgets.Table)125 TableColumn (org.eclipse.swt.widgets.TableColumn)79 SelectionEvent (org.eclipse.swt.events.SelectionEvent)73 GridData (org.eclipse.swt.layout.GridData)70 GridLayout (org.eclipse.swt.layout.GridLayout)61 Composite (org.eclipse.swt.widgets.Composite)56 ArrayList (java.util.ArrayList)55 Image (org.eclipse.swt.graphics.Image)55 Button (org.eclipse.swt.widgets.Button)53 Rectangle (org.eclipse.swt.graphics.Rectangle)52 Label (org.eclipse.swt.widgets.Label)51 Shell (org.eclipse.swt.widgets.Shell)49 Color (org.eclipse.swt.graphics.Color)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Text (org.eclipse.swt.widgets.Text)42 FillLayout (org.eclipse.swt.layout.FillLayout)40 Test (org.junit.Test)39 SelectionListener (org.eclipse.swt.events.SelectionListener)36