Search in sources :

Example 1 with AnalysisItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput in project tdq-studio-se by Talend.

the class DataFilterDND method installDND.

public static void installDND(final Text targetControl) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
    final CommonViewer commonViewer = findView.getCommonViewer();
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] { transfer };
    DropTarget dropTarget = new DropTarget(targetControl, operations);
    dropTarget.setTransfer(transfers);
    dropTarget.addDropListener(new DropTargetAdapter() {

        @Override
        public void dragEnter(DropTargetEvent event) {
            Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
            if (!(obj instanceof DBColumnRepNode)) {
                event.detail = DND.DROP_NONE;
            } else {
                event.detail = DND.DROP_MOVE;
                event.feedback = DND.FEEDBACK_INSERT_AFTER;
            }
        }

        @Override
        public void dropAccept(DropTargetEvent event) {
        // do nothing until now
        }

        @Override
        public void drop(DropTargetEvent event) {
            if (event.detail != DND.DROP_NONE) {
                IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
                if (!selection.isEmpty()) {
                    List list = selection.toList();
                    IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
                    if (currentActiveEditor instanceof AnalysisEditor) {
                        AnalysisEditor editor = (AnalysisEditor) currentActiveEditor;
                        AnalysisItemEditorInput input = (AnalysisItemEditorInput) editor.getEditorInput();
                        for (Object object : list) {
                            DBColumnRepNode node = (DBColumnRepNode) object;
                            DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage((Analysis) input.getModel());
                            MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
                            String name = columnObject.getTdColumn().getName();
                            targetControl.insert(language.quote(name));
                            // Focus text.
                            targetControl.forceFocus();
                        }
                    }
                }
            }
        }
    });
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Analysis(org.talend.dataquality.analysis.Analysis) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DropTarget(org.eclipse.swt.dnd.DropTarget) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 2 with AnalysisItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput in project tdq-studio-se by Talend.

the class TableAnalysisWizard method openEditor.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.wizard.analysis.AbstractAnalysisWizard#openEditor(org.talend.repository.model.IRepositoryNode
     * )
     */
@Override
public void openEditor(IRepositoryNode repNode) {
    AnalysisItemEditorInput itemEditorInput = new AnalysisItemEditorInput(repNode);
    CorePlugin.getDefault().openEditor(itemEditorInput, AnalysisEditor.class.getName());
}
Also used : AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 3 with AnalysisItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput in project tdq-studio-se by Talend.

the class AbstractAnalysisWizard method openEditor.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.AbstractWizard#openEditor(org.talend.repository.model.IRepositoryNode)
     */
@Override
public void openEditor(IRepositoryNode repNode) {
    String editorID = null;
    AnalysisItemEditorInput analysisEditorInput = new AnalysisItemEditorInput(repNode);
    IRepositoryNode connectionRepNode = getParameter().getConnectionRepNode();
    analysisEditorInput.setConnectionNode(connectionRepNode);
    // add support for match analysis editor
    Analysis analysis = (Analysis) analysisEditorInput.getModel();
    if (analysis.getParameters() != null && analysis.getParameters().getAnalysisType().equals(AnalysisType.MATCH_ANALYSIS)) {
        editorID = MatchAnalysisEditor.class.getName();
    } else {
        editorID = AnalysisEditor.class.getName();
    }
    CorePlugin.getDefault().openEditor(analysisEditorInput, editorID);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) MatchAnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.MatchAnalysisEditor) MatchAnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.MatchAnalysisEditor)

Example 4 with AnalysisItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput in project tdq-studio-se by Talend.

the class WorkbenchUtils method getIEditorReference.

/**
 * Get Editors which is is same as editorID --used for the analysis editor only
 *
 * @param editorID
 * @param analysisName
 * @return
 */
private static List<IEditorReference> getIEditorReference(String editorID, String analysisName) {
    List<IEditorReference> returnCode = new ArrayList<IEditorReference>();
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editors = activePage.getEditorReferences();
    if (editors != null) {
        for (IEditorReference editorRef : editors) {
            if (editorRef.getId().equals(editorID)) {
                IEditorInput editorInput;
                try {
                    editorInput = editorRef.getEditorInput();
                    if (editorInput instanceof AbstractItemEditorInput) {
                        AnalysisItemEditorInput anaItemEditorInput = (AnalysisItemEditorInput) editorInput;
                        // if not pointed which analysis, add all opened ones.
                        if (StringUtils.isEmpty(analysisName) || StringUtils.equals(analysisName, anaItemEditorInput.getModel().getName())) {
                            returnCode.add(editorRef);
                        }
                    }
                } catch (PartInitException e) {
                    log.error(e, e);
                }
            }
        }
    }
    return returnCode;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) AbstractItemEditorInput(org.talend.dataprofiler.core.ui.editor.AbstractItemEditorInput) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 5 with AnalysisItemEditorInput

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput in project tdq-studio-se by Talend.

the class TdqContextView method setCompositeReadonly.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.context.view.AbstractContextView#setCompositeReadonly(org.eclipse.ui.IEditorInput)
     */
@Override
protected void setCompositeReadonly(IEditorInput editorInput) {
    if (editorInput != null) {
        if (editorInput instanceof ReportItemEditorInput) {
            ReportItemEditorInput reportInput = (ReportItemEditorInput) editorInput;
            boolean readOnly = reportInput.getModel() == null;
            contextComposite.setReadOnly(readOnly);
        } else if (editorInput instanceof AnalysisItemEditorInput) {
            AnalysisItemEditorInput analysisInput = (AnalysisItemEditorInput) editorInput;
            boolean readOnly = analysisInput.getModel() == null;
            contextComposite.setReadOnly(readOnly);
        }
    }
}
Also used : AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) ReportItemEditorInput(org.talend.dataprofiler.core.ui.editor.report.ReportItemEditorInput)

Aggregations

AnalysisItemEditorInput (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput)9 AnalysisEditor (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)6 Analysis (org.talend.dataquality.analysis.Analysis)4 IEditorInput (org.eclipse.ui.IEditorInput)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 IEditorPart (org.eclipse.ui.IEditorPart)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 TdColumn (org.talend.cwm.relational.TdColumn)2 ReportItemEditorInput (org.talend.dataprofiler.core.ui.editor.report.ReportItemEditorInput)2 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IFolder (org.eclipse.core.resources.IFolder)1 IPath (org.eclipse.core.runtime.IPath)1 EList (org.eclipse.emf.common.util.EList)1 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 DropTarget (org.eclipse.swt.dnd.DropTarget)1 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)1