Search in sources :

Example 1 with AnalysisEditor

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

the class CommonEditorPartListener method partOpened.

@Override
public void partOpened(IWorkbenchPart part) {
    // Added TDQ-7531 20130718 add lock support for sql source file/jrxml file
    if (part.getClass().getName().equals(SqlExplorerUtils.SQLEDITOR_ID)) {
        lockFile(part);
        super.partOpened(part);
        return;
    }
    // MOD mzhao bug 12497 Firstly check if the part is TDQ common form editor.
    if (!isCommonFormEditor(part)) {
        return;
    }
    Item item = getItem((IEditorPart) part);
    if (item == null) {
        return;
    }
    CorePlugin.getDefault().refreshWorkSpace();
    // (when remote and ask user: when the user select unlock should be also not editable)
    if (!ProxyRepositoryFactory.getInstance().isEditableAndLockIfPossible(item)) {
        // MOD yyi 2010-11-29 15686: Make the editor readonly when the login user has no sufficient previlege.
        lockCommonFormEditor(part);
        WorkspaceResourceHelper.refreshItem(item);
        return;
    }
    WorkspaceResourceHelper.refreshItem(item);
    if (part instanceof AnalysisEditor) {
        ((AnalysisEditor) part).getMasterPage().autoRefreshPreviewData();
    }
    super.partOpened(part);
}
Also used : Item(org.talend.core.model.properties.Item) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 2 with AnalysisEditor

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

the class UDIUtils method createIndicatorUnit.

public static IndicatorUnit[] createIndicatorUnit(IndicatorDefinition udid, ModelElementIndicator meIndicator, Analysis analysis) throws Throwable {
    List<IndicatorUnit> addIndicatorUnits = new ArrayList<IndicatorUnit>();
    // can't add the same user defined indicator
    for (Indicator indicator : meIndicator.getIndicators()) {
        // MOD xwang 2011-08-01 bug TDQ-2730
        if (udid.getName().equals(indicator.getName()) && indicator instanceof UserDefIndicator) {
            // $NON-NLS-1$
            MessageUI.openWarning(DefaultMessagesImpl.getString("UDIUtils.UDISelected", udid.getName()));
            return null;
        }
    }
    Indicator udi = UDIFactory.createUserDefIndicator(udid);
    udi.setIndicatorDefinition(udid);
    // MOD mzhao feature 11128, Handle Java User Defined Indicator.
    Indicator judi = UDIHelper.adaptToJavaUDI(udi);
    if (judi != null) {
        udi = judi;
    }
    IEditorPart activeEditor = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor == null || !(activeEditor instanceof AnalysisEditor)) {
        return null;
    }
    ExecutionLanguage executionLanguage = ((AnalysisEditor) activeEditor).getUIExecuteEngin();
    boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
    DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis, executionLanguage);
    Expression returnExpression = dbmsLanguage.getExpression(udi);
    String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
    // MOD qiongli 2013.5.22 TDQ-7282.if don't find a valid java expression for JUDI,should also pop this dialog.
    boolean finddExpression = true;
    if (isJavaEngin && judi == null || !isJavaEngin && returnExpression == null) {
        finddExpression = false;
    }
    if (!finddExpression) {
        // open the editor
        boolean openUDI = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("UDIUtils.NoExpression", executeType));
        if (openUDI) {
            RepositoryNode node = RepositoryNodeHelper.recursiveFind(udid);
            if (RepositoryNodeHelper.canOpenEditor(node)) {
                new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
            }
        }
        return null;
    }
    // dbmsLanguage
    IndicatorParameters parameters = udi.getParameters();
    if (parameters == null) {
        parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
        udi.setParameters(parameters);
    }
    Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
    if (indicatorValidDomain == null) {
        // $NON-NLS-1$
        indicatorValidDomain = DomainHelper.createDomain("JAVA_UDI_PARAMETERS");
        parameters.setIndicatorValidDomain(indicatorValidDomain);
    }
    List<IndicatorDefinitionParameter> indicatorDefs = udid.getIndicatorDefinitionParameter();
    for (IndicatorDefinitionParameter idp : indicatorDefs) {
        JavaUDIIndicatorParameter judip = DomainHelper.createJavaUDIIndicatorParameter(idp.getKey(), idp.getValue());
        indicatorValidDomain.getJavaUDIIndicatorParameter().add(judip);
    }
    IndicatorEnum indicatorType = IndicatorEnum.findIndicatorEnum(udi.eClass());
    addIndicatorUnits.add(meIndicator.addSpecialIndicator(indicatorType, udi));
    DependenciesHandler.getInstance().setUsageDependencyOn(analysis, udid);
    return addIndicatorUnits.toArray(new IndicatorUnit[addIndicatorUnits.size()]);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IndicatorEnum(org.talend.dq.nodes.indicator.type.IndicatorEnum) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ArrayList(java.util.ArrayList) JavaUDIIndicatorParameter(org.talend.dataquality.domain.JavaUDIIndicatorParameter) ExecutionLanguage(org.talend.dataquality.analysis.ExecutionLanguage) IEditorPart(org.eclipse.ui.IEditorPart) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) TdExpression(org.talend.cwm.relational.TdExpression) Expression(orgomg.cwm.objectmodel.core.Expression) IndicatorDefinitionParameter(org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) Domain(org.talend.dataquality.domain.Domain) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator)

Example 3 with AnalysisEditor

use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor 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 4 with AnalysisEditor

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

the class CorePlugin method getCurrentOpenAnalysisEditor.

public List<AnalysisEditor> getCurrentOpenAnalysisEditor() {
    IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorReferences = activePage.getEditorReferences();
    List<AnalysisEditor> result = new ArrayList<AnalysisEditor>();
    for (IEditorReference iEditorReference : editorReferences) {
        IEditorPart editor = iEditorReference.getEditor(false);
        if (editor instanceof AnalysisEditor) {
            result.add((AnalysisEditor) editor);
        }
    }
    return result;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)

Example 5 with AnalysisEditor

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

the class MatchAnalysisAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    PackagesAnalyisParameter packaFilterParameter = new PackagesAnalyisParameter();
    if (needselection) {
        IRepositoryNode firstElement = (RepositoryNode) this.selection.getFirstElement();
        IRepositoryViewObject viewObject = firstElement.getObject();
        Item item = viewObject.getProperty().getItem();
        ConnectionItem connectionItem = (ConnectionItem) item;
        Connection connection = connectionItem.getConnection();
        IRepositoryNode repositoryNode = RepositoryNodeHelper.recursiveFind(connection);
        packaFilterParameter.setConnectionRepNode(repositoryNode);
    }
    if (openMatchAnalysisDialog(packaFilterParameter) == Window.OK) {
        AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (editor != null) {
            MatchAnalysisDetailsPage page = (MatchAnalysisDetailsPage) editor.getMasterPage();
            IRepositoryNode[] columns = getColumns();
            if (this.needselection && columns.length > 0) {
                page.updateAnalyzeDataLabel(columns[0]);
                page.setSelectedNodes(columns);
            }
            page.doSave(null);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IRepositoryNode(org.talend.repository.model.IRepositoryNode) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) MatchAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.MatchAnalysisDetailsPage)

Aggregations

AnalysisEditor (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)13 IEditorPart (org.eclipse.ui.IEditorPart)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 RepositoryNode (org.talend.repository.model.RepositoryNode)6 ArrayList (java.util.ArrayList)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 AbstractAnalysisMetadataPage (org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage)3 ColumnAnalysisDetailsPage (org.talend.dataprofiler.core.ui.editor.analysis.ColumnAnalysisDetailsPage)3 ColumnSetAnalysisDetailsPage (org.talend.dataprofiler.core.ui.editor.analysis.ColumnSetAnalysisDetailsPage)3 Indicator (org.talend.dataquality.indicators.Indicator)3 DbmsLanguage (org.talend.dq.dbms.DbmsLanguage)3 Iterator (java.util.Iterator)2 List (java.util.List)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 OpenItemEditorAction (org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction)2 AnalysisItemEditorInput (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput)2