use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView 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>() {
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);
// see bug 7471,record the modification about the column value
String curConnName = null;
if (dataMapTableEntry != null) {
curConnName = dataMapTableEntry.getParentName();
}
List<? extends IConnection> curInConns = mapperManager.getAbstractMapComponent().getIncomingConnections();
List<? extends IConnection> curOutConns = mapperManager.getAbstractMapComponent().getOutgoingConnections();
for (IConnection curInConn : curInConns) {
if (curConnName.equals(curInConn.getUniqueName())) {
Map<String, String> changedNameInColumns = new HashMap<String, String>();
changedNameInColumns.put((String) event.newValue, (String) event.previousValue);
changedNameColumns.put(curInConn, changedNameInColumns);
}
}
for (IConnection curOutConn : curOutConns) {
if (curConnName.equals(curOutConn.getUniqueName())) {
Map<String, String> changedNameOutColumns = new HashMap<String, String>();
changedNameOutColumns.put((String) event.newValue, (String) event.previousValue);
changedNameColumns.put(curOutConn, changedNameOutColumns);
}
}
processColumnNameChanged((String) event.previousValue, (String) event.newValue, dataMapTableView, dataMapTableEntry);
// related tables
List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
for (DataMapTableView relatedView : relatedOutputsTableView) {
TableEntryLocation relatedEntryLocation = new TableEntryLocation(relatedView.getDataMapTable().getName(), (String) event.previousValue);
ITableEntry relatedTableEntry = mapperManager.retrieveTableEntry(relatedEntryLocation);
processColumnNameChanged((String) event.previousValue, (String) event.newValue, relatedView, relatedTableEntry);
}
}
// dataMapTableViewer.refresh(event.bean, true);
tableViewer.refresh(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() {
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() {
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.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method parseAllExpressionsForAllTables.
/**
* DOC amaumont Comment method "processAllExpressions".
*/
@SuppressWarnings("unchecked")
public void parseAllExpressionsForAllTables() {
List<DataMapTableView> tablesView = tableManager.getInputsTablesView();
tablesView.addAll(tableManager.getVarsTablesView());
tablesView.addAll(tableManager.getOutputsTablesView());
for (DataMapTableView view : tablesView) {
parseAllExpressions(view, false);
}
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method unregisterCustomPaint.
public void unregisterCustomPaint() {
List<DataMapTableView> tablesView = mapperManager.getUiManager().getOutputsTablesView();
tablesView.addAll(mapperManager.getUiManager().getInputsTablesView());
for (DataMapTableView view : tablesView) {
view.getTableViewerCreatorForColumns().setUseCustomItemColoring(false);
}
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class ProblemsManager method checkProblemsForAllEntriesOfAllTables.
/**
*
* DOC amaumont Comment method "checkProblemsForAllEntriesOfAllTables".
*
* @param forceRefreshData
* @return true if has errors
*/
public boolean checkProblemsForAllEntriesOfAllTables(boolean forceRefreshData) {
hasProblems = Boolean.FALSE;
List<DataMapTableView> tablesView = mapperManager.getUiManager().getInputsTablesView();
tablesView.addAll(mapperManager.getUiManager().getVarsTablesView());
tablesView.addAll(mapperManager.getUiManager().getOutputsTablesView());
if (forceRefreshData) {
mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
checkProblems();
}
for (DataMapTableView view : tablesView) {
checkProblemsForAllEntries(view, false);
}
boolean returnedValue = hasProblems;
hasProblems = null;
return returnedValue;
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class ProblemsManager method checkProblemsForTableEntry.
public boolean checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData, boolean checkLookupProblem) {
if (!mapperManager.isCheckSyntaxEnabled()) {
return false;
}
if (forceRefreshData) {
mapperManager.getAbstractMapComponent().restoreMapperModelFromInternalData();
checkProblems();
}
String expression = tableEntry.getExpression();
List<Problem> problems = null;
if (expression == null || EMPTY_STRING.equals(expression.trim())) {
problems = null;
} else {
// System.out.println("check=" + expression);
if (codeLanguage == ECodeLanguage.PERL) {
problems = codeChecker.checkProblemsForExpression(expression);
} else if (codeLanguage == ECodeLanguage.JAVA) {
PROBLEM_KEY_FIELD problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN;
String entryName = tableEntry.getName();
if (tableEntry instanceof FilterTableEntry || tableEntry instanceof ExpressionFilterEntry) {
problemKeyField = JavaGenerationManager.PROBLEM_KEY_FIELD.FILTER;
entryName = null;
}
problems = checkJavaProblemsForEntry(problemKeyField, tableEntry.getParent().getName(), entryName, forceRefreshData);
}
if (problems != null) {
for (Iterator iter = problems.iterator(); iter.hasNext(); ) {
Problem problem = (Problem) iter.next();
ProblemStatus status = problem.getStatus();
if (status != ProblemStatus.ERROR) {
iter.remove();
}
}
} else {
problems = null;
}
}
if (problems != null) {
if (problems.size() == 0) {
tableEntry.setProblems(null);
} else {
hasProblems = true;
tableEntry.setProblems(problems);
}
} else {
tableEntry.setProblems(problems);
}
// check problem for M/R process , only needed if modify lookup expressions
if (checkLookupProblem) {
checkLookupExpressionProblem();
}
// no need to update again
TableViewerCreator tableViewerCreator = mapperManager.retrieveTableViewerCreator(tableEntry);
DataMapTableView retrieveDataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreator);
return problems != null;
}
Aggregations