use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsColumnMouseAdapter method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
currentPoint = new Point(e.x, e.y);
// Clean up any previous editor control
Control oldEditor = getEditor();
if (oldEditor != null) {
oldEditor.dispose();
}
if (getViewerCell() == null) {
return;
}
// Identify the selected row
TreeItem item = (TreeItem) getViewerCell().getViewerRow().getItem();
if (item == null) {
return;
}
if (getColumnIndex() < 1) {
// ingore first
return;
}
final Object data = item.getData();
if (!(data instanceof ColumnLineData)) {
return;
}
ColumnLineData lineData = (ColumnLineData) data;
List<MultiMetadataColumn> metadataColumnsInModel = lineData.getKeyData().getMetadataColumnsInModel();
final MultiMetadataColumn multiMetadataColumn = metadataColumnsInModel.get(getColumnIndex() - 1);
Control newEditor = null;
final EPropertyName property = lineData.getProperty();
if (UIManager.isFirstForColumnModel(property)) {
newEditor = createTextControl(item, property, multiMetadataColumn);
} else {
switch(property) {
case NAME:
case TAGLEVEL:
break;
case TYPE:
newEditor = createComboControl(item, multiMetadataColumn);
break;
case LENGTH:
// case CARD:
case PATTERN:
newEditor = createTextControl(item, property, multiMetadataColumn);
break;
case KEY:
/*
* ingore record type(first column);
*
* if existed key column, should not edit other key.
*/
if (getColumnIndex() == uiManager.getSelectedColumnIndex() + 1 || UIManager.existedKeyColumn(metadataColumnsInModel, multiMetadataColumn)) {
break;
}
newEditor = createCheckBoxControl(item, property, multiMetadataColumn);
break;
}
}
if (newEditor != null) {
newEditor.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (getEditor() != null && !getEditor().isDisposed()) {
getEditor().dispose();
}
}
});
newEditor.setFocus();
getTreeEditor().setEditor(newEditor, item, getColumnIndex());
}
}
use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsColumnsProvider method getColumnImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getColumnImage(Object element, int columnIndex) {
if (element instanceof ColumnLineData) {
ColumnLineData lineData = (ColumnLineData) element;
final EPropertyName property = lineData.getProperty();
List<MultiMetadataColumn> columnsData = lineData.getKeyData().getMetadataColumnsInModel();
if (columnsData.size() >= columnIndex && columnIndex > 1) {
MultiMetadataColumn columnData = columnsData.get(columnIndex - 1);
if (columnData != null && property == EPropertyName.KEY) {
if (columnData.isKey()) {
// return ImageProvider.getImage(EImage.CHECKED_ICON);
} else {
// return ImageProvider.getImage(EImage.UNCHECKED_ICON);
}
}
}
}
return null;
}
use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.
the class ChangeMultiSchemasCommand method addSchemasMap.
private void addSchemasMap(List<Map<String, String>> newValueList, List<IMetadataTable> newTables, SchemasKeyData keyData) {
if (keyData == null) {
return;
}
if (keyData.getParent() != null) {
// not root
//
Map<String, String> map = new HashMap<String, String>();
final String uniqueRecord = keyData.getUniqueRecord();
final String recordType = keyData.getRecordType();
map.put(IMultiSchemaConstant.SCHEMA, uniqueRecord);
map.put(IMultiSchemaConstant.RECORD, TalendTextUtils.addQuotes(recordType));
map.put(IMultiSchemaConstant.PARENT_RECORD, TalendTextUtils.addQuotes(keyData.getParent().getRecordType()));
map.put(IMultiSchemaConstant.CARDINALITY, keyData.getCard());
map.put(IMultiSchemaConstant.FIELDDELIMITED, TalendTextUtils.addQuotes(keyData.getSeparator()));
newValueList.add(map);
//
String connectionBaseName = MetadataToolHelper.validateColumnName(MultiSchemasUtil.getConnectionBaseName(uniqueRecord), 0);
String uniqueConnName = node.getProcess().generateUniqueConnectionName(connectionBaseName);
MetadataTable table = new MetadataTable();
table.setLabel(uniqueRecord);
table.setTableName(uniqueConnName);
//$NON-NLS-1$
String keyIndex = "";
boolean first = true;
List<MultiMetadataColumn> metadataColumnsInModel = keyData.getMetadataColumnsInModel();
for (int i = 0; i < metadataColumnsInModel.size(); i++) {
MultiMetadataColumn column = metadataColumnsInModel.get(i);
table.getListColumns().add(column.clone(true));
if (column.isKey()) {
if (first) {
keyIndex += i;
} else {
//$NON-NLS-1$
keyIndex += "," + i;
}
first = false;
}
}
map.put(IMultiSchemaConstant.KEY_COLUMN_INDEX, TalendTextUtils.addQuotes(keyIndex));
newTables.add(table);
}
for (SchemasKeyData child : keyData.getChildren()) {
addSchemasMap(newValueList, newTables, child);
}
}
use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsPropertiesCellModifier method canModify.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
*/
public boolean canModify(Object element, String property) {
if (element instanceof MultiMetadataColumn) {
MultiMetadataColumn column = (MultiMetadataColumn) element;
SchemasKeyData container = column.getContainer();
if (container == null) {
return false;
}
List<MultiMetadataColumn> metadataColumnsInModel = container.getMetadataColumnsInModel();
/*
* ingore record type(first column);
*
* if existed key column, should not edit other key.
*/
if (EPropertyName.KEY.name().equals(property) && (metadataColumnsInModel.indexOf(column) == uiManager.getSelectedColumnIndex() || UIManager.existedKeyColumn(metadataColumnsInModel, column))) {
return false;
}
if (!EPropertyName.TAGLEVEL.name().equals(property)) {
return true;
}
}
return false;
}
use of org.talend.designer.filemultischemas.data.MultiMetadataColumn in project tdi-studio-se by Talend.
the class SchemaDetailsPropertiesProvider method getColumnImage.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex == 2) {
// key
if (element instanceof MultiMetadataColumn) {
MultiMetadataColumn multiMetadataColumn = (MultiMetadataColumn) element;
// first column(record type)
SchemasKeyData container = multiMetadataColumn.getContainer();
if (container != null && container.getMetadataColumnsInModel().indexOf(multiMetadataColumn) == 0) {
return null;
}
if (multiMetadataColumn.isKey()) {
// return ImageProvider.getImage(EImage.CHECKED_ICON);
} else {
// return ImageProvider.getImage(EImage.UNCHECKED_ICON);
}
}
}
return null;
}
Aggregations