use of org.talend.designer.dbmap.model.table.AbstractInOutTable in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkProblems.
public List<Problem> checkProblems(ExternalDbMapData externalData) {
problems.clear();
if (externalData != null) {
List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
tablesWriteMode.addAll(inputTables);
tablesWriteMode.addAll(outputTables);
List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
ProblemsManager problemsManager = new ProblemsManager(mapperManager);
ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
for (AbstractInOutTable table : tablesReadMode) {
List<IColumnEntry> columnEntries = table.getColumnEntries();
problemsManager.checkProblemsForAllEntries(columnEntries);
for (IColumnEntry entry : columnEntries) {
List<Problem> problemsOfEntry = entry.getProblems();
if (problemsOfEntry != null) {
problemsLocal.addAll(problemsOfEntry);
}
}
}
problems.addAll(problemsLocal);
}
return getProblems();
}
use of org.talend.designer.dbmap.model.table.AbstractInOutTable in project tdi-studio-se by Talend.
the class DataMapTableView method createTableForColumns.
/**
* DOC amaumont Comment method "createTableForColumns".
*
* @param parent
*/
private void createTableForColumns(Composite parent) {
this.extendedTableViewerForColumns = new AbstractExtendedTableViewer<IColumnEntry>(abstractDataMapTable.getTableColumnsEntriesModel(), parent) {
@Override
protected void createColumns(TableViewerCreator<IColumnEntry> tableViewerCreator, Table table) {
initColumnsOfTableColumns(tableViewerCreator);
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initTableListeners()
*/
@Override
protected void initTableListeners() {
super.initTableListeners();
getTableViewerCreator().addCellValueModifiedListener(new ITableCellValueModifiedListener() {
@Override
public void cellValueModified(TableCellValueModifiedEvent e) {
// System.out.println();
// System.out.println(getTable().hashCode());
// System.out.println(e.tableItem.getParent().hashCode());
// if (e.tableItem.getParent().isFocusControl()) {
// only if table of item is actually the focus control
getTableViewerCreator().getSelectionHelper().deselectAll();
getTable().forceFocus();
// }
}
});
}
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
* (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
*/
@Override
protected void setTableViewerCreatorOptions(final TableViewerCreator<IColumnEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setColumnsResizableByDefault(true);
newTableViewerCreator.setBorderVisible(false);
newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
newTableViewerCreator.setKeyboardManagementForCellEdition(false);
// tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable() instanceof
// AbstractInOutTable);
newTableViewerCreator.setFirstColumnMasked(true);
if (getDataMapTable() instanceof AbstractInOutTable) {
if (imageKey == null) {
imageKey = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.KEY_ICON);
}
if (imageEmpty == null) {
imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
}
}
newTableViewerCreator.setLabelProvider(new DefaultTableLabelProvider(newTableViewerCreator) {
@Override
public Color getBackground(Object element, int columnIndex) {
Color backgroundCellColor = getBackgroundCellColor(newTableViewerCreator, element, columnIndex);
if (backgroundCellColor != null) {
return backgroundCellColor;
}
return super.getBackground(element, columnIndex);
}
@Override
public Color getForeground(Object element, int columnIndex) {
Color foregroundCellColor = getForegroundCellColor(newTableViewerCreator, element, columnIndex);
if (foregroundCellColor != null) {
return foregroundCellColor;
}
return getForegroundCellColor(newTableViewerCreator, element, columnIndex);
}
@Override
public Image getColumnImage(Object element, int columnIndex) {
return getColumnImageExecute(element, columnIndex);
}
/**
* DOC amaumont Comment method "getColumnImageExecute".
*
* @param element
* @param columnIndex
* @return
*/
private Image getColumnImageExecute(Object element, int columnIndex) {
if (getDataMapTable() instanceof AbstractInOutTable) {
AbstractInOutTableEntry entry = (AbstractInOutTableEntry) element;
TableViewerCreatorColumnNotModifiable column = newTableViewerCreator.getColumns().get(columnIndex);
if (column.getId().equals(ID_NAME_COLUMN)) {
if (entry.getMetadataColumn().isKey()) {
return imageKey;
} else {
return imageEmpty;
}
}
}
return null;
}
});
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initModelListeners()
*/
@Override
protected void initModelListeners() {
super.initModelListeners();
getExtendedTableModel().addAfterOperationListListener(100, new IListenableListListener<IColumnEntry>() {
@Override
public void handleEvent(ListenableListEvent<IColumnEntry> event) {
if (tableViewerCreator.getTable() != null && !tableViewerCreator.getTable().isDisposed()) {
if (event.type == TYPE.ADDED) {
Collection<IColumnEntry> addedObjects = event.addedObjects;
for (IColumnEntry tableEntry : addedObjects) {
mapperManager.getProblemsManager().checkProblemsForTableEntry(tableEntry, false);
}
}
}
}
});
}
};
tableViewerCreatorForColumns = this.extendedTableViewerForColumns.getTableViewerCreator();
this.extendedTableViewerForColumns.setCommandStack(mapperManager.getCommandStack());
tableForEntries = tableViewerCreatorForColumns.getTable();
GridData tableEntriesGridData = new GridData(GridData.FILL_BOTH);
tableEntriesGridData.grabExcessVerticalSpace = true;
tableEntriesGridData.minimumHeight = tableForEntries.getHeaderHeight() + tableForEntries.getItemHeight();
// tableEntriesGridData.heightHint = 50;
// tableEntriesGridData.grabExcessVerticalSpace = false;
tableForEntries.setLayoutData(tableEntriesGridData);
addTablesListeners();
}
use of org.talend.designer.dbmap.model.table.AbstractInOutTable in project tdi-studio-se by Talend.
the class UIManager method selectDataMapTableView.
/**
* Select a table view.
*
* @param dataMapTableView
* @param useNewCommand
* @param selectAllEntries TODO
*/
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
// tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
MetadataTableEditorView metadataTableEditorView = null;
MetadataTableEditorView otherMetadataTableEditorView = null;
final Zone currentZone = dataMapTableView.getZone();
List<? extends IDataMapTable> tables = null;
DataMapTableView previousSelectedTableView = null;
DataMapTableView newSelectedTableView = null;
if (currentZone == Zone.INPUTS) {
metadataTableEditorView = tabFolderEditors.getInputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
tables = mapperManager.getInputTables();
previousSelectedTableView = this.currentSelectedInputTableView;
setCurrentSelectedInputTableView((InputDataMapTableView) dataMapTableView);
newSelectedTableView = dataMapTableView;
} else if (currentZone == Zone.OUTPUTS) {
metadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditor();
tables = mapperManager.getOutputTables();
previousSelectedTableView = this.currentSelectedOutputTableView;
newSelectedTableView = dataMapTableView;
setCurrentSelectedOutputTableView((OutputDataMapTableView) dataMapTableView);
}
updateToolbarButtonsStates(currentZone);
final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveIDataMapTable(dataMapTableView);
MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && newSelectedTableView != previousSelectedTableView) {
if (useNewCommand) {
DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
mapperManager.executeCommand(command);
}
currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getTitle());
currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
// init actions listeners for list which contains metadata
metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {
/**
* DOC acer Comment method "handleEvent".
*
* @param event
*/
@Override
public void handleEvent(ListenableListEvent event) {
DataMapTableView view = mapperManager.retrieveIDataMapTableView(abstractDataMapTable);
if (event.type == TYPE.ADDED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
lastCreatedInOutColumnEntries.clear();
if (event.index != null) {
int index = event.index;
for (IMetadataColumn metadataColumn : metadataColumns) {
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index++));
}
} else if (event.indicesTarget != null) {
List<Integer> indicesTarget = event.indicesTarget;
int lstSize = indicesTarget.size();
for (int i = 0; i < lstSize; i++) {
Integer indice = indicesTarget.get(i);
IMetadataColumn metadataColumn = metadataColumns.get(i);
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("UIManager.1"));
}
refreshBackground(false, false);
if (event.index != null) {
dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
dataMapTableViewer.refresh();
dataMapTVCreator.getSelectionHelper().setSelection(event.index);
} else if (event.indicesTarget != null) {
dataMapTableViewer.refresh();
dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
dataMapTVCreator.getSelectionHelper().setSelection(selection);
}
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
if (event.type == TYPE.REMOVED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
for (IMetadataColumn metadataColumn : metadataColumns) {
ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
mapperManager.removeTableEntry(metadataTableEntry);
}
dataMapTableViewer.refresh();
dataMapTableView.resizeAtExpandedSize();
resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
refreshBackground(true, false);
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
if (event.type == TYPE.SWAPED) {
List<Integer> listIndexTarget = event.indicesTarget;
abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
// dataMapTableViewer.refresh();
refreshBackground(true, false);
}
}
});
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
// disable highlight for other DataMapTableView and highlight selected DataMapTableView
for (IDataMapTable table : tables) {
DataMapTableView otherDataMapTableView = mapperManager.retrieveIDataMapTableView(table);
otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
}
dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
}
if (selectAllEntries) {
dataMapTVCreator.getTable().selectAll();
selectAllLinks(dataMapTableView);
metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
if (currentZone == Zone.OUTPUTS) {
dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().selectAll();
dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().selectAll();
}
}
if (otherMetadataTableEditorView != null) {
otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
use of org.talend.designer.dbmap.model.table.AbstractInOutTable in project tdi-studio-se by Talend.
the class UIManager method refreshInOutTableAndMetaTable.
/**
* DOC amaumont Comment method "refreshInOutTableAndMetaTable".
*
* @param currentModifiedTableEntry can be null
*/
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
}
}
use of org.talend.designer.dbmap.model.table.AbstractInOutTable in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param renamingDependentEntries TODO
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
boolean atLeastOneLinkHasBeenRemoved = false;
for (DataMapTableView view : tableViews) {
IDataMapTable dataMapTable = view.getDataMapTable();
List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
for (IColumnEntry entry : metadataTableEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
if (dataMapTable instanceof OutputTable) {
List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
for (FilterTableEntry entry : constraintWhereEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
for (FilterTableEntry entry : constraintOtherEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
refreshSqlExpression();
if (!renamingDependentEntries) {
AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
if (currentTable instanceof InputTable) {
InputTable currentInputTable = (InputTable) currentTable;
String physicalTableName = currentInputTable.getTableName();
String alias = currentInputTable.getAlias();
InputTable physicalInputTable = null;
List<InputTable> inputTables = mapperManager.getInputTables();
if (alias != null) {
for (InputTable table : inputTables) {
if (table.equals(physicalTableName)) {
physicalInputTable = table;
}
}
} else {
physicalInputTable = currentInputTable;
}
if (physicalInputTable == null) {
List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
IOConnection connectionFound = null;
for (IOConnection connection : incomingConnections) {
if (connection.getName().equals(physicalTableName)) {
connectionFound = connection;
}
}
IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
if (metadataColumn != null) {
metadataColumn.setLabel(newColumnName);
}
}
for (InputTable table : inputTables) {
if ((// Physical table parent
alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
if (aliasTableEntry != null) {
processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
}
}
}
}
}
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
Aggregations