use of org.talend.designer.filemultischemas.data.SchemasKeyData 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.SchemasKeyData 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;
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class SchemaDetailsColumnsProvider method getElements.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
if (inputElement instanceof SchemasKeyData) {
SchemasKeyData keyData = (SchemasKeyData) inputElement;
List<ColumnLineData> lineDatas = new ArrayList<ColumnLineData>();
// fist column name
ColumnLineData line = new ColumnLineData(null, keyData);
lineDatas.add(line);
for (EPropertyName property : EPropertyName.values()) {
line = new ColumnLineData(property, keyData);
lineDatas.add(line);
}
return lineDatas.toArray();
}
return null;
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class SchemasTreeDnD method addDragAndDrop.
public void addDragAndDrop() {
// drag
DragSource source = new DragSource(getTree(), operations);
source.setTransfer(transferTypes);
source.addDragListener(new TreeDragSourceEffect(getTree()));
// drop
DropTarget target = new DropTarget(getTree(), operations);
target.setTransfer(transferTypes);
target.addDropListener(new TreeDropTargetEffect(getTree()) {
private SchemasKeyData source;
@Override
public void dragEnter(DropTargetEvent event) {
super.dragEnter(event);
Widget item = event.item;
if (item != null) {
TreeItem treeItem = (TreeItem) event.item;
Object data = treeItem.getData();
if (data != null && data instanceof SchemasKeyData) {
this.source = (SchemasKeyData) data;
event.feedback = DND.FEEDBACK_EXPAND;
return;
}
}
event.detail = DND.DROP_NONE;
}
@Override
public void drop(DropTargetEvent event) {
super.drop(event);
if (event.item != null && source != null) {
TreeItem item = (TreeItem) event.item;
Object data = item.getData();
if (data != null && data instanceof SchemasKeyData) {
SchemasKeyData target = (SchemasKeyData) data;
target.addChild(source);
schemaTreeViewer.refresh();
}
}
source = null;
}
});
}
use of org.talend.designer.filemultischemas.data.SchemasKeyData in project tdi-studio-se by Talend.
the class MultiSchemasUI method fetchCodes.
@SuppressWarnings("restriction")
private void fetchCodes() {
try {
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Fetch...", IProgressMonitor.UNKNOWN);
monitor.setCanceled(false);
final CsvArray csvArray = processor.getCsvArray();
Display.getDefault().syncExec(new Runnable() {
public void run() {
SchemasKeyData schemasModel = null;
boolean checked = (csvArray != null && csvArray.getRows().size() > 0);
CSVArrayAndSeparator uniqueCsvArray = null;
if (useMultiSaparators.getSelection()) {
getMultiSchemaManager().setKeyValues(keyValuesText.getText());
}
if (multiSchemasFilePreview.getSelectColumnIndex() < 0 && multiSchemaManager.getSelectedColumnIndex() != 0) {
uniqueCsvArray = getMultiSchemaManager().retrieveCsvArrayInUniqueModel(getProcessDescription(), checked, multiSchemaManager.getSelectedColumnIndex(), useMultiSaparators.getSelection());
schemasModel = getMultiSchemaManager().createSchemasTree(uniqueCsvArray, multiSchemaManager.getSelectedColumnIndex());
} else {
uniqueCsvArray = getMultiSchemaManager().retrieveCsvArrayInUniqueModel(getProcessDescription(), checked, multiSchemasFilePreview.getSelectColumnIndex(), useMultiSaparators.getSelection());
schemasModel = getMultiSchemaManager().createSchemasTree(uniqueCsvArray, multiSchemasFilePreview.getSelectColumnIndex());
getMultiSchemaManager().setSelectedColumnIndex(multiSchemasFilePreview.getSelectColumnIndex());
schemaTreeViewer.setInput(schemasModel);
getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
clearSchemaDetail();
checkDialog();
}
}
});
monitor.done();
}
});
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
Aggregations