Search in sources :

Example 1 with SchemaDetailsPropertiesProvider

use of org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesProvider 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);
//
}
Also used : SchemaDetailsTextCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsTextCellEditor) SchemaDetailsPropertiesCellModifier(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesCellModifier) SchemaDetailsColumnsProvider(org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnsProvider) SchemaDetailsPropertiesProvider(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesProvider) TreeEditor(org.eclipse.swt.custom.TreeEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SchemaDetailsTextCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsTextCellEditor) SchemaDetailsCheckBoxCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsCheckBoxCellEditor) ArrayList(java.util.ArrayList) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SchemaDetailsViewerSorterListener(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorterListener) SchemaDetailsColumnMouseAdapter(org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnMouseAdapter) SchemaDetailsCheckBoxCellEditor(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsCheckBoxCellEditor) Control(org.eclipse.swt.widgets.Control) SchemaDetailsViewerSorter(org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorter) EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) SchemaDetailsProvider(org.talend.designer.filemultischemas.ui.provider.SchemaDetailsProvider)

Aggregations

ArrayList (java.util.ArrayList)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TreeEditor (org.eclipse.swt.custom.TreeEditor)1 Control (org.eclipse.swt.widgets.Control)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 EPropertyName (org.talend.designer.filemultischemas.data.EPropertyName)1 SchemaDetailsProvider (org.talend.designer.filemultischemas.ui.provider.SchemaDetailsProvider)1 SchemaDetailsColumnMouseAdapter (org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnMouseAdapter)1 SchemaDetailsColumnsProvider (org.talend.designer.filemultischemas.ui.provider.column.SchemaDetailsColumnsProvider)1 SchemaDetailsCheckBoxCellEditor (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsCheckBoxCellEditor)1 SchemaDetailsPropertiesCellModifier (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesCellModifier)1 SchemaDetailsPropertiesProvider (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsPropertiesProvider)1 SchemaDetailsTextCellEditor (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsTextCellEditor)1 SchemaDetailsViewerSorter (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorter)1 SchemaDetailsViewerSorterListener (org.talend.designer.filemultischemas.ui.provider.property.SchemaDetailsViewerSorterListener)1