use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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();
}
});
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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);
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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);
}
}
});
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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);
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent 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);
}
}
});
}
Aggregations