Search in sources :

Example 1 with SchemasKeyData

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;
}
Also used : SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 2 with SchemasKeyData

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;
}
Also used : SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 3 with SchemasKeyData

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;
}
Also used : EPropertyName(org.talend.designer.filemultischemas.data.EPropertyName) ArrayList(java.util.ArrayList) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 4 with SchemasKeyData

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;
        }
    });
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) Widget(org.eclipse.swt.widgets.Widget) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DragSource(org.eclipse.swt.dnd.DragSource) DropTarget(org.eclipse.swt.dnd.DropTarget) TreeDragSourceEffect(org.eclipse.swt.dnd.TreeDragSourceEffect) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 5 with SchemasKeyData

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);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CsvArray(org.talend.core.utils.CsvArray) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) CSVArrayAndSeparator(org.talend.designer.filemultischemas.data.CSVArrayAndSeparator) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

SchemasKeyData (org.talend.designer.filemultischemas.data.SchemasKeyData)21 MultiMetadataColumn (org.talend.designer.filemultischemas.data.MultiMetadataColumn)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 ArrayList (java.util.ArrayList)5 ISelection (org.eclipse.jface.viewers.ISelection)3 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 KeyAdapter (org.eclipse.swt.events.KeyAdapter)2 KeyEvent (org.eclipse.swt.events.KeyEvent)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Tree (org.eclipse.swt.widgets.Tree)2 TreeColumn (org.eclipse.swt.widgets.TreeColumn)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 CommandStackForComposite (org.talend.commons.ui.command.CommandStackForComposite)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1