Search in sources :

Example 6 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method resetJobProblemList.

/**
     * 
     * ldong Comment method "resetJobProblemList".
     */
public static void resetJobProblemList(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
        return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
        for (Iterator<Problem> iter = Problems.getProblemList().getProblemList().iterator(); iter.hasNext(); ) {
            Problem problem = iter.next();
            if (problem instanceof TalendProblem) {
                TalendProblem routineProblem = (TalendProblem) problem;
                if (routineProblem.getJavaUnitName() != null && (routineProblem.getJavaUnitName().equals(oldLabel))) {
                    // TDI-24683:if rename the jobItem,need clear the problem view to avoid use the old
                    // problem list
                    iter.remove();
                }
            }
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) TalendProblem(org.talend.core.model.process.TalendProblem) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) Property(org.talend.core.model.properties.Property)

Example 7 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method computeCompilationUnit.

@SuppressWarnings("restriction")
private static List<Problem> computeCompilationUnit(IFile file, ProblemType type, Item item) throws CoreException {
    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
    // FIXME, only for standard job first, also for JobLaunchShortcut.launch
    if (itemType == null || !itemType.equals(ERepositoryObjectType.PROCESS)) {
        return Collections.emptyList();
    }
    List<Problem> compilProblems = new ArrayList<Problem>();
    final ICompilationUnit unit = JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput(file), false);
    if (unit != null) {
        CompilationUnit ast = unit.reconcile(ASTProvider.SHARED_AST_LEVEL, ICompilationUnit.FORCE_PROBLEM_DETECTION, null, null);
        IProblem[] problems = ast.getProblems();
        if (problems != null) {
            for (IProblem p : problems) {
                String[] arguments = p.getArguments();
                int id = p.getID();
                String message = p.getMessage();
                int sourceLineNumber = p.getSourceLineNumber();
                int sourceStart = p.getSourceStart();
                int sourceEnd = p.getSourceEnd();
                String uniName = null;
                IPath location = file.getLocation();
                if (location != null) {
                    String path = location.toString();
                    uniName = setErrorMark(path, sourceLineNumber);
                }
                ProblemStatus status = ProblemStatus.WARNING;
                if (p.isError()) {
                    status = ProblemStatus.ERROR;
                }
                TalendProblem tp = new TalendProblem(status, item, null, message, sourceLineNumber, uniName, sourceStart, sourceEnd, type);
                compilProblems.add(tp);
            }
        }
    }
    return compilProblems;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPath(org.eclipse.core.runtime.IPath) TalendProblem(org.talend.core.model.process.TalendProblem) ArrayList(java.util.ArrayList) IProblem(org.eclipse.jdt.core.compiler.IProblem) ProblemStatus(org.talend.core.model.process.Problem.ProblemStatus) FileEditorInput(org.eclipse.ui.part.FileEditorInput) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 8 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method refreshNodeStatus.

/**
     * DOC bqian Comment method "refreshNodeStatus".
     * 
     * @param node
     * @param problemList2
     */
private static void refreshNodeStatus(Node node, List<Problem> problemList) {
    boolean hasWarning = false;
    boolean hasError = false;
    boolean hasInfo = false;
    IProcess process = node.getProcess();
    if (process == null) {
        return;
    }
    for (Problem problem : problemList) {
        // if problem not instanceof TalendProblem ,node don't operate it.for bug 23088
        if (problem.getJobInfo() != null && problem.getJobInfo().getJobId() != null && problem.getJobInfo().getJobId().equals(process.getId()) && !(problem instanceof TalendProblem)) {
            if (problem.getJobInfo().getJobVersion() != null && problem.getJobInfo().getJobVersion().equals(process.getVersion())) {
                if (problem.getNodeName() == null) {
                    continue;
                } else if (problem.getNodeName() != null && (!problem.getNodeName().equals(node.getUniqueName()))) {
                    continue;
                }
                if (problem.getStatus().equals(ProblemStatus.INFO)) {
                    hasInfo = true;
                    node.addStatus(Process.INFO_STATUS);
                } else if (problem.getStatus().equals(ProblemStatus.WARNING)) {
                    hasWarning = true;
                    node.addStatus(Process.WARNING_STATUS);
                } else if (problem.getStatus().equals(ProblemStatus.ERROR)) {
                    hasError = true;
                    node.addStatus(Process.ERROR_STATUS);
                }
            }
        }
    }
    if (!hasWarning) {
        node.removeStatus(Process.WARNING_STATUS);
    }
    if (!hasError) {
        node.removeStatus(Process.ERROR_STATUS);
    }
    if (!hasInfo) {
        node.removeStatus(Process.INFO_STATUS);
    }
    node.updateStatus();
}
Also used : TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem) IProcess(org.talend.core.model.process.IProcess)

Example 9 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class ProblemsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().addPropertyChangeListener(this);
    parent.setLayout(new FillLayout());
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    final Tree tree = viewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Problem problem = (Problem) selection.getFirstElement();
            if (problem != null && problem.isConcrete()) {
                if (problem.getNodeName() != null) {
                    selectInDesigner(problem.getJobInfo(), problem.getNodeName());
                } else if (problem instanceof TalendProblem) {
                    selectInRoutine((TalendProblem) problem);
                }
            }
        }
    });
    TreeColumn column1 = new TreeColumn(tree, SWT.CENTER);
    //$NON-NLS-1$
    column1.setText(Messages.getString("ProblemsView.description"));
    column1.setWidth(400);
    column1.setAlignment(SWT.LEFT);
    column1.setResizable(true);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    column2.setText(Messages.getString("ProblemsView.resource"));
    column2.setWidth(400);
    column2.setResizable(true);
    ProblemViewProvider provider = new ProblemViewProvider();
    viewer.setLabelProvider(provider);
    viewer.setContentProvider(provider);
    resetContent();
    IActionBars actionBars = getViewSite().getActionBars();
    initMenu(actionBars.getMenuManager());
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) TalendProblem(org.talend.core.model.process.TalendProblem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Tree(org.eclipse.swt.widgets.Tree) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Problem(org.talend.core.model.process.Problem) TalendProblem(org.talend.core.model.process.TalendProblem) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IActionBars(org.eclipse.ui.IActionBars)

Example 10 with TalendProblem

use of org.talend.core.model.process.TalendProblem in project tdi-studio-se by Talend.

the class Problems method addErrorMark.

public static void addErrorMark() {
    nodeList.clear();
    String befor = "Error in the component's properties:";
    for (IProcess process : openJobs) {
        if (((Process) process).isActivate()) {
            for (INode inode : ((Process) process).getGraphicalNodes()) {
                if (inode instanceof Node) {
                    Node node = (Node) inode;
                    if (problemList.getProblemList().size() > 0) {
                        for (int i = 0; i < problemList.getProblemList().size(); i++) {
                            Problem problem = problemList.getProblemList().get(i);
                            if (node.isActivate()) {
                                if (problem.getStatus().equals(ProblemStatus.ERROR)) {
                                    if (problem instanceof TalendProblem) {
                                        TalendProblem tProblem = (TalendProblem) problem;
                                        if (!tProblem.getJavaUnitName().equals(node.getProcess().getName())) {
                                            continue;
                                        }
                                        if (tProblem.getVersion() != null) {
                                            if (!tProblem.getVersion().equals(node.getProcess().getVersion())) {
                                                continue;
                                            }
                                        }
                                        if (tProblem.getUnitName() != null && tProblem.getUnitName().equals(node.getUniqueName())) {
                                            // nodeList.add(node);
                                            if (nodeList.get(node) != null) {
                                                nodeList.get(node).append("\r\n");
                                                nodeList.get(node).append(tProblem.getDescription());
                                            } else {
                                                nodeList.put(node, new StringBuffer(tProblem.getDescription()));
                                            }
                                        } else {
                                            if (node.isErrorFlag() == true) {
                                                node.setErrorFlag(false);
                                                node.setCompareFlag(false);
                                                node.setErrorInfo(befor + tProblem.getDescription());
                                                //$NON-NLS-1$
                                                node.getNodeError().updateState("UPDATE_STATUS", false);
                                                //$NON-NLS-1$
                                                node.setErrorInfoChange("ERRORINFO", false);
                                            } else {
                                                continue;
                                            }
                                        }
                                    }
                                } else {
                                    if (node.isErrorFlag() == true) {
                                        node.setErrorFlag(false);
                                        node.setCompareFlag(false);
                                        //$NON-NLS-1$
                                        node.setErrorInfoChange("ERRORINFO", false);
                                    } else {
                                        continue;
                                    }
                                }
                            } else {
                                continue;
                            }
                        }
                    } else {
                        if (node.isErrorFlag() == true) {
                            node.setErrorFlag(false);
                            node.setCompareFlag(false);
                            node.setErrorInfo(null);
                            //$NON-NLS-1$
                            node.getNodeError().updateState("UPDATE_STATUS", false);
                            //$NON-NLS-1$
                            node.setErrorInfoChange("ERRORINFO", false);
                        } else {
                            continue;
                        }
                    }
                }
            }
        } else {
            continue;
        }
    }
    Iterator<Entry<Node, StringBuffer>> set = nodeList.entrySet().iterator();
    while (set.hasNext()) {
        Entry<Node, StringBuffer> en = set.next();
        Node node = en.getKey();
        String des = en.getValue().toString();
        if (node.isErrorFlag() == false) {
            node.setErrorFlag(true);
            node.setCompareFlag(false);
            node.setErrorInfo(befor + des);
            //$NON-NLS-1$
            node.getNodeError().updateState("UPDATE_STATUS", false);
            //$NON-NLS-1$
            node.setErrorInfoChange("ERRORINFO", true);
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) Entry(java.util.Map.Entry) TalendProblem(org.talend.core.model.process.TalendProblem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) Problem(org.talend.core.model.process.Problem) IProblem(org.eclipse.jdt.core.compiler.IProblem) TalendProblem(org.talend.core.model.process.TalendProblem) IProcess(org.talend.core.model.process.IProcess)

Aggregations

Problem (org.talend.core.model.process.Problem)10 TalendProblem (org.talend.core.model.process.TalendProblem)10 IProblem (org.eclipse.jdt.core.compiler.IProblem)6 ArrayList (java.util.ArrayList)2 IProcess (org.talend.core.model.process.IProcess)2 Property (org.talend.core.model.properties.Property)2 Entry (java.util.Map.Entry)1 IFile (org.eclipse.core.resources.IFile)1 IMarker (org.eclipse.core.resources.IMarker)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1