Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'archive/working/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java')
-rw-r--r--archive/working/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java166
1 files changed, 0 insertions, 166 deletions
diff --git a/archive/working/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java b/archive/working/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java
deleted file mode 100644
index d0603f09e..000000000
--- a/archive/working/apitools/org.eclipse.wtp.releng.tools.component.ui/src/org/eclipse/wtp/releng/tools/component/ui/internal/job/AbstractModifyMarkersJob.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
-  *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.wtp.releng.tools.component.ui.internal.job;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wtp.releng.tools.component.ui.ComponentManager;
-import org.eclipse.wtp.releng.tools.component.use.ClassUse;
-import org.eclipse.wtp.releng.tools.component.use.FieldUse;
-import org.eclipse.wtp.releng.tools.component.use.MethodUse;
-
-public abstract class AbstractModifyMarkersJob extends Job
-{
- public AbstractModifyMarkersJob(String name)
- {
- super(name);
- }
-
- public void createClassViolationMarker(IResource javaSource, ClassUse classUse) throws CoreException
- {
- String className = classUse.getName();
- ComponentManager manager = ComponentManager.getManager();
- if (classUse.getReference() != null && classUse.isReference())
- {
- int methodRefCount = classUse.sizeMethodUses();
- int fieldRefCount = classUse.sizeFieldUses();
- if (methodRefCount > 0 || fieldRefCount > 0)
- {
- if (methodRefCount > 0)
- {
- List methodUses = classUse.getMethodUses();
- for (Iterator it = methodUses.iterator(); it.hasNext();)
- createMethodViolationMarker(javaSource, classUse, (MethodUse)it.next());
- }
- if (fieldRefCount > 0)
- {
- List fieldUses = classUse.getFieldUses();
- for (Iterator it = fieldUses.iterator(); it.hasNext();)
- createFieldViolationMarker(javaSource, classUse, (FieldUse)it.next());
- }
- }
- else
- {
- createMarker(javaSource, manager.getMessage("VIOLATION_CLASS_REF", new String[] {className}), -1);
- }
- }
- if (classUse.getSubclass() != null && classUse.isSubclass())
- createMarker(javaSource, manager.getMessage("VIOLATION_CLASS_SUBCLASS", new String[] {className}), -1);
- if (classUse.getImplement() != null && classUse.isImplement())
- createMarker(javaSource, manager.getMessage("VIOLATION_CLASS_IMPLEMENT", new String[] {className}), -1);
- if (classUse.getInstantiate() != null && classUse.isInstantiate())
- {
- if (classUse.sizeLines() > 0)
- createMarker(javaSource, manager.getMessage("VIOLATION_CLASS_INSTANTIATE", new String[] {className}), classUse.getLines());
- else
- createMarker(javaSource, manager.getMessage("VIOLATION_CLASS_INSTANTIATE", new String[] {className}), -1);
- }
- }
-
- private void createMethodViolationMarker(IResource javaSource, ClassUse classUse, MethodUse methodUse) throws CoreException
- {
- String className = classUse.getName();
- String methodName = methodUse.getName();
- ComponentManager manager = ComponentManager.getManager();
- if (methodUse.sizeLines() > 0)
- createMarker(javaSource, manager.getMessage("VIOLATION_METHOD_REF", new String[] {methodName, className}), methodUse.getLines());
- else
- createMarker(javaSource, manager.getMessage("VIOLATION_METHOD_REF", new String[] {methodName, className}), -1);
- }
-
- private void createFieldViolationMarker(IResource javaSource, ClassUse classUse, FieldUse fieldUse) throws CoreException
- {
- String className = classUse.getName();
- String fieldName = fieldUse.getName();
- ComponentManager manager = ComponentManager.getManager();
- if (fieldUse.sizeLines() > 0)
- createMarker(javaSource, manager.getMessage("VIOLATION_FIELD_REF", new String[] {fieldName, className}), fieldUse.getLines());
- else
- createMarker(javaSource, manager.getMessage("VIOLATION_FIELD_REF", new String[] {fieldName, className}), -1);
- }
-
- private void createMarker(IResource resource, String message, List lines) throws CoreException
- {
- for (Iterator it = lines.iterator(); it.hasNext();)
- {
- try
- {
- createMarker(resource, message, Integer.parseInt((String)it.next()));
- }
- catch (NumberFormatException e)
- {
- createMarker(resource, message, -1);
- }
- }
- }
-
- private void createMarker(IResource resource, String message, int line) throws CoreException
- {
- IJobManager jobManager = Platform.getJobManager();
- try
- {
- jobManager.beginRule(resource, new NullProgressMonitor());
- }
- finally
- {
- jobManager.endRule(resource);
- }
- try
- {
- IMarker marker = resource.createMarker(IMarker.PROBLEM);
- marker.setAttribute(ComponentManager.MARKER_COMPONENT_VIOLATION, true);
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
- marker.setAttribute(IMarker.MESSAGE, message);
- if (line != -1)
- marker.setAttribute(IMarker.LINE_NUMBER, line);
- }
- catch (Throwable t)
- {
- // do nothing here
- }
- }
-
- public void deleteViolationMarksers(IResource res) throws CoreException
- {
- IMarker[] markers = res.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++)
- {
- if (markers[i].getAttribute(ComponentManager.MARKER_COMPONENT_VIOLATION) != null)
- {
- IJobManager jobManager = Platform.getJobManager();
- try
- {
- jobManager.beginRule(res, new NullProgressMonitor());
- }
- finally
- {
- jobManager.endRule(res);
- }
- try
- {
- markers[i].delete();
- }
- catch (Throwable t)
- {
- // do nothing here
- }
- }
- }
- }
-}

Back to the top