Search in sources :

Example 1 with ILineSelectionListener

use of org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener in project tdi-studio-se by Talend.

the class VarsDataMapTableView method addListeners.

@Override
protected void addListeners() {
    super.addListeners();
    tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

        public void handle(LineSelectionEvent e) {
            if (!getMapperManager().componentIsReadOnly()) {
                boolean atLeastOneItemIsSelected = tableViewerCreatorForColumns.getTable().getSelectionCount() > 0;
                removeEntryItem.setEnabled(atLeastOneItemIsSelected);
                moveUpEntryItem.setEnabled(atLeastOneItemIsSelected);
                moveDownEntryItem.setEnabled(atLeastOneItemIsSelected);
            }
        }
    });
    getExtendedTableViewerForColumns().getExtendedTableModel().addAfterOperationListListener(new IListenableListListener() {

        public void handleEvent(ListenableListEvent event) {
            if (event.type == ListenableListEvent.TYPE.SWAPED) {
                DataMapTableView varsDataMapTableView = mapperManager.retrieveDataMapTableView(getExtendedTableViewerForColumns().getTable());
                UIManager uiManager = mapperManager.getUiManager();
                uiManager.parseAllExpressions(varsDataMapTableView, false);
                mapperManager.getProblemsManager().checkProblemsForAllEntries(varsDataMapTableView, true);
                uiManager.refreshBackground(true, false);
                List<ITableEntry> list = uiManager.extractSelectedTableEntries(varsDataMapTableView.getTableViewerCreatorForColumns().getTableViewer().getSelection());
                uiManager.selectLinks(varsDataMapTableView, list, false, false);
            }
        }
    });
}
Also used : ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) UIManager(org.talend.designer.mapper.managers.UIManager) List(java.util.List) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener)

Example 2 with ILineSelectionListener

use of org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener 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 3 with ILineSelectionListener

use of org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener in project tdi-studio-se by Talend.

the class JSONToXPathLinker method initFieldsListeners.

/**
     * DOC amaumont Comment method "initListeners".
     */
private void initFieldsListeners() {
    JSONExtractorFieldModel schemaModel = this.fieldsTableEditorView.getModel();
    final Table fieldsTable = this.fieldsTableEditorView.getTable();
    schemaModelModifiedBeanListener = new IModifiedBeanListener<SchemaTarget>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<SchemaTarget> event) {
            handleModifiedBeanEvent(event);
        }

        private void handleModifiedBeanEvent(ModifiedBeanEvent<SchemaTarget> event) {
            if (event.column == fieldsTableEditorView.getXPathColumn()) {
                onXPathValueChanged(fieldsTable, (String) event.newValue, event.index);
            }
        }
    };
    schemaModel.addModifiedBeanListener(schemaModelModifiedBeanListener);
    schemaModelBeforeListenableListListener = new IListenableListListener<SchemaTarget>() {

        @Override
        public void handleEvent(ListenableListEvent<SchemaTarget> event) {
            handleListenableListBeforeTableViewerRefreshedEvent(event);
        }
    };
    schemaModel.addBeforeOperationListListener(-50, schemaModelBeforeListenableListListener);
    schemaModelAfterListenableListListener = new IListenableListListener<SchemaTarget>() {

        @Override
        public void handleEvent(ListenableListEvent<SchemaTarget> event) {
            handleListenableListAfterTableViewerRefreshedEvent(event);
        }
    };
    schemaModel.addAfterOperationListListener(schemaModelAfterListenableListListener);
    SelectionHelper selectionHelper = this.fieldsTableEditorView.getTableViewerCreator().getSelectionHelper();
    fieldsTableLineSelectionListener = new ILineSelectionListener() {

        @Override
        public void handle(LineSelectionEvent e) {
            updateLinksStyleAndControlsSelection(e.source.getTable(), true);
        }
    };
    selectionHelper.addAfterSelectionListener(fieldsTableLineSelectionListener);
}
Also used : LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) Table(org.eclipse.swt.widgets.Table) SelectionHelper(org.talend.commons.ui.runtime.swt.tableviewer.selection.SelectionHelper) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) SchemaTarget(org.talend.repository.model.json.SchemaTarget)

Example 4 with ILineSelectionListener

use of org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener 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() {

        @Override
        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) {
            removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
        }
    }
    if (removeButton != null) {
        final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
        tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {

            @Override
            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)
             */
        @Override
        public void widgetDisposed(DisposeEvent e) {
            for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
                extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) RemovePushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButton) TableItem(org.eclipse.swt.widgets.TableItem) 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) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) ExtendedPushButton(org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton) MetadataToolbarEditorView(org.talend.core.ui.metadata.editor.MetadataToolbarEditorView) ExtendedButtonEvent(org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)

Example 5 with ILineSelectionListener

use of org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener 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)

Aggregations

ILineSelectionListener (org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)10 LineSelectionEvent (org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent)10 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 TableViewer (org.eclipse.jface.viewers.TableViewer)3 ExtendedButtonEvent (org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent)3 IExtendedButtonListener (org.talend.commons.ui.swt.extended.table.IExtendedButtonListener)3 IModifiedBeanListener (org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener)3 ModifiedBeanEvent (org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent)3 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)3 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 Event (org.eclipse.swt.widgets.Event)2 Listener (org.eclipse.swt.widgets.Listener)2 Table (org.eclipse.swt.widgets.Table)2 TableItem (org.eclipse.swt.widgets.TableItem)2 RemovePushButton (org.talend.commons.ui.swt.advanced.dataeditor.button.RemovePushButton)2 ExtendedPushButton (org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton)2 IListenableListListener (org.talend.commons.utils.data.list.IListenableListListener)2 ListenableListEvent (org.talend.commons.utils.data.list.ListenableListEvent)2