KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > StructureCreatorDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.compare.internal;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15
16 import org.eclipse.compare.structuremergeviewer.IStructureCreator;
17
18 /**
19  * A factory proxy for creating a StructureCreator.
20  */

21 public class StructureCreatorDescriptor {
22     
23     private final static String JavaDoc CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
24
private final static String JavaDoc EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
25

26     private IConfigurationElement fElement;
27     
28     /*
29      * Creates a new sorter node with the given configuration element.
30      */

31     public StructureCreatorDescriptor(IConfigurationElement element) {
32         fElement= element;
33     }
34
35     /*
36      * Creates a new sorter from this node.
37      */

38     public IStructureCreator createStructureCreator() {
39         try {
40             return (IStructureCreator)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
41         } catch (CoreException ex) {
42             CompareUIPlugin.log(ex.getStatus());
43             //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
44
return null;
45         } catch (ClassCastException JavaDoc ex) {
46             //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
47
return null;
48         }
49     }
50
51     /*
52      * Returns the structure creator's extensions.
53      */

54     public String JavaDoc getExtension() {
55         return fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
56     }
57 }
58
Popular Tags