use of org.talend.designer.dbmap.model.tableentry.AbstractInOutTableEntry 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.tableentry.AbstractInOutTableEntry in project tdi-studio-se by Talend.
the class OutputTable method initFromExternalData.
@Override
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
List<IMetadataColumn> columns = this.metadataTable.getListColumns();
Map<String, ExternalDbMapEntry> nameToPerTabEntry = new HashMap<String, ExternalDbMapEntry>();
if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
for (ExternalDbMapEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
}
}
for (IMetadataColumn column : columns) {
AbstractInOutTableEntry columnEntry = getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(columnEntry.getMetadataColumn().getLabel());
// Entry match with current column
if (externalMapperTableEntry != null) {
columnEntry.setExpression(externalMapperTableEntry.getExpression());
}
dataMapTableEntries.add(columnEntry);
}
if (externalMapperTable != null) {
List<ExternalDbMapEntry> externalWhereConstraintTableEntries = externalMapperTable.getCustomWhereConditionsEntries();
if (externalWhereConstraintTableEntries != null) {
for (ExternalDbMapEntry entry : externalWhereConstraintTableEntries) {
FilterTableEntry whereFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.WHERE_FILTER);
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addWhereFilterEntry(whereFilterTableEntry);
}
}
List<ExternalDbMapEntry> externalOtherConstraintTableEntries = externalMapperTable.getCustomOtherConditionsEntries();
if (externalOtherConstraintTableEntries != null) {
for (ExternalDbMapEntry entry : externalOtherConstraintTableEntries) {
FilterTableEntry otherFilterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression(), FilterTableEntry.OTHER_FILTER);
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addOtherFilterEntry(otherFilterTableEntry);
}
}
}
}
Aggregations