KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > SchemaMarkerResolutionGenerator


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

11 package org.eclipse.pde.internal.ui.search;
12
13 import org.eclipse.core.resources.IMarker;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.pde.internal.core.PDECore;
16 import org.eclipse.pde.internal.core.ischema.ISchema;
17 import org.eclipse.pde.internal.ui.PDEPlugin;
18 import org.eclipse.ui.*;
19
20 /**
21  * Insert the type's description here.
22  * @see IMarkerResolutionGenerator
23  */

24 public class SchemaMarkerResolutionGenerator implements IMarkerResolutionGenerator {
25     /**
26      * The constructor.
27      */

28     private IMarkerResolution [] resolutions = new IMarkerResolution[1];
29
30     class SchemaMarkerResolution implements IMarkerResolution {
31         private ShowDescriptionAction action;
32         public String JavaDoc getLabel() {
33             return PDEPlugin.getResourceString("SchemaMarkerResolutionGenerator.label"); //$NON-NLS-1$
34
}
35         
36         public void run(IMarker marker) {
37             try {
38                 String JavaDoc point = (String JavaDoc)marker.getAttribute("point"); //$NON-NLS-1$
39
if (point==null) return;
40                 ISchema schema = PDECore.getDefault().getSchemaRegistry().getSchema(point);
41
42                 if (action==null)
43                     action = new ShowDescriptionAction(schema);
44                 else
45                     action.setSchema(schema);
46                 action.run();
47             }
48             catch (CoreException e) {
49                 PDEPlugin.logException(e);
50             }
51         }
52     }
53     public SchemaMarkerResolutionGenerator() {
54         resolutions[0] = new SchemaMarkerResolution();
55     }
56
57     /**
58      * Insert the method's description here.
59      * @see IMarkerResolutionGenerator#getResolutions
60      */

61     public IMarkerResolution [] getResolutions(IMarker marker) {
62         return resolutions;
63     }
64 }
65
Popular Tags