use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.
the class MapperManager method addMetadataTableEditorEntry.
/**
* DOC amaumont Comment method "addTableEntry".
*
* @param dataMapTableEntry
* @param index
*/
public void addMetadataTableEditorEntry(MetadataTableEditorView metadataTableEditorView, IMetadataColumn metadataColumn, Integer index) {
MetadataTableEditor metadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
metadataTableEditor.add(metadataColumn, index);
}
use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.
the class MainConnectionComposite method addComponents.
@Override
public void addComponents(boolean forceRedraw) {
if (conSchema()) {
disposeChildren();
curRowSize = 0;
List<? extends IElementParameter> listParam = ((Connection) elem).getSource().getElementParameters();
generator.initController(this);
for (IElementParameter cur : listParam) {
if (cur.getCategory() == this.section) {
if ((cur.getFieldType() == EParameterFieldType.SCHEMA_TYPE || cur.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) && (cur.getContext().equals(((Connection) elem).getConnectorName()))) {
AbstractElementPropertySectionController contorller = generator.getController(EParameterFieldType.SCHEMA_TYPE, this);
contorller.createControl(composite, cur, 1, 1, 0, null);
}
}
}
if (((Connection) elem).getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IMetadataTable outputMetaTable = ((Connection) elem).getMetadataTable();
if (outputMetaTable != null && this.section == EComponentCategory.BASIC) {
// Composite compositeEditorView = new Composite(composite, SWT.BORDER);
// compositeEditorView.setLayoutData(data);
metadataTableEditor = new MetadataTableEditor(outputMetaTable, //$NON-NLS-1$
"Schema from " + ((Connection) elem).getSource().getElementName() + //$NON-NLS-1$
" output ");
metadataTableEditorView = new MetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, true, false, true, false);
MetadataDialog.initializeMetadataTableView(metadataTableEditorView, ((Connection) elem).getSource(), outputMetaTable);
metadataTableEditorView.initGraphicComponents();
metadataTableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
CustomTableManager.addCustomManagementToTable(metadataTableEditorView, true);
Composite compositeEditorView = metadataTableEditorView.getMainComposite();
Table table = metadataTableEditorView.getTable();
FormData data = new FormData();
data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(0, curRowSize + ITabbedPropertyConstants.VSPACE);
// to correct bug of table growing indefinitly
data.width = 300;
/*
* On windows it will adjust automatically the size depends the number of columns. Seems this system
* doesn't work on linux
*/
// fix bug 3893.
int tableHeight = 160;
int maxTableHeight = table.getHeaderHeight() + 22 * table.getItemHeight();
int rows = outputMetaTable.getListColumns().size();
int currentHeightEditor = table.getHeaderHeight() + rows * table.getItemHeight() + 50;
if (currentHeightEditor > tableHeight) {
tableHeight = currentHeightEditor;
}
if (currentHeightEditor > maxTableHeight) {
tableHeight = maxTableHeight;
}
// fix bug 3893.
data.height = tableHeight;
compositeEditorView.setLayoutData(data);
// compositeEditorView.getParent().layout();
// Table table = metadataTableEditorView.getTable();
// int currentHeightEditor = table.getHeaderHeight() + outputMetaTable.getListColumns().size()
// * table.getItemHeight() + table.getItemHeight() + 50;
curRowSize = tableHeight + ITabbedPropertyConstants.VSPACE + curRowSize;
}
}
super.addComponents(forceRedraw, false, curRowSize);
} else if (conIf()) {
super.addComponents(forceRedraw);
} else if (resumingIf()) {
super.addComponents(forceRedraw);
} else {
disposeChildren();
}
}
use of org.talend.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.
the class MainConnectionSection method addComponents.
@Override
public void addComponents(boolean forceRedraw) {
if (conSchema()) {
disposeChildren();
curRowSize = 0;
List<? extends IElementParameter> listParam = ((Connection) elem).getSource().getElementParameters();
generator.initController(this);
for (IElementParameter cur : listParam) {
if ((cur.getFieldType() == EParameterFieldType.SCHEMA_TYPE || cur.getFieldType() == EParameterFieldType.SCHEMA_REFERENCE) && (cur.getContext().equals(((Connection) elem).getConnectorName()))) {
AbstractElementPropertySectionController contorller = generator.getController(EParameterFieldType.SCHEMA_TYPE, this);
contorller.createControl(composite, cur, 0, 0, 0, null);
}
}
FormData data = new FormData();
data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
data.top = new FormAttachment(0, curRowSize + ITabbedPropertyConstants.VSPACE);
// to correct bug of table growing indefinitly
data.width = 300;
IMetadataTable outputMetaTable = ((Connection) elem).getMetadataTable();
if (outputMetaTable != null) {
// Composite compositeEditorView = new Composite(composite, SWT.BORDER);
// compositeEditorView.setLayoutData(data);
metadataTableEditor = new MetadataTableEditor(outputMetaTable, //$NON-NLS-1$
"Schema from " + ((Connection) elem).getSource().getElementName() + //$NON-NLS-1$
" output ");
metadataTableEditorView = new MetadataTableEditorView(composite, SWT.NONE, metadataTableEditor, true, false, true, false);
MetadataDialog.initializeMetadataTableView(metadataTableEditorView, ((Connection) elem).getSource(), outputMetaTable);
metadataTableEditorView.initGraphicComponents();
metadataTableEditorView.getExtendedTableViewer().setCommandStack(getCommandStack());
CustomTableManager.addCustomManagementToTable(metadataTableEditorView, true);
Composite compositeEditorView = metadataTableEditorView.getMainComposite();
compositeEditorView.setLayoutData(data);
// compositeEditorView.getParent().layout();
Table table = metadataTableEditorView.getTable();
int currentHeightEditor = table.getHeaderHeight() + outputMetaTable.getListColumns().size() * table.getItemHeight() + table.getItemHeight() + 50;
curRowSize = currentHeightEditor + ITabbedPropertyConstants.VSPACE + curRowSize;
}
super.addComponents(forceRedraw, false);
} else if (conIf()) {
super.addComponents(forceRedraw);
} else {
disposeChildren();
}
}
use of org.talend.core.ui.metadata.editor.MetadataTableEditor 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.core.ui.metadata.editor.MetadataTableEditor in project tdi-studio-se by Talend.
the class spssComponent method getSchemaFromSPSSFile.
private void getSchemaFromSPSSFile() {
try {
List<IMetadataTable> metadataList = getMetadataList();
MetadataTable metaTable = (MetadataTable) metadataList.get(0);
metaTable.getListColumns().clear();
MetadataTableEditor tableEditor = new MetadataTableEditor(metaTable, "");
spss spssIn = new spss();
spssfile spssFile = spssIn.openFile(strFileName, spssfile.SPSS_READ);
String strComponentName = this.getComponent().getName();
spssvariables spssVars = spssFile.getVariables();
spssvariable spssVar;
for (int i = 0; i < spssVars.getNumberOfVariables(); i++) {
spssVar = spssVars.getVariabelAtPos(i);
IMetadataColumn column = tableEditor.createNewMetadataColumn();
String lableName = MetadataToolHelper.validateColumnName(spssVar.getName(), i);
column.setLabel(lableName);
column.setOriginalDbColumnName(spssVar.getName());
if (spssVar.hasLabels() && strTranslateLabels.toLowerCase().equals("true")) {
column.setLength(spssVar.getMaxLengthByLableTranslation());
column.setPrecision(0);
column.setTalendType("id_String");
} else {
switch(spssVar.getJAVAType()) {
case spssvariable.JAVA_TYPE_DOUBLE:
column.setTalendType("id_Double");
break;
case spssvariable.JAVA_TYPE_STRING:
column.setTalendType("id_String");
break;
case spssvariable.JAVA_TYPE_DATE:
column.setTalendType("id_Date");
break;
}
column.setLength(spssVar.getDecimals());
column.setPrecision(spssVar.getPrecision());
}
String strLabel = spssVar.getLabel();
if (null != strLabel && strLabel.length() > 0)
column.setComment(strLabel);
else
column.setComment("");
if (null == strComponentName || strComponentName.toLowerCase().equals("tspssinput"))
column.setReadOnly(true);
else
column.setReadOnly(false);
metaTable.getListColumns().add(column);
}
spssFile.close();
} catch (Exception e) {
log.error("", e);
}
}
Aggregations