KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > CancelableProblemFactory


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.OperationCanceledException;
15 import org.eclipse.jdt.core.compiler.CategorizedProblem;
16 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
17 import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
18
19
20 public class CancelableProblemFactory extends DefaultProblemFactory {
21     public IProgressMonitor monitor;
22
23     public CancelableProblemFactory(IProgressMonitor monitor) {
24         super();
25         this.monitor = monitor;
26     }
27
28     public CategorizedProblem createProblem(char[] originatingFileName, int problemId, String JavaDoc[] problemArguments, String JavaDoc[] messageArguments, int severity, int startPosition, int endPosition, int lineNumber, int columnNumber) {
29         if (this.monitor != null && this.monitor.isCanceled())
30             throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
31         return super.createProblem(originatingFileName, problemId, problemArguments, messageArguments, severity, startPosition, endPosition, lineNumber, columnNumber);
32     }
33 }
34
Popular Tags