Search in sources :

Example 31 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project tdi-studio-se by Talend.

the class UIManager method modifySelectionChangedListener.

private void modifySelectionChangedListener(final Zone currentZone, final MetadataTableEditorView metadataTableEditorViewFinal, final TableViewerCreator metadataTVCreator, final MetadataTableEditor metadataTableEditor, final DataMapTableView dataMapTableView, DataMapTableView previousSelectedTableView) {
    final TableViewer tableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
    IModifiedBeanListener<IMetadataColumn> modifiedBeanListener = new IModifiedBeanListener<IMetadataColumn>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
            if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId()) && !event.previousValue.equals(event.newValue)) {
                IMetadataColumn modifiedObject = event.bean;
                if (modifiedObject != null) {
                    TableEntryLocation tableEntryLocation = new TableEntryLocation(dataMapTableView.getDataMapTable().getName(), (String) event.previousValue);
                    final ITableEntry dataMapTableEntry = mapperManager.retrieveTableEntry(tableEntryLocation);
                    processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry, false);
                }
                // dataMapTableViewer.refresh(event.bean, true);
                tableViewer.refresh(true);
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_KEY.equals(event.column.getId())) {
                tableViewer.refresh(true);
                IColumnEntry entry = dataMapTableView.getDataMapTable().getColumnEntries().get(event.index);
                parseExpression(entry.getExpression(), entry, false, false, false);
            } else if (AbstractMetadataTableEditorView.ID_COLUMN_TYPE.equals(event.column.getId()) || AbstractMetadataTableEditorView.ID_COLUMN_NULLABLE.equals(event.column.getId())) {
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        }
    };
    ILineSelectionListener metadataEditorViewerSelectionChangedListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (metadataTableEditorViewFinal.getTableViewerCreator() == e.source) {
                if (metadataTableEditorViewFinal.getExtendedTableViewer().isExecuteSelectionEvent()) {
                    mapperManager.getUiManager().selectLinkedTableEntries(metadataTableEditor.getMetadataTable(), metadataTVCreator.getTable().getSelectionIndices());
                }
            } else {
            // if (dataMapTableView.getExtendedTableViewerForColumns().isExecuteSelectionEvent()) {
            // int[] selectionIndices =
            // dataMapTableView.getTableViewerCreatorForColumns().getTable().getSelectionIndices();
            // mapperManager.getUiManager().selectLinkedMetadataEditorEntries(dataMapTableView,
            // selectionIndices);
            // }
            }
        }
    };
    // ISelectionChangedListener previousSelectionChangedListener = null;
    ILineSelectionListener previousSelectionChangedListener = null;
    IModifiedBeanListener<IMetadataColumn> previousModifiedBeanListener = null;
    if (currentZone == Zone.INPUTS) {
        previousSelectionChangedListener = inputsSelectionChangedListener;
        previousModifiedBeanListener = inputModifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        previousSelectionChangedListener = outputsSelectionChangedListener;
        previousModifiedBeanListener = outputModifiedBeanListener;
    }
    if (previousSelectionChangedListener != null) {
        // metadataTVCreator.removeSelectionChangedListener(previousSelectionChangedListener);
        metadataTVCreator.getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        if (previousSelectedTableView != null) {
            previousSelectedTableView.getTableViewerCreatorForColumns().getSelectionHelper().removeAfterSelectionListener(previousSelectionChangedListener);
        }
    }
    if (previousModifiedBeanListener != null) {
        metadataTableEditor.removeModifiedBeanListener(previousModifiedBeanListener);
    }
    if (currentZone == Zone.INPUTS) {
        inputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        inputModifiedBeanListener = modifiedBeanListener;
    } else if (currentZone == Zone.OUTPUTS) {
        outputsSelectionChangedListener = metadataEditorViewerSelectionChangedListener;
        outputModifiedBeanListener = modifiedBeanListener;
    }
    // metadataTVCreator.addSelectionChangedListener(metadataEditorViewerSelectionChangedListener);
    metadataTVCreator.getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    dataMapTableView.getTableViewerCreatorForColumns().getSelectionHelper().addAfterSelectionListener(metadataEditorViewerSelectionChangedListener);
    metadataTableEditor.addModifiedBeanListener(modifiedBeanListener);
    if (this.commonMetadataDisposeListener == null) {
        this.commonMetadataDisposeListener = new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                if (inputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.INPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(inputsSelectionChangedListener);
                }
                if (outputsSelectionChangedListener != null) {
                    getMetadataEditorView(Zone.OUTPUTS).getTableViewerCreator().getSelectionHelper().removeAfterSelectionListener(outputsSelectionChangedListener);
                }
                if (inputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.INPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(inputModifiedBeanListener);
                    }
                }
                if (outputModifiedBeanListener != null) {
                    MetadataTableEditor metadataTableEditor = getMetadataEditorView(Zone.OUTPUTS).getMetadataTableEditor();
                    if (metadataTableEditor != null) {
                        metadataTableEditor.removeModifiedBeanListener(outputModifiedBeanListener);
                    }
                }
            }
        };
        metadataTVCreator.getTable().addDisposeListener(this.commonMetadataDisposeListener);
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableEntryLocation(org.talend.designer.dbmap.model.tableentry.TableEntryLocation) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 32 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project tdi-studio-se by Talend.

the class PatternCellEditor method openDialogBox.

//TODO: when no one use repository, need to set back to "Built-in"
@Override
protected Object openDialogBox(Control cellEditorWindow) {
    ITDQPatternService service = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
        service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
    }
    if (service != null) {
        IElementParameter typeParam = node.getElementParameter("TYPE");
        if (typeParam == null && node.getIncomingConnections().size() > 0) {
            IConnection iConnection = node.getIncomingConnections().get(0);
            typeParam = iConnection.getElementParameter("TYPE");
        }
        String[] patternInfo = service.selectPattern(cellEditorWindow.getShell(), typeParam);
        //modify the same row's pattern info: id, name, regex
        if (patternInfo != null) {
            int index = 0;
            TableViewer tableViewer = getTableViewer();
            if (tableViewer != null) {
                index = tableViewer.getTable().getSelectionIndex();
            }
            updatePatterInfoOnRow(index, patternInfo);
            // if any row select a pattern, set the node's PROPERTY = REPOSITORY
            IElementParameter property = node.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
            if (property != null) {
                IElementParameter repositoryParam = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                if (StringUtils.isNotBlank(patternInfo[0])) {
                    property.setValue(EmfComponent.REPOSITORY);
                    if (repositoryParam != null) {
                        repositoryParam.setValue(patternInfo[0]);
                    }
                }
            }
        }
        return patternInfo[1];
    }
    return null;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) IConnection(org.talend.core.model.process.IConnection) ITDQPatternService(org.talend.core.ITDQPatternService) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer)

Example 33 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project tdi-studio-se by Talend.

the class JobHierarchyViewPart method createMethodViewerControl.

private Control createMethodViewerControl(Composite parent) {
    dependencyViewer = new TableViewer(parent);
    DependencyViewerProvider provider = new DependencyViewerProvider(this.fHierarchyLifeCycle);
    dependencyViewer.setContentProvider(provider);
    dependencyViewer.setLabelProvider(provider);
    Control control = dependencyViewer.getTable();
    //$NON-NLS-1$
    String popupId = "DependencyViewer_ContextMenu";
    MenuManager menuMgr = new MenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menu) {
            fillDependencyViewerContextMenu(menu);
        }
    });
    Menu menu = menuMgr.createContextMenu(control);
    control.setMenu(menu);
    getSite().registerContextMenu(popupId, menuMgr, dependencyViewer);
    return control;
}
Also used : Control(org.eclipse.swt.widgets.Control) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 34 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project tdi-studio-se by Talend.

the class DataMapTableView method addTablesListeners.

/**
     * DOC amaumont Comment method "addTableForColumnsListeners".
     */
private void addTablesListeners() {
    tableViewerCreatorForColumns.addCellValueModifiedListener(new ITableCellValueModifiedListener() {

        @Override
        public void cellValueModified(TableCellValueModifiedEvent e) {
            unselectAllEntriesIfErrorDetected(e);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

        @Override
        public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
    tableViewerForEntries.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            int[] selectionIndices = tableViewerForEntries.getTable().getSelectionIndices();
            if (selectionIndices.length > 0) {
                selectThisDataMapTableView();
                onSelectedEntries(event.getSelection(), selectionIndices);
                // bug 18414
                MetadataTableEditorView metadataTableEditorView = null;
                if (getZone() == Zone.INPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getInputMetaEditorView();
                } else if (getZone() == Zone.OUTPUTS) {
                    metadataTableEditorView = mapperManager.getUiManager().getOutputMetaEditorView();
                }
                if (metadataTableEditorView != null) {
                    metadataTableEditorView.getTableViewerCreator().refresh();
                }
            }
        }
    });
    tableForEntries.addListener(SWT.DragDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
        }
    });
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            if (forceExecuteSelectionEvent) {
                forceExecuteSelectionEvent = false;
                onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
            }
        }
    });
    tableForEntries.addListener(SWT.KeyDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            processEnterKeyDown(tableViewerCreatorForColumns, event);
        }
    });
    abstractDataMapTable.getTableColumnsEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<IColumnEntry>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IColumnEntry> event) {
            TableViewerCreator tableViewerCreator = tableViewerCreatorForColumns;
            ITableEntry tableEntry = event.bean;
            parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
            mapperManager.getUiManager().refreshSqlExpression();
        }
    });
    if (abstractDataMapTable instanceof OutputTable) {
        OutputTable outputTable = (OutputTable) abstractDataMapTable;
        outputTable.getWhereTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getWhereTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, extendedTableViewerForFilters);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
                resizeAtExpandedSize();
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
        outputTable.getOtherTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {

            @Override
            public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
                onOutputTableFiltersModified(event, entendedTableViewerForOtherClauses);
                mapperManager.getUiManager().refreshSqlExpression();
            }
        });
    }
}
Also used : SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FilterTableEntry(org.talend.designer.dbmap.model.tableentry.FilterTableEntry) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) AbstractExtendedTableViewer(org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView)

Example 35 with TableViewer

use of org.eclipse.jface.viewers.TableViewer in project tdi-studio-se by Talend.

the class JSONFileOutputStep2Form method addSchemaViewer.

private void addSchemaViewer(final Composite mainComposite, final int width, final int height) {
    final Group group = Form.createGroup(mainComposite, 1, "Linker Source", height);
    // group.setBackgroundMode(SWT.INHERIT_FORCE);
    schemaButton = new Button(group, SWT.PUSH);
    schemaButton.setText("Schema Management");
    schemaButton.setToolTipText("You can add or edit schema and save in 'Schema List' viewer");
    schemaViewer = new TableViewer(group);
    JSONFileTableViewerProvider provider = new JSONFileTableViewerProvider();
    schemaViewer.setContentProvider(provider);
    schemaViewer.setLabelProvider(provider);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    Table table = schemaViewer.getTable();
    if (isReadOnly()) {
        table.setEnabled(false);
    }
    table.setHeaderVisible(true);
    org.eclipse.swt.widgets.TableColumn column = new org.eclipse.swt.widgets.TableColumn(table, SWT.LEFT);
    column.setText("Schema List");
    column.setWidth(100);
    table.setLayoutData(gridData);
}
Also used : Group(org.eclipse.swt.widgets.Group) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Button(org.eclipse.swt.widgets.Button) MoveUpTreeNodeButton(org.talend.repository.json.ui.wizards.buttons.MoveUpTreeNodeButton) MoveDownTreeNodeButton(org.talend.repository.json.ui.wizards.buttons.MoveDownTreeNodeButton) RemoveTreeNodeButton(org.talend.repository.json.ui.wizards.buttons.RemoveTreeNodeButton) AddTreeNodeButton(org.talend.repository.json.ui.wizards.buttons.AddTreeNodeButton) GridData(org.eclipse.swt.layout.GridData) JSONFileTableViewerProvider(org.talend.repository.json.ui.wizards.view.JSONFileTableViewerProvider) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

TableViewer (org.eclipse.jface.viewers.TableViewer)273 GridData (org.eclipse.swt.layout.GridData)161 Composite (org.eclipse.swt.widgets.Composite)152 Table (org.eclipse.swt.widgets.Table)128 GridLayout (org.eclipse.swt.layout.GridLayout)111 SelectionEvent (org.eclipse.swt.events.SelectionEvent)105 TableColumn (org.eclipse.swt.widgets.TableColumn)91 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)79 Label (org.eclipse.swt.widgets.Label)72 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)70 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)61 Button (org.eclipse.swt.widgets.Button)61 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)60 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)56 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)52 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)37 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)37 ArrayList (java.util.ArrayList)28 Point (org.eclipse.swt.graphics.Point)26 Event (org.eclipse.swt.widgets.Event)26