Adds Item provider preference page.
[EMFCompare2.git] / plugins / org.eclipse.emf.compare.rcp / src / org / eclipse / emf / compare / rcp / internal / adapterfactory / RankedAdapterFactoryDescriptorImpl.java
blobd67d363d772a56ccacc5b2bdc60c8b34280e8b57
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
7 *
8 * Contributors:
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;
18 /**
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;
43 /**
44 * Creates a descriptor corresponding to the information of the given <em>element</em>.
46 * @param element
47 * Configuration element from which to create this descriptor.
48 * @param ranking
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);
57 /**
58 * {@inheritDoc}
60 * @see org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#createAdapterFactory()
62 public AdapterFactory createAdapterFactory() {
63 if (factory == null) {
64 factory = this.createInstance();
66 return factory;
69 /**
70 * {@inheritDoc}
72 * @see org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getRanking()
74 public int getRanking() {
75 return ranking;
78 /**
79 * {@inheritDoc}
81 * @see RankedAdapterFactoryDescriptor#getId()
83 public String getId() {
84 return id;
87 /**
88 * {@inheritDoc}
90 * @see {org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getLabel()}
92 public String getLabel() {
93 String label = element.getAttribute(ATT_LABEL);
94 if (label == null) {
95 label = element.getAttribute(AdapterFactoryDescriptorRegistryListener.ATT_CLASS);
97 return label;
101 * {@inheritDoc}
103 * @see {@link org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#getDescription()}
105 public String getDescription() {
106 return element.getAttribute(ATT_DESCRIPTION);
110 * {@inheritDoc}
112 * @see {@link org.eclipse.emf.compare.internal.adapterfactory.RankedAdapterFactoryDescriptor#isOptional()}
114 public boolean isOptional() {
115 return Boolean.parseBoolean(element.getAttribute(ATT_OPTIONAL));