KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > correction > AbstractPDEMarkerResolution


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.pde.internal.ui.correction;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.core.resources.IMarker;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.pde.core.IBaseModel;
19 import org.eclipse.pde.internal.ui.util.ModelModification;
20 import org.eclipse.pde.internal.ui.util.PDEModelUtility;
21 import org.eclipse.swt.graphics.Image;
22 import org.eclipse.ui.IMarkerResolution2;
23
24 public abstract class AbstractPDEMarkerResolution implements IMarkerResolution2 {
25
26     public static final int CREATE_TYPE = 1;
27     public static final int RENAME_TYPE = 2;
28     public static final int REMOVE_TYPE = 3;
29     
30     protected int fType;
31     /**
32      * This variable will only be available after run() is called.
33      * ie. its not the be used in getImage()/getType()/getDesciption()
34      */

35     protected IResource fResource;
36
37     public AbstractPDEMarkerResolution(int type) {
38         fType = type;
39     }
40     
41     public Image getImage() {
42         return null;
43     }
44
45     public int getType() {
46         return fType;
47     }
48
49     public String JavaDoc getDescription() {
50         return getLabel();
51     }
52     
53     public void run(IMarker marker) {
54         fResource = marker.getResource();
55         ModelModification modification = new ModelModification((IFile)marker.getResource()) {
56             protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException {
57                 createChange(model);
58             }
59         };
60         PDEModelUtility.modifyModel(modification, null);
61     }
62     
63     protected abstract void createChange(IBaseModel model);
64     
65 }
66
Popular Tags