use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry 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.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.
the class StyleLinkFactory method getStyleLink.
// public static DrawableLinkFactory getInstance() {
// if (instance == null) {
// instance = new DrawableLinkFactory();
// }
// return instance;
// }
//
// public IDrawableLink getDrawableLink(IMapperLink link) {
// IDrawableLink drawableLink = null;
// PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptorSource();
// PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptorTarget();
// if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
// drawableLink = new HorizontalBezierLink();
// } else if (pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
// drawableLink = new VerticalRoundedCornerLink();
// }
// return drawableLink;
// }
//
public IStyleLink getStyleLink(IMapperLink link) {
ILinkState linkState = link.getState();
PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptor1();
PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptor2();
ITableEntry targetTableEntry = pointLinkDescriptorTarget.getTableEntry();
boolean targetIsConstraint = false;
if (targetTableEntry instanceof FilterTableEntry) {
targetIsConstraint = true;
}
IStyleLink style = null;
if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
if (linkState == LinkState.SELECTED) {
if (targetIsConstraint) {
style = selectedFilterStyle;
} else {
style = selectedZoneToZoneStyle;
}
} else if (linkState == LinkState.UNSELECTED) {
if (targetIsConstraint) {
style = unselectedFilterStyle;
} else {
style = unselectedZoneToZoneStyle;
}
}
} else if ((pointLinkDescriptorSource.getZone() == Zone.INPUTS || pointLinkDescriptorSource.getZone() == Zone.OUTPUTS) && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
if (linkState == LinkState.SELECTED) {
style = selectedSameInputZoneStyle;
} else if (linkState == LinkState.UNSELECTED) {
style = unselectedSameZoneStyle;
}
}
return style;
}
use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initTableFilters.
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#initTableConstraints()
*/
@Override
protected void initTableFilters(Composite parent) {
/**
* create whereFiltersTable
*/
// createFiltersTable(parent);
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalWhereClauses");
extendedTableViewerForFilters = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getWhereTableFiltersEntriesModel(), parent) {
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
* getTableConstraintSize()
*/
@Override
protected int getTableConstraintSize() {
int retSize = 0;
if (abstractDataMapTable instanceof OutputTable) {
retSize = ((OutputTable) abstractDataMapTable).getWhereFilterEntries().size();
}
return retSize;
}
@Override
protected void setTextCellEditor(TextCellEditor textEditor) {
if (textEditor != null) {
whereConstraintExpressionTextEditor = (Text) textEditor.getControl();
}
}
};
// correct partially layout problem with GTK when cell editor value is applied
((ExtendedTableViewerForFilters) extendedTableViewerForFilters).createFiltersTable();
TableViewerCreator tableViewerCreatorForWhereClauses = extendedTableViewerForFilters.getTableViewerCreator();
tableViewerCreatorForWhereClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
List<FilterTableEntry> whereEntries = ((OutputTable) getDataMapTable()).getWhereFilterEntries();
tableViewerCreatorForWhereClauses.init(whereEntries);
/**
* create otherFiltersTable
*/
IComponent component = getMapperManager().getComponent().getComponent();
if (component != null && "tELTOracleMap".equals(component.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses.oracle");
} else {
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses");
}
entendedTableViewerForOtherClauses = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getOtherTableFiltersEntriesModel(), parent) {
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
* getTableConstraintSize()
*/
@Override
public int getTableConstraintSize() {
int retSize = 0;
if (abstractDataMapTable instanceof OutputTable) {
retSize = ((OutputTable) abstractDataMapTable).getOtherFilterEntries().size();
}
return retSize;
}
@Override
protected void setTextCellEditor(TextCellEditor textEditor) {
if (textEditor != null) {
otherConstraintExpressionTextEditor = (Text) textEditor.getControl();
}
}
};
((ExtendedTableViewerForFilters) entendedTableViewerForOtherClauses).createFiltersTable();
TableViewerCreator tableViewerCreatorForOtherClauses = entendedTableViewerForOtherClauses.getTableViewerCreator();
tableViewerCreatorForOtherClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
List<FilterTableEntry> otherEntries = ((OutputTable) getDataMapTable()).getOtherFilterEntries();
tableViewerCreatorForOtherClauses.init(otherEntries);
// updateGridDataHeightForTableConstraints(entendedTableViewerForOtherClauses.getTable());
updateGridDataHeightForTableConstraints();
if (WindowSystem.isGTK()) {
tableViewerCreatorForWhereClauses.layout();
entendedTableViewerForOtherClauses.getTableViewerCreator().layout();
}
}
use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry 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);
}
}
}
}
use of org.talend.designer.dbmap.model.tableentry.FilterTableEntry in project tdi-studio-se by Talend.
the class TableEntriesManager method remove.
public void remove(ITableEntry dataMapTableEntry, boolean removingPhysicalInputTable) {
if (dataMapTableEntry != null) {
mapperManager.removeLinksOf(dataMapTableEntry);
tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
dataMapTableEntryToProperties.remove(dataMapTableEntry);
IDataMapTable dataMapTable = dataMapTableEntry.getParent();
if (dataMapTableEntry instanceof IColumnEntry) {
dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
InputTable inputTable = isPhysicalTable(dataMapTable);
if (inputTable != null && !removingPhysicalInputTable) {
removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
}
} else if (dataMapTableEntry instanceof FilterTableEntry) {
if (dataMapTable instanceof OutputTable) {
if (FilterTableEntry.WHERE_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
((OutputTable) dataMapTable).removeWhereFilterEntry((FilterTableEntry) dataMapTableEntry);
} else if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
((OutputTable) dataMapTable).removeOtherFilterEntry((FilterTableEntry) dataMapTableEntry);
}
}
} else {
String exceptionMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
throw new IllegalArgumentException(exceptionMessage);
}
}
}
Aggregations