KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > core > sourcelookup > SourcePathComputer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.internal.core.sourcelookup;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.debug.core.DebugPlugin;
17 import org.eclipse.debug.core.ILaunchConfiguration;
18 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
19 import org.eclipse.debug.core.sourcelookup.ISourcePathComputer;
20 import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
21
22 /**
23  * Proxy to contributed source path computer extension.
24  */

25 public class SourcePathComputer implements ISourcePathComputer {
26     
27     // lazily instantiated delegate
28
private ISourcePathComputerDelegate fDelegate = null;
29     
30     // extension definition
31
private IConfigurationElement fElement = null;
32     
33     /**
34      * Constructs a source path computer on the given extension.
35      *
36      * @param element extension definition
37      */

38     public SourcePathComputer(IConfigurationElement element) {
39         fElement = element;
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputer#getId()
44      */

45     public String JavaDoc getId() {
46         return fElement.getAttribute("id"); //$NON-NLS-1$
47
}
48     
49     /**
50      * Lazily instantiates and returns the underlying source container type.
51      *
52      * @exception CoreException if unable to instantiate
53      */

54     private ISourcePathComputerDelegate getDelegate() throws CoreException {
55         if (fDelegate == null) {
56             fDelegate = (ISourcePathComputerDelegate) fElement.createExecutableExtension("class"); //$NON-NLS-1$
57
}
58         return fDelegate;
59     }
60
61     /* (non-Javadoc)
62      * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
63      */

64     public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) {
65         try {
66             return getDelegate().computeSourceContainers(configuration, monitor);
67         } catch (CoreException e) {
68             DebugPlugin.log(e);
69         }
70         return new ISourceContainer[0];
71     }
72 }
73
Popular Tags