use of org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnMouseAdapter 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);
//
}
Aggregations