KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > core > LogicalStructureProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.debug.core.DebugPlugin;
18 import org.eclipse.debug.core.ILogicalStructureProvider;
19 import org.eclipse.debug.core.ILogicalStructureType;
20 import org.eclipse.debug.core.model.IValue;
21
22 /**
23  * Manage logical structure provider extensions
24  */

25 public class LogicalStructureProvider {
26
27     private IConfigurationElement fConfigurationElement;
28     
29     private String JavaDoc fModelIdentifier;
30
31     private ILogicalStructureProvider fDelegate;
32
33     public LogicalStructureProvider(IConfigurationElement element) throws CoreException {
34         fConfigurationElement= element;
35         fModelIdentifier= fConfigurationElement.getAttribute("modelIdentifier"); //$NON-NLS-1$
36
if (fModelIdentifier == null) {
37             throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, DebugCoreMessages.LogicalStructureProvider_0, null));
38         }
39         String JavaDoc className= fConfigurationElement.getAttribute("class"); //$NON-NLS-1$
40
if (className == null) {
41             throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, DebugCoreMessages.LogicalStructureProvider_1, null));
42         }
43     }
44     
45     /**
46      * Return the logical structure type able to provide a logical structure for
47      * the given value.
48      *
49      * @param value value for which structure types are requested
50      * @return logical structure types
51      */

52     public ILogicalStructureType[] getLogicalStructures(IValue value) {
53         if (fModelIdentifier.equals(value.getModelIdentifier())) {
54             return getDelegate().getLogicalStructureTypes(value);
55         }
56         return new ILogicalStructureType[0];
57     }
58
59     /**
60      * Return the ILogicalStructureProvider for this extension.
61      */

62     protected ILogicalStructureProvider getDelegate() {
63         if (fDelegate == null) {
64             try {
65                 fDelegate = (ILogicalStructureProvider) fConfigurationElement.createExecutableExtension("class"); //$NON-NLS-1$
66
} catch (CoreException e) {
67                 DebugPlugin.log(e);
68             }
69         }
70         return fDelegate;
71     }
72
73 }
74
Popular Tags