1 /*******************************************************************************
2 * Copyright (c) 2013 Obeo.
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
9 * Obeo - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.emf
.compare
.rcp
.internal
.adapterfactory
;
13 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
14 import org
.eclipse
.emf
.common
.notify
.AdapterFactory
;
15 import org
.eclipse
.emf
.compare
.internal
.adapterfactory
.RankedAdapterFactoryDescriptor
;
16 import org
.eclipse
.emf
.compare
.rcp
.extension
.PluginClassDescriptor
;
19 * Default implementation of {@link RankedAdapterFactoryDescriptor}.
21 * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
23 public class RankedAdapterFactoryDescriptorImpl
extends PluginClassDescriptor
<AdapterFactory
> implements RankedAdapterFactoryDescriptor
{
25 /** Optional attribute in extension point. */
26 private static final String ATT_OPTIONAL
= "optional"; //$NON-NLS-1$
28 /** Label attribute in extension point. */
29 private static final String ATT_LABEL
= "label"; //$NON-NLS-1$
31 /** Description attribute in extension point. */
32 private static final String ATT_DESCRIPTION
= "description"; //$NON-NLS-1$
34 /** The wrapped adapter factory. */
35 private AdapterFactory factory
;
37 /** Ranking of this adapter factory. */
38 private final int ranking
;
40 /** Holds the id of this descriptor. */
41 private final String id
;
44 * Creates a descriptor corresponding to the information of the given <em>element</em>.
47 * Configuration element from which to create this descriptor.
49 * The ranking of the adapter factory.
51 public RankedAdapterFactoryDescriptorImpl(IConfigurationElement element
, int ranking
) {
52 super(element
, AdapterFactoryDescriptorRegistryListener
.ATT_CLASS
);
53 this.ranking
= ranking
;
54 this.id
= element
.getAttribute(AdapterFactoryDescriptorRegistryListener
.ATT_CLASS
);
60 * @see org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#createAdapterFactory()
62 public AdapterFactory
createAdapterFactory() {
63 if (factory
== null) {
64 factory
= this.createInstance();
72 * @see org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getRanking()
74 public int getRanking() {
81 * @see RankedAdapterFactoryDescriptor#getId()
83 public String
getId() {
90 * @see {org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getLabel()}
92 public String
getLabel() {
93 String label
= element
.getAttribute(ATT_LABEL
);
95 label
= element
.getAttribute(AdapterFactoryDescriptorRegistryListener
.ATT_CLASS
);
103 * @see {@link org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getDescription()}
105 public String
getDescription() {
106 return element
.getAttribute(ATT_DESCRIPTION
);
112 * @see {@link org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#isOptional()}
114 public boolean isOptional() {
115 return Boolean
.parseBoolean(element
.getAttribute(ATT_OPTIONAL
));