KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > core > sourcelookup > containers > AbstractSourceContainer


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.debug.core.sourcelookup.containers;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.debug.core.DebugPlugin;
18 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
19 import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
20 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
21
22 /**
23  * Common function for source containers.
24  * <p>
25  * Clients implementing source containers should subclass this class.
26  * </p>
27  * @since 3.0
28  */

29 public abstract class AbstractSourceContainer extends PlatformObject implements ISourceContainer {
30     
31     public static final Object JavaDoc[] EMPTY = new Object JavaDoc[0];
32     
33     private ISourceLookupDirector fDirector;
34     
35     /**
36      * Throws an error exception with the given message and underlying exception.
37      *
38      * @param message error message
39      * @param exception underlying exception, or <code>null</code>
40      * @throws CoreException
41      */

42     protected void abort(String JavaDoc message, Throwable JavaDoc exception) throws CoreException {
43         IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, message, exception);
44         throw new CoreException(status);
45     }
46     
47     /**
48      * Throws a warning exception with the given message and underlying exception.
49      *
50      * @param message error message
51      * @param exception underlying exception, or <code>null</code>
52      * @throws CoreException
53      * @since 3.3
54      */

55     protected void warn(String JavaDoc message, Throwable JavaDoc exception) throws CoreException {
56         IStatus status = new Status(IStatus.WARNING, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, message, exception);
57         throw new CoreException(status);
58     }
59     
60     /* (non-Javadoc)
61      *
62      * By default, do nothing. Subclasses should override as required.
63      *
64      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#dispose()
65      */

66     public void dispose() {
67         fDirector = null;
68     }
69     
70     /* (non-Javadoc)
71      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getSourceContainers()
72      */

73     public ISourceContainer[] getSourceContainers() throws CoreException {
74         return new ISourceContainer[0];
75     }
76
77     /* (non-Javadoc)
78      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#isComposite()
79      */

80     public boolean isComposite() {
81         return false;
82     }
83     
84     /* (non-Javadoc)
85      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#init(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
86      */

87     public void init(ISourceLookupDirector director) {
88         fDirector = director;
89     }
90     
91     /**
92      * Returns the source lookup director this source container registered
93      * in, or <code>null</code> if none.
94      *
95      * @return the source lookup director this source container registered
96      * in, or <code>null</code> if none
97      */

98     protected ISourceLookupDirector getDirector() {
99         return fDirector;
100     }
101     
102     /**
103      * Returns whether this container's source lookup director is configured
104      * to search for duplicate source elements.
105      *
106      * @return whether this container's source lookup director is configured
107      * to search for duplicate source elements
108      */

109     protected boolean isFindDuplicates() {
110         if (getDirector() != null) {
111             return getDirector().isFindDuplicates();
112         }
113         return false;
114     }
115     
116     /**
117      * Returns the source container type identified by the given id,
118      * or <code>null</code> if none.
119      *
120      * @param id source container type identifier
121      * @return source container type or <code>null</code>
122      */

123     protected ISourceContainerType getSourceContainerType(String JavaDoc id) {
124         return DebugPlugin.getDefault().getLaunchManager().getSourceContainerType(id);
125     }
126 }
127
Popular Tags