use of org.talend.designer.filemultischemas.data.EPropertyName in project tdi-studio-se by Talend.
the class UIManager method changeSchemasDetailView.
/**
*
* cLi Comment method "refreshSchemasDetailView".
*
* refresh schema details view by different provider.
*/
public void changeSchemasDetailView(final TreeViewer schemaDetailsViewer, boolean model) {
if (schemaDetailsViewer == null || schemaDetailsViewer.getTree().isDisposed()) {
return;
}
final Tree tree = schemaDetailsViewer.getTree();
// removed all columns
final TreeColumn[] columns = tree.getColumns();
for (TreeColumn col : columns) {
col.dispose();
}
if (columnTreeEditor != null) {
columnTreeEditor.dispose();
final Control editor = columnTreeEditor.getEditor();
if (editor != null && !editor.isDisposed()) {
editor.setVisible(false);
editor.dispose();
}
columnTreeEditor = null;
}
if (columnMouseListener != null) {
tree.removeMouseListener(columnMouseListener);
columnMouseListener = null;
}
SchemaDetailsProvider provider = null;
if (model) {
// is properties model
provider = new SchemaDetailsPropertiesProvider(this);
List<String> columnProperties = new ArrayList<String>();
List<CellEditor> cellEidors = new ArrayList<CellEditor>();
for (EPropertyName pName : EPropertyName.values()) {
columnProperties.add(pName.name());
TreeColumn pColumn = new TreeColumn(tree, SWT.NONE);
pColumn.setWidth(100);
pColumn.setText(pName.getName());
final CellEditor cellEditor;
switch(pName) {
case NAME:
case LENGTH:
case TAGLEVEL:
// case CARD:
case PATTERN:
cellEditor = new SchemaDetailsTextCellEditor(schemaDetailsViewer, pName);
break;
case KEY:
pColumn.setToolTipText("Only one column can be set as key.");
cellEditor = new SchemaDetailsCheckBoxCellEditor(tree);
break;
// break;
case TYPE:
cellEditor = new ComboBoxCellEditor(tree, MultiSchemasUtil.getTalendTypeLabel(), SWT.READ_ONLY);
break;
default:
cellEditor = null;
}
if (cellEditor != null) {
cellEidors.add(cellEditor);
}
}
schemaDetailsViewer.setColumnProperties(columnProperties.toArray(new String[0]));
schemaDetailsViewer.setCellEditors(cellEidors.toArray(new CellEditor[0]));
schemaDetailsViewer.setCellModifier(new SchemaDetailsPropertiesCellModifier(schemaDetailsViewer, this));
// set sorter
TreeColumn sorterColumn = tree.getColumn(0);
sorterColumn.addListener(SWT.Selection, new SchemaDetailsViewerSorterListener(schemaDetailsViewer));
tree.setSortColumn(sorterColumn);
tree.setSortDirection(SWT.UP);
schemaDetailsViewer.setSorter(new SchemaDetailsViewerSorter(schemaDetailsViewer, sorterColumn, tree.getSortDirection() == SWT.UP));
} else {
// is column model
provider = new SchemaDetailsColumnsProvider(this);
// first columm is fixed.
TreeColumn propertyColumn = new TreeColumn(tree, SWT.NONE);
propertyColumn.setWidth(80);
propertyColumn.setResizable(false);
//
columnTreeEditor = new TreeEditor(tree);
columnTreeEditor.horizontalAlignment = SWT.LEFT;
columnTreeEditor.grabHorizontal = true;
columnMouseListener = new SchemaDetailsColumnMouseAdapter(schemaDetailsViewer, columnTreeEditor, this);
tree.addMouseListener(columnMouseListener);
}
schemaDetailsViewer.setContentProvider(provider);
schemaDetailsViewer.setLabelProvider(provider);
//
}
use of org.talend.designer.filemultischemas.data.EPropertyName 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.EPropertyName 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.EPropertyName 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.EPropertyName in project tdi-studio-se by Talend.
the class SchemaDetailsColumnsProvider method getBackground.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
*/
public Color getBackground(Object element, int columnIndex) {
if (element instanceof ColumnLineData) {
ColumnLineData lineData = (ColumnLineData) element;
final EPropertyName property = lineData.getProperty();
if (UIManager.isFirstForColumnModel(property)) {
return Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}
if (columnIndex == 0) {
final int index = EPropertyName.indexOf(property);
if (index > -1 && index % 2 == 0) {
return Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
} else {
return Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}
}
}
return null;
}
Aggregations