diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal')
64 files changed, 0 insertions, 8029 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java deleted file mode 100644 index a3e46e360..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.HashSet; -import java.util.Set; - -/** - * Convenient abstract class that a source model locator should consider extending. - */ -public abstract class AbstractMetaDataLocator implements IMetaDataLocator, IMetaDataObservable{ - - private IDomainSourceModelType domainSourceModelType; - private Set <IMetaDataObserver> observers; - - /** - * Constructor - */ - public AbstractMetaDataLocator(){ - observers = new HashSet(1); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#getDomainSourceModelType() - */ - public IDomainSourceModelType getDomainSourceModelType() { - return domainSourceModelType; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#setDomainSourceModelType(org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType) - */ - public void setDomainSourceModelType( - final IDomainSourceModelType domainSourceModelType) { - this.domainSourceModelType = domainSourceModelType; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#addObserver(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver) - */ - public void addObserver(final IMetaDataObserver observer) { - observers.add(observer); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#removeObserver(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver) - */ - public void removeObserver(final IMetaDataObserver observer) { - observers.remove(observer); - } - - /** - * @return the set of {@link IMetaDataObserver}s for this instance - */ - public Set <IMetaDataObserver> getObservers(){ - return observers; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataModelManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataModelManager.java deleted file mode 100644 index 829bf2361..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataModelManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.internal.managedobject.AbstractManagedObject; - - -/** - * Abstract implementation of an {@link IMetaDataModelManager} that all implementers must subclass - */ -public abstract class AbstractMetaDataModelManager extends AbstractManagedObject implements IMetaDataModelManager { - - @Override - public void dispose() { - //do nothing by default - } - - @Override - public void checkpoint() { - //do nothing by default - } - - @Override - public void destroy() { - // do nothing by default - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java deleted file mode 100644 index ed0d1c54a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java +++ /dev/null @@ -1,360 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesFactory; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; - -/** - * Abstract class that the taglib domain translators use to - * convert the CM model to a standard meta data model - * - */ -public abstract class AbstractTagLibDomainContentModelMetaDataTranslator { - - /** - * {@link IMetaDataModelMergeAssistant} to use - */ - protected IMetaDataModelMergeAssistant _assistant; - - /** - * Set the assistant to use during the translation. Must be called prior to doTransalate(doc); - * @param assistant - */ - protected void setAssistant(IMetaDataModelMergeAssistant assistant){ - _assistant = assistant; - } - - /** - * Transforms the CMDocument into entities and traits of a standard metadata model - * using the assistant that must be set before this call. - * @param doc - */ - protected void doTranslate(CMDocument doc){ - createTags(doc); - createTagfileTraits(doc); - } - - /** - * @param entity - * @param key - * @param value - */ - protected void createSimpleStringEntityTraitIfNecessary(final Entity entity, final String key, - final String value) { - Trait t = findTraitOnEntityById(entity, key); - if (t == null){ - t = internalCreateTrait(entity, key); - - StringValue val = TraitTypesFactory.eINSTANCE.createStringValue(); - val.setValue(value); - - t.setValue(val); - } - } - - /** - * @param entity - * @param key - * @param value - */ - protected void createSimpleBooleanObjectEntityTraitIfNecessary(final Entity entity, - String key, boolean value) { - - Trait t = findTraitOnEntityById(entity, key); - if (t == null){ - t = internalCreateTrait(entity, key); - - BooleanValue val = TraitTypesFactory.eINSTANCE.createBooleanValue(); - val.setTrue(value); - - t.setValue(val); - } - - } - - /** - * @param entity - * @param key - * @return Trait - */ - protected Trait internalCreateTrait(final Entity entity, final String key) { - Trait t = MetadataFactory.eINSTANCE.createTrait(); - t.setId(key); - t.setSourceModelProvider(_assistant.getSourceModelProvider()); - entity.getTraits().add(t); - return t; - } - - /** - * @param entity - * @param key - * @return Trait - */ - protected Trait findTraitOnEntityById(final Entity entity, final String key) { - for (Iterator it=entity.getTraits().iterator();it.hasNext();){ - Trait t = (Trait)it.next(); - if (key.equals(t.getId())) - return t; - } - return null; - } - - /** - * @param nodeName - * @return Entity - */ - protected Entity findTagEntity(final String nodeName) { - for (Iterator it=getMergedModel().getChildEntities().iterator();it.hasNext();){ - Entity entity = (Entity)it.next(); - if (nodeName.equals(entity.getId())) - return entity; - } - return null; - } - - /** - * @param tag - * @param attributeName - * @return Attribute entity for supplied attribute name and given Tag entity. Will return null if not found. - */ - protected Entity findAttributeEntityForTagEntity(final Entity tag, final String attributeName) { - for (Iterator it=tag.getChildEntities().iterator();it.hasNext();){ - Entity attr = (Entity)it.next(); - if (attributeName.equals(attr.getId())) - return attr; - } - return null; - } - /** - * Create entities for tags - * @param doc - */ - protected void createTags(final CMDocument doc) { - for (Iterator it=doc.getElements().iterator();it.hasNext();){ - CMElementDeclaration tag = (CMElementDeclaration)it.next(); - Entity entity = findTagEntity(tag.getNodeName()); - if (entity == null){ - entity = MetadataFactory.eINSTANCE.createEntity(); - entity.setId(getTagNodeName(tag)); - entity.setType("tag"); //$NON-NLS-1$ - getMergedModel().getChildEntities().add(entity); - } - setTagEntityTraits(tag, entity); - } - - } - - /** - * @param tag - * @return tag node name - */ - protected String getTagNodeName(CMElementDeclaration tag) { - return tag.getNodeName(); - } - - /** - * Sets the standard traits for a tag entity from the element declaration - * @param tag - * @param entity - */ - protected void setTagEntityTraits(CMElementDeclaration tag, Entity entity) { - createSimpleStringEntityTraitIfNecessary(entity, "display-label", getTagDisplayName(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "description", getTagDescription(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "small-icon", getTagSmallIcon(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "large-icon", getTagLargeIcon(tag)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(entity, "expert", getTagIsExpert(tag)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(entity, "hidden", getTagIsHidden(tag)); //$NON-NLS-1$ - - createAttributeEntities(entity, tag); - } - - /** - * @param tagEntity - * @param tag - */ - protected void createAttributeEntities(Entity tagEntity, - CMElementDeclaration tag) { - - for (Iterator it=tag.getAttributes().iterator();it.hasNext();){ - CMAttributeDeclaration cmAttr = (CMAttributeDeclaration)it.next(); - Entity attr = findAttributeEntityForTagEntity(tagEntity, cmAttr.getAttrName()); - if (attr == null) { - attr = MetadataFactory.eINSTANCE.createEntity(); - attr.setId(cmAttr.getAttrName()); - tagEntity.getChildEntities().add(attr); - } - createAttributeTraits(attr, cmAttr); - } - - - } - - /** - * @param attr - * @param cmAttr - */ - protected void createAttributeTraits(Entity attr, - CMAttributeDeclaration cmAttr) { - - createSimpleStringEntityTraitIfNecessary(attr, "description", getTagAttributeDescription(cmAttr)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(attr, "required", getTagAttributeIsRequired(cmAttr)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(attr, "default-value", getTagAttributeDefaultValue(cmAttr)); //$NON-NLS-1$ - } - - /** - * @param cmAttr - * @return null. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected String getTagAttributeDescription(CMAttributeDeclaration cmAttr) {return null;} - - /** - * @param cmAttr - * @return false. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected boolean getTagAttributeIsRequired(CMAttributeDeclaration cmAttr) {return cmAttr.getUsage() == CMAttributeDeclaration.REQUIRED;} - - /** - * @param cmAttr - * @return null. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected String getTagAttributeDefaultValue(CMAttributeDeclaration cmAttr) {return null;} - - /** - * @param tag - * @return false. subclass should override if CMElementDeclaration has the metadata. - */ - protected boolean getTagIsHidden(CMElementDeclaration tag) {return false;} - - /** - * @param tag - * @return false. subclass should override if CMElementDeclaration has the metadata. - */ - protected boolean getTagIsExpert(CMElementDeclaration tag) {return false;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagLargeIcon(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagSmallIcon(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagDescription(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return tag.getElementName() - */ - protected String getTagDisplayName(CMElementDeclaration tag) {return tag.getElementName();} - - /** - * Creates standard traits for tag file entity from CMDocument metadata - * @param doc - */ - protected void createTagfileTraits(CMDocument doc) { - Model model = getMergedModel(); - - createSimpleStringEntityTraitIfNecessary(model, "display-label", getURIDisplayLabel()); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(model, "description", getURIDescription()); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(model, "default-prefix", getURIDefaultPrefix()); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(model, "expert", getURIExpert()); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(model, "hidden", getURIHidden()); //$NON-NLS-1$ - - } - - /** - * @return the display label to use for this model. Subclasses should override if model has the meta data. - */ - protected String getURIDisplayLabel(){ - return getMergedModel().getId(); - } - - /** - * @return default prefix to use for tags. Returns null. Subclasses should override if model has the meta data. - */ - protected String getURIDefaultPrefix(){ - return null; - } - - /** - * @return description to use. Default is the URI. Subclasses should override if model has the meta data. - */ - protected String getURIDescription(){ - return getMergedModel().getId(); - } - - /** - * @return false. Subclasses should override if model has the meta data. - */ - protected boolean getURIExpert() { return false;} - - /** - * @return false. Subclasses should override if model has the meta data. - */ - protected boolean getURIHidden() {return false; } - - /** - * @return a model of all entities and traits - */ - protected Model getMergedModel() { - Model model = (Model)_assistant.getMergedModel().getRoot(); - if (model == null){ - //need to create model key object - Model tld = createTLDModel(); - _assistant.getMergedModel().setRoot(tld); - model = (Model)_assistant.getMergedModel().getRoot(); - } - return model; - } - - /** - * @return new model - */ - protected Model createTLDModel() { - Model entity = getFactory().createModel(); - entity.setId(_assistant.getMergedModel().getModelContext().getModelIdentifier()); - return entity; - } - - /** - * @return MetadataFactory instance - */ - protected MetadataFactory getFactory(){ - return (MetadataFactory) MetadataPackage.eINSTANCE.getEFactoryInstance(); - } - - /** - * @return CMDocument being used for the current translate call - */ - protected CMDocument getSourceModel() { - return (CMDocument)_assistant.getSourceModelProvider().getSourceModel(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java deleted file mode 100644 index 8cfda6a8b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Default class used for loading metadata. - * Loads the source types from extensions defined against the domain. - * - * see org.eclipse.jst.jsf.common.domainLoadingStrategies ext-pt - */ -public class DomainLoadingStrategy implements IDomainLoadingStrategy, IMetaDataObserver { - - /** - * Domain id - */ - protected String domain; - - private MetaDataModel _model; - private List <IDomainSourceModelType> _sourceTypes; - private List <IMetaDataSourceModelProvider> _sources; - - /** - * Constructor - * @param domain - */ - public DomainLoadingStrategy(String domain){ - this.domain = domain; - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#load(org.eclipse.jst.jsf.common.metadata.internal.MetaDataModel) - */ - public void load(MetaDataModel model) { - this._model = model; - _sourceTypes = loadDomainSourceModelTypes(); - sortSourceTypes(_sourceTypes); - _sources = locateMetaDataSourceInstances(_sourceTypes, model); - mergeModel(model, _sources); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#reload() - */ - public void reload() throws ModelNotSetException { - //System.out.println("reload");//debug //$NON-NLS-1$ - if (_model == null) - throw new ModelNotSetException(); - - removeOldLocatorObservers(); - _sources = locateMetaDataSourceInstances(_sourceTypes, _model); - mergeModel(_model, _sources); - } - - /** - * Responsible for iterating through the sorted list of <code>IMetaDataSourceModelProvider</code> - * and merging the models after first translating the source model as required, into a single mreged model of - * standard metadata Entities and Traits. - * @param model - * @param sources - */ - protected void mergeModel(final MetaDataModel model, final List <IMetaDataSourceModelProvider> sources) { - - StandardModelFactory.debug(">> Begin Merge: "+model.getModelContext()+"("+sources.size()+ " sources)", StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - final IMetaDataModelMergeAssistant assistant = createModelMergeAssistant(model); - for (final IMetaDataSourceModelProvider mds : sources){ - final Iterator translators = mds.getLocator().getDomainSourceModelType().getTranslators().iterator(); - while (translators.hasNext()){ - final IMetaDataTranslator translator = (IMetaDataTranslator)translators.next(); - if (translator.canTranslate(mds)){ - StandardModelFactory.debug(">>> Merging: "+model.getModelContext()+"::"+mds, StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$//$NON-NLS-2$ - assistant.setSourceModelProvider(mds); - try { - translator.translate(assistant); - } catch (Exception e) { - StandardModelFactory.debug(">>>> Error during translate/merge of: "+model.getModelContext()+": "+mds, StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ //$NON-NLS-2$ - JSFCommonPlugin.log(IStatus.ERROR, "Error during load of: "+mds, e); //$NON-NLS-1$ - } - } - } - } - assistant.setMergeComplete(); - StandardModelFactory.debug(">> End Merge: "+model.getModelContext(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - - /** - * @param model - * @return an instance of a IMetaDataModelMergeAssistant to be used while merging source models - */ - protected IMetaDataModelMergeAssistant createModelMergeAssistant(MetaDataModel model){ - return new MetaDataModelMergeAssistantImpl(model); - } - - /** - * Allows for subclasses to override the default mechanism for sorting the source types. - * @param sourceTypes - */ - protected void sortSourceTypes(List <IDomainSourceModelType> sourceTypes) { - //allows override - } - - /** - * @return list of <code>IDomainSourceModelType</code>s located in the <code>DomainSourceTypesRegistry</code> - * for the specified uri - */ - protected List <IDomainSourceModelType> loadDomainSourceModelTypes() { - return DomainSourceTypesRegistry.getInstance().getDomainSourceTypes(domain); - } - - /** - * @param sourceTypes - * @param model - * @return list of <code>IMetaDataSourceModelProvider</code> instances from the domain source types applicable for - * this domain for this particular uri specified in the model - */ - protected List <IMetaDataSourceModelProvider> locateMetaDataSourceInstances(final List <IDomainSourceModelType> sourceTypes, MetaDataModel model) { - final List<IMetaDataSourceModelProvider> sources = new ArrayList<IMetaDataSourceModelProvider>(); - final IProject project = getProject(model); - for (final IDomainSourceModelType sourceType : sourceTypes){ - final IMetaDataLocator locator = sourceType.getLocator(project); - if (locator != null) { - //We MUST set the sourceType here to associate the handler with locator to use for the source models - locator.setDomainSourceModelType(sourceType); - - final List <IMetaDataSourceModelProvider> providers = locator.locateMetaDataModelProviders(model.getModelContext().getModelIdentifier()); - if (providers != null && !providers.isEmpty()){ - for (final IMetaDataSourceModelProvider provider : providers){ - //We MUST set the sourceType here to associate the translators to use for the source models - provider.setLocator(locator); - sources.add(provider); - } - } - //listen for changes - locator.addObserver(this); - } - } - return sources; - } - - private IProject getProject(final MetaDataModel model) { - return (IProject)model.getModelContext().getAdapter(IProject.class); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver#notifyMetadataChanged(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent) - */ - public void notifyMetadataChanged(final IMetaDataChangeNotificationEvent event) { - //for now, if any event occurs, we need to flush the _model so that it will rebuild - _model.setNeedsRefresh(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#cleanup() - */ - public void cleanup(){ - removeOldLocatorObservers(); - _sources = null; - _sourceTypes = null; - _model = null; - } - - private void removeOldLocatorObservers(){ - if (_sources != null){ - for (final IMetaDataSourceModelProvider provider : _sources){ - if (provider != null) { - final IMetaDataLocator locator = provider.getLocator(); - if (locator != null){ - locator.removeObserver(this); - locator.setDomainSourceModelType(null); - provider.setLocator(null); - } - } - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java deleted file mode 100644 index d5b175599..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - - -/** - * Registry of strategies used to load domains of metadata. - * Uses the <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt to load. - * - * see <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt - */ -public class DomainLoadingStrategyRegistry{ - private static DomainLoadingStrategyRegistry INSTANCE; - - private HashMap <String, DomainLoadingStrategyDescriptorImpl> domainLoadingStrategyDescriptors; - - private static final String EXTENSION_POINT_ID = "domainLoadingStrategies"; //$NON-NLS-1$ - - private DomainLoadingStrategyRegistry(){ - init(); - } - - /** - * @return singleton instance of the DomainLoadingStrategyRegistry - */ - public synchronized static DomainLoadingStrategyRegistry getInstance() { - if (INSTANCE == null){ - INSTANCE = new DomainLoadingStrategyRegistry(); - } - return INSTANCE; - } - - /** - * Loads registry with descriptors from the domainLoadingStrategies ext-pt. - */ - synchronized final void init(){ - final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - final IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID ); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; - DomainLoadingStrategyDescriptorImpl dls = new DomainLoadingStrategyDescriptorImpl(element); - addDomainLoadingStrategyDescriptor(dls); - } - } - } - - /** - * Add domain loading strategy descriptor for a domain to the registry domains - * @param strategy - */ - protected void addDomainLoadingStrategyDescriptor(final DomainLoadingStrategyDescriptorImpl strategy){ - getDescriptors().put(strategy.getDomain(), strategy); - } - - /** - * @param domain - * @return an instance of an <code>IDomainLoadingStrategy</code> for the given domain - */ - public IDomainLoadingStrategy getLoadingStrategy(final String domain){ - final DomainLoadingStrategyDescriptorImpl strategy = getDescriptors().get(domain); - if (strategy == null){ - return createDefaultLoadingStrategy(); - } - return createLoadingStrategy(domain); - } - - - /** - * @return strategy that will only use standard metadata files - */ - private IDomainLoadingStrategy createDefaultLoadingStrategy() { - return new DomainLoadingStrategy(null); - } - - private IDomainLoadingStrategy createLoadingStrategy(final String domain){ - return getDescriptors().get(domain).newInstance(); - } - - private Map <String, DomainLoadingStrategyDescriptorImpl> getDescriptors(){ - if (domainLoadingStrategyDescriptors == null){ - domainLoadingStrategyDescriptors = new HashMap<String, DomainLoadingStrategyDescriptorImpl>(); - } - return domainLoadingStrategyDescriptors; - } - - /** - * Implementation of a DomainLoadingStrategy descriptor that is responsible for creating instances of the IDomainLoadingStrategy - */ - private static class DomainLoadingStrategyDescriptorImpl { - String domain; - String loadingStrategyClassName; - String bundleId; - Class strategy; - IConfigurationElement element; - - DomainLoadingStrategyDescriptorImpl(IConfigurationElement element){ - this.element = element; - this.init(); - } - - private void init() { - domain = element.getAttribute("domainId"); //$NON-NLS-1$ - bundleId = element.getContributor().getName(); - loadingStrategyClassName = element.getAttribute("domainLoadingStrategy"); //$NON-NLS-1$ - } - - /** - * @return domain id - */ - public String getDomain() { - return domain; - } - - /** - * @return new instance of IDomainLoadingStrategy - */ - public IDomainLoadingStrategy newInstance(){ - try { - Class[] parameterTypes = new Class[]{String.class}; - Object[] initargs = new Object[]{domain}; - Object loader = this.getLoadingStrategy().getConstructor(parameterTypes).newInstance(initargs); - if (loader instanceof IDomainLoadingStrategy) - return (IDomainLoadingStrategy)loader; - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Unable to instantiate IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (IllegalArgumentException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalArgumentException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (SecurityException e) { - JSFCommonPlugin.log(IStatus.ERROR, "SecurityException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (InvocationTargetException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InvocationTargetException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (NoSuchMethodException e) { - JSFCommonPlugin.log(IStatus.ERROR, "NoSuchMethodException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } - return null; - } - - private Class getLoadingStrategy() { - if (strategy == null){ - strategy = JSFCommonPlugin.loadClass(loadingStrategyClassName, bundleId); - } - return strategy; - } - - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java deleted file mode 100644 index d2e925100..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Implementation of a {@link IDomainSourceModelType} descriptor. - * Responsible for producing instances of {@link IDomainSourceModelType}. - * Also responsible for creating the {@link IMetaDataTranslator} descriptors from the - * <code>com.eclipse.jst.jsf.common.domainSourceModelTypeTranslators</code> ext-pt - */ -public class DomainSourceModelTypeDescriptor { - private static final String TRANSLATORS_EXTENSION_POINT_ID = "domainSourceModelTypeTranslators"; //$NON-NLS-1$ - private static final String STANDARD_FILE_NULL_TRANSLATOR = "org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataFilesTranslator"; //$NON-NLS-1$ - private String domain = "DEFAULT"; //$NON-NLS-1$ - private String domainSourceModelTypeId; - private String locatorClassName = "org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataLocator"; //$NON-NLS-1$ - private Set translatorDescriptors; - private String bundleId = JSFCommonPlugin.PLUGIN_ID; - private int ordinal; - - /** - * Constructor - * @param domain - * @param domainSourceModelTypeId - * @param locatorClassName - * @param bundleId - * @param ordinal - */ - public DomainSourceModelTypeDescriptor(String domain, String domainSourceModelTypeId, String locatorClassName, String bundleId, int ordinal){ - this.domain = domain; - this.locatorClassName = locatorClassName; - this.domainSourceModelTypeId = domainSourceModelTypeId; - this.bundleId = bundleId; - this.ordinal = ordinal; - init(); - } - - /** - * Default model type descriptor that will load only standard metadata files - */ - public DomainSourceModelTypeDescriptor(){ -// getTranslatorDescriptors(); - //createTranslatorInstances() will add the standard null translator - } - - private synchronized void init() { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, TRANSLATORS_EXTENSION_POINT_ID ); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; - String srcHdlrId = element.getAttribute("domainSourceModelTypeId"); //$NON-NLS-1$ - if (srcHdlrId.equals(domainSourceModelTypeId)) - addTranslatorDescriptor(element); - } - } - } - - private void addTranslatorDescriptor(IConfigurationElement element) { - String translator = element.getAttribute("translatorClass"); //$NON-NLS-1$ - DomainSourceModelTranslatorDescriptor d = new DomainSourceModelTranslatorDescriptor(translator, element.getContributor().getName()); - getTranslatorDescriptors().add(d); - } - - private Set getTranslatorDescriptors(){ - if (translatorDescriptors == null){ - translatorDescriptors = new HashSet(); - } - return translatorDescriptors; - } - - /** - * @return domain - */ - public String getDomain() { - return domain; - } - - /** - * @return new instance of the {@link IDomainSourceModelType} - */ - public IDomainSourceModelType getInstance(){ - return new DomainSourceModelTypeImpl(); - } - - /** - * Internal class implementing {@link IDomainSourceModelType} - */ - class DomainSourceModelTypeImpl implements IDomainSourceModelType{ - - private Set translators; - private IMetaDataLocator locator; - - DomainSourceModelTypeImpl(){ - // restrict construction to package scope - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getDomain() - */ - public String getDomain() { - return domain; - } - - /** - * @return value of ordinal defined by the ext-pt used for ordering source types for a domain - */ - public int getOrdinal(){ - return ordinal; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getLocator() - */ - public IMetaDataLocator getLocator(IProject project) { - if (locator == null){ - locator = MetaDataLocatorFactory.getInstance().getLocator(locatorClassName, bundleId, project); - } - - return locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getTranslators() - */ - public Set getTranslators() { - if (translators == null){ - translators = createTranslatorInstances(); - } - return translators; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString(){ - StringBuffer buf = new StringBuffer("DomainSourceModelTypeImpl"); //$NON-NLS-1$ - buf.append("(domain = "); //$NON-NLS-1$ - buf.append(getDomain()); - buf.append(", locator = "); //$NON-NLS-1$ - buf.append(locator != null ? locator.toString() : "null"); //$NON-NLS-1$ - buf.append(")"); //$NON-NLS-1$ - return buf.toString(); - } - - private Set createTranslatorInstances() { - translators = new HashSet<IMetaDataTranslator>(); - if (getTranslatorDescriptors().size() == 0){// for TagLibDomain, we are adding null translator via extension (as of 7/16/07) - //would get here if a domain and source type was defined without a domain translator. Should not happen, but - //add Null Translator for now.... - //we could/should raise exception. - //Developers should add a STANDARD_FILE_NULL_TRANSLATOR if using standard metadata format. - Class klass = JSFCommonPlugin.loadClass(STANDARD_FILE_NULL_TRANSLATOR, JSFCommonPlugin.PLUGIN_ID); - try { - translators.add(klass.newInstance()); - return translators; - } catch (InstantiationException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances(STANDARD_FILE_NULL_TRANSLATOR)"); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances(STANDARD_FILE_NULL_TRANSLATOR)"); //$NON-NLS-1$ - } - - } - - Iterator <DomainSourceModelTranslatorDescriptor>it = getTranslatorDescriptors().iterator(); - while (it.hasNext()){ - final DomainSourceModelTranslatorDescriptor d = it.next(); - final Class klass = JSFCommonPlugin.loadClass(d.getTranslator(), d.getBundleId()); - try { - translators.add(klass.newInstance()); - } catch (InstantiationException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances"); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances"); //$NON-NLS-1$ - } - } - return translators; - } - - } - - /** - * Internal class implementing a descriptor for DomainSourceModelTranslators - */ - static class DomainSourceModelTranslatorDescriptor { - - private final String _translator; - private final String _bundleId; - - /** - * Constructor - * @param translator - * @param bundleId - */ - public DomainSourceModelTranslatorDescriptor(final String translator, final String bundleId) { - this._translator = translator; - this._bundleId = bundleId; - } - - String getTranslator(){ - return _translator; - } - - String getBundleId(){ - return _bundleId; - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java deleted file mode 100644 index 54d0ed182..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.internal.DomainSourceModelTypeDescriptor.DomainSourceModelTypeImpl; - -/** - * Registry of Domain Source Types loaded from domainSourceModelTypes ext-pt. - */ -public class DomainSourceTypesRegistry{ - private static final String EXTENSION_POINT_ID = "domainSourceModelTypes"; //$NON-NLS-1$ - private static DomainSourceTypesRegistry INSTANCE; - private Map<String, List<DomainSourceModelTypeDescriptor>> domainSourceTypeDescriptors; - - private DomainSourceTypesRegistry(){ - init(); - } - - /** - * @return singleton instance of DomainSourceTypesRegistry - */ - public synchronized static DomainSourceTypesRegistry getInstance() { - if (INSTANCE == null){ - INSTANCE = new DomainSourceTypesRegistry(); - } - return INSTANCE; - } - - /** - * @param domain identifier - * @return list of <code>IDomainSourceModelType</code> sorted in descending order by ordinal - */ - public List<IDomainSourceModelType> getDomainSourceTypes(String domain){ - final List<DomainSourceModelTypeDescriptor> list = getDomainSourceModelDescriptors(domain); - final List<IDomainSourceModelType> types = new ArrayList<IDomainSourceModelType>(); - for(final DomainSourceModelTypeDescriptor d : list){ - types.add(d.getInstance()); - } - //default sort descending by ordinal - Collections.sort(types, new Comparator(){ - public int compare(final Object o1, final Object o2) { - final DomainSourceModelTypeImpl desc1 = (DomainSourceModelTypeImpl)o1; - final DomainSourceModelTypeImpl desc2 = (DomainSourceModelTypeImpl)o2; - if (desc1.getOrdinal() == desc2.getOrdinal()) - return 0; - if (desc1.getOrdinal() > desc2.getOrdinal()) - return -1; - - return 1; - } - - }); - - return types; - } - - private List getDomainSourceModelDescriptors(final String domain) { - final List ret = getDescriptors().get(domain); - if (ret != null && ret.size()>0) - return ret; - - return getDefaultSourceModelDescriptor(); - } - - private List getDefaultSourceModelDescriptor() { - final List ret = new ArrayList(); - final DomainSourceModelTypeDescriptor desc = new DomainSourceModelTypeDescriptor(); - ret.add(desc); - return ret; - } - - private synchronized void init() { - final IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - final IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID ); - if (point != null) { - final IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - final IConfigurationElement element = elements[i]; - addDomainSourceTypeDescriptor(element); - } - } - } - - private void addDomainSourceTypeDescriptor(final IConfigurationElement element) { - final String domainId = element.getAttribute("domainId"); //$NON-NLS-1$ - final String srcHdlrId = element.getAttribute("domainSourceModelTypeId"); //$NON-NLS-1$ - final String locator = element.getAttribute("locator"); //$NON-NLS-1$ - final String ordinalStr = element.getAttribute("ordinal"); //$NON-NLS-1$ - int ordinal = 1; - if (ordinalStr!=null && !ordinalStr.equals("")){ //$NON-NLS-1$ - ordinal = Integer.parseInt(ordinalStr); - } - final DomainSourceModelTypeDescriptor d = new DomainSourceModelTypeDescriptor(domainId, srcHdlrId, locator, element.getContributor().getName(), ordinal); - List<DomainSourceModelTypeDescriptor> descs = getDescriptors().get(domainId); - if (descs == null){ - descs = new ArrayList<DomainSourceModelTypeDescriptor>(); - getDescriptors().put(domainId, descs); - } - descs.add(d); - } - - private Map<String, List<DomainSourceModelTypeDescriptor>> getDescriptors() { - if (domainSourceTypeDescriptors == null){ - domainSourceTypeDescriptors = new HashMap<String, List<DomainSourceModelTypeDescriptor>>(); - } - return domainSourceTypeDescriptors; - } - - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java deleted file mode 100644 index 6c8169616..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Provides class loading by using the plugin's classloader that defined an item of metadata - */ -public interface IClassLoaderProvider { - /** - * @param className - * @return Class - implementers should eat exceptions and return null whenever class cannot be returned - */ - public Class loadClass(String className); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java deleted file mode 100644 index ee21e6249..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - - -/** - * Defines a strategy to use for loading a standard metadata model for a certain domain. - * see <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt - */ -public interface IDomainLoadingStrategy { - - /** - * Create a merged "standard" metadata model. - * @param model to load - * - */ - public void load(MetaDataModel model); - - /** - * Reload a merged "standard" metadata model. - * Allows for some optimization for reload. - * @throws ModelNotSetException - * - */ - public void reload() throws ModelNotSetException; - - - /** - * Opportunity to cleanup and should be called when strategy is being destroyed - */ - public void cleanup(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java deleted file mode 100644 index b2d7fcda4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.Set; - -import org.eclipse.core.resources.IProject; - -/** - * Binds a domain of metadata to a source model type which is defined by a {@link IMetaDataLocator} - * and set of {@link IMetaDataTranslator}s - * Not intended to be implemented by clients. Created from ext-pts. - */ -public interface IDomainSourceModelType { - /** - * @return domain id - */ - public String getDomain(); - /** - * @param project - may be null - * @return instance of IMetaDataLocator - may return null if the locator cannot operate in the current context - */ - public IMetaDataLocator getLocator(IProject project); -// public int getOrdinal(); - /** - * @return set of {@link IMetaDataTranslator}s for the domain source model type - */ - public Set<IMetaDataTranslator> getTranslators(); - - /** - * @return oridinal for this type within the domain - */ - public int getOrdinal(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java deleted file mode 100644 index 9405a6a64..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Provides image descriptors relative to the plugin that provided the image metadata - * - */ -public interface IImageDescriptorProvider { - /** - * @param imagePath - * @return ImageDescriptor - implementers should eat exceptions and return null whenever imageDescriptor cannot be returned - */ - public ImageDescriptor getImageDescriptor(String imagePath); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java deleted file mode 100644 index 29c6ce13f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Experimental and not used at the moment. - * - */ -public interface IMetaDataChangeNotificationEvent { - //change to enums if we do Java5 - /** - * TODO: - */ - public static final int ADDED = 1; - /** - * TODO: - */ - public static final int REMOVED = 2; - /** - * TODO: - */ - public static final int CHANGED = 3; - - /** - * @return the uri - */ - public String getURI(); - /** - * @return when to the event types above - */ - public int getEventType(); - /** - * @return the meta-data locator - */ - public IMetaDataLocator getLocator(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainContext.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainContext.java deleted file mode 100644 index 83fb2ce77..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainContext.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryContextFactory; -import org.eclipse.jst.jsf.context.IModelContext; - -/** - * Domain context - * <p> - * @noimplement - see {@link MetaDataQueryContextFactory} - * - */ -public interface IMetaDataDomainContext extends IModelContext{ - - /** - * For convenience... - */ - public static final String TAGLIB_DOMAIN_CONTEXT_ID = "TagLibraryDomain"; //$NON-NLS-1$ - - /** - * @return domain identifier for this context. - */ - public String getDomainId(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainQueryFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainQueryFactory.java deleted file mode 100644 index 85403c8cc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataDomainQueryFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.query.internal.IMetaDataQuery; - -/** - * Produces {@link IMetaDataQuery}s for a metadata domain - * - */ -public interface IMetaDataDomainQueryFactory { - /** - * @param context - * @return {@link IMetaDataQuery} - */ - public IMetaDataQuery createQuery(final IMetaDataDomainContext context); - - /** - * @return the domain id that this factory handles - */ - public String getDomainIdentifier(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java deleted file mode 100644 index c4405566c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.List; - -/** - * Locates instances of metadata of a specific source model type - */ -public interface IMetaDataLocator { - /** - * @param uri - * @return a list of <code>IMetaDataSourceModelProvider</code>s for the uri located by this instance - */ - public List <IMetaDataSourceModelProvider> locateMetaDataModelProviders(String uri); - - /** - * Opportunity for service to start (add listeners, etc.). - * Framework calls this immediately after construction and all setup should occur at this time. - */ - public void startLocating(); - /** - * Stop looking for instances of metadata model sources. An opportunity to cleanup. - */ - public void stopLocating(); - - /** - * @param observer add a {@link IMetaDataObserver} of this locator - */ - public void addObserver(IMetaDataObserver observer); - /** - * @param observer remove a {@link IMetaDataObserver} of this locator - */ - public void removeObserver(IMetaDataObserver observer); - - /** - * @return IDomainSourceModelType instance that created this locator - */ - public IDomainSourceModelType getDomainSourceModelType(); - /** - * @param domainSourceModelType set the domainSourceModelType instance that created this locator - */ - public void setDomainSourceModelType(IDomainSourceModelType domainSourceModelType); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelContext.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelContext.java deleted file mode 100644 index 024b514e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelContext.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.Model; - -/** - * Context for establishing the metadata model. - * TODO: Should probably be moved to query internal package - * <p> - * @noimplement - not intended to be implemented, users must subclass {@link MetaDataModelContext} if necessary - */ -public interface IMetaDataModelContext extends IMetaDataDomainContext { - - /** - * @return the string that will uniquely identify the {@link Model} within this domain of metadata - */ - public String getModelIdentifier(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManager.java deleted file mode 100644 index dc9cc0e10..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.internal.managedobject.IManagedObject; -import org.eclipse.jst.jsf.common.metadata.Model; - -/** - * Returns {@link Model}s for a given context which can then be queried. - * <p> - * Responsible for managing all domains of metadata - * <p> - * @noimplement - users must extend AbstractMetaDataModelManager - * @noextend - */ -public interface IMetaDataModelManager extends IManagedObject { - - /** - * Will locate a MetaData Model. Sets the model context in the - * model. - * - * @param modelContext - * @return the {@link Model} for the given model identifier - */ - public Model getModel( - final IMetaDataModelContext modelContext); - - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManagerFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManagerFactory.java deleted file mode 100644 index 5c8fa8492..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelManagerFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IResource; - -/** - * A factory that will produce {@link IMetaDataModelManager}s - */ -public interface IMetaDataModelManagerFactory { - /** - * @param projectOrWorkspaceRoot - * @return IMetaDataModelManager for the project, or shared IMetaDataModelManager for the workspace - */ - public IMetaDataModelManager getInstance(IResource projectOrWorkspaceRoot); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java deleted file mode 100644 index 0a6a341be..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.Trait; - - -/** - * Helper class interface to merge source models into a single merged model. - * Not intended to be implemented by clients - * - */ -public interface IMetaDataModelMergeAssistant { - /** - * @return merged model - */ - public MetaDataModel getMergedModel(); - /** - * Method that will first check to see if an entity with the same id exists in the merged model. - * If not, it will add it. The entities includeGroups are then also merged. - * @param entity - * @return the merged model entity - * - */ - public Entity addEntity(Entity entity); - /** - * Method will add an entity if not already existing in the merged model, and then check for an existing trait by id on the merged model's entity. - * @param entity - * @param trait - * @return flag indicating whether or not the traits was new and therefore added to the merged model's entity - */ - public boolean addTrait(Entity entity, Trait trait); - - /** - * Method will add an entityGroup to the model if not already exiting in the merged model (by id). - * @param entityGroup - */ - public void addEntityGroup(EntityGroup entityGroup); - /** - * Signal that the merge is complete so that any post-processing may occur. - * This should be the last call made on the merge assistant and should be done before client calls for the merged model result. - * This should signal that entityGroups processing should begin. - */ - public void setMergeComplete(); - - /** - * @param mds - {@link IMetaDataSourceModelProvider} - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider mds); - /** - * @return {@link IMetaDataSourceModelProvider} for current operation - */ - public IMetaDataSourceModelProvider getSourceModelProvider(); - - /** - * @param queryRoot - * @param entityKey - key relative to queryRoot - * @return entity - will return null if not found - */ - public Entity getMergedEntity(Entity queryRoot, String entityKey); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java deleted file mode 100644 index 69152d34d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Allows {@link IMetaDataObserver}s to observe changes. - * Experimental. - * - */ -public interface IMetaDataObservable { - /** - * Add the observer to the set of observers. Has no effect if - * the same observer is already registered - * - * @param observer - */ - public void addObserver(IMetaDataObserver observer); - - /** - * Remove the observer from the set of observers. Has no effect - * if observer was not already registered. - * - * @param observer must not be null - */ - public void removeObserver(IMetaDataObserver observer); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java deleted file mode 100644 index 5a138a33a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Interface for notification when an {@link IMetaDataObservable} changes - * - */ -public interface IMetaDataObserver { - /** - * Callback to observer when an {@link IMetaDataObservable} throws an event - * @param event - */ - public void notifyMetadataChanged(IMetaDataChangeNotificationEvent event); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java deleted file mode 100644 index 6a19c3bb0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.runtime.IAdaptable; - - -/** - * Provides a source of metadata that can be transformed into a merged standard model - * LIKELY TO CHANGE - */ -public interface IMetaDataSourceModelProvider extends IAdaptable{ - /** - * @return the source model - */ - public Object getSourceModel(); - /** - * @return the IMetaDataLocator instance that located this model provider instance - */ - public IMetaDataLocator getLocator(); - /** - * @param locator instance that located this model provider instance - */ - public void setLocator(IMetaDataLocator locator); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java deleted file mode 100644 index 2a7f6e2e9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Translate from the source model metadata structure into a standard metadata domain of metadata. - * - */ -public interface IMetaDataTranslator { - /** - * @param assistant perform translation using the IMetaDataModelMergeAssistant - */ - public void translate(IMetaDataModelMergeAssistant assistant); - /** - * @param modelProvider - cannot be null - * @return true if this translator can translate this model source - */ - public boolean canTranslate(IMetaDataSourceModelProvider modelProvider); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java deleted file mode 100644 index 0f0ed7125..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; - -/** - * A <code>IMetaDataLocator</code> that is sensitive to the project context - */ -public interface IPathSensitiveMetaDataLocator extends IMetaDataLocator { - /** - * @param project - */ - public void setProjectContext(IProject project); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java deleted file mode 100644 index 640da3540..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ResourceBundle; - -/** - * Provides the resource bundle from the plugin that defined an item of metadata. - */ -public interface IResourceBundleProvider { - /** - * @return ResourceBundle - implementers should eat exceptions and return null whenever resourceBundle cannot be returned - */ - public ResourceBundle getResourceBundle(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java deleted file mode 100644 index f82d0fbe4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2008 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - */ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.net.URL; - -/** - * Provides absolute URLs from resource path, which is relative to the plug-in - * with the metadata that specified the resource path. - * - * @author Ian Trimble - Oracle - */ -public interface IResourceURLProvider { - - /** - * Get absolute URL for resource path, which is relative to the plug-in that - * specified the resource metadata. - * - * @param resourcePath Path to resource, relative to metadata plug-in. - * @return Absolute URL for resource path. - */ - public URL getResourceURL(String resourcePath); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java deleted file mode 100644 index 02270a31d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - - -/** - * Represents the metadata file defined by the StandardMetaDataFile extension-point - * Not intended to be implemented by clients - */ -public interface IStandardMetaDataSourceInfo { - /** - * @return location of metadata file that the locator class will use - */ - public String getLocation(); - /** - * @return bundle id of plugin defining the metadata file - */ - public String getBundleId(); - /** - * @return class name of the locator that will find the the standard metadata file - */ - public String getLocatorClassname(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java deleted file mode 100644 index 80cbbd961..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.List; - - -/** - * Strategy for loading tag metadata. Extends and uses the default {@link DomainLoadingStrategy}. - * Mainly exists for illustrative purposes. Could be removed.. - */ -public class JSPTagLibDomainLoadingStrategy extends DomainLoadingStrategy { - - /** - * Constructor - * @param domain - */ - public JSPTagLibDomainLoadingStrategy(String domain) { - super(domain); - } - - /*@Override*/ - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.DomainLoadingStrategy#sortSourceTypes(java.util.List) - */ - protected void sortSourceTypes(List<IDomainSourceModelType> sourceTypes) { - //an opportunity to override the priority of the source types... - } - - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java deleted file mode 100644 index 74fd0a7b2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Externalized strings for Metadata - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.common.metadata.internal.messages"; //$NON-NLS-1$ - - /** - * Property key not found in bundle - */ - public static String Key_not_found; - - /** - * Missing resource - */ - public static String MissingResource_exception; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - // no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java deleted file mode 100644 index 8ecc17df6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Experimental. Subject to change. - * - */ -public class MetaDataChangeNotificationEvent implements - IMetaDataChangeNotificationEvent { - - private String _uri; - private IMetaDataLocator _locator; - private int _type; - - /** - * Constructor - * @param locator - * @param uri - * @param type - */ - public MetaDataChangeNotificationEvent(IMetaDataLocator locator, String uri, int type){ - this._locator = locator; - this._uri = uri; - this._type = type; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getEventType() - */ - public int getEventType() { - return _type; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getLocator() - */ - public IMetaDataLocator getLocator() { - return _locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getURI() - */ - public String getURI() { - return _uri; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java deleted file mode 100644 index a82cad7ac..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Creates instances of IMetaDataLocators and caches them so that there is only one instance of a particular locator - * when client requests one. - */ -public class MetaDataLocatorFactory - implements IResourceChangeListener { - - private static MetaDataLocatorFactory INSTANCE = null; - private Map<String, IMetaDataLocator> _locators; - - private static final boolean DEBUG = false; - /** - * @return singleton instance of the MetaDataLocatorFactory - */ - public synchronized static MetaDataLocatorFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new MetaDataLocatorFactory(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(INSTANCE, - IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE); - } - return INSTANCE; - } - - - - private Map<String, IMetaDataLocator> getLocators() { - if (_locators == null){ - _locators = new HashMap<String, IMetaDataLocator>(); - } - return _locators; - } - - /** - * @param locatorClassName - may NOT be null - * @param bundleId - may NOT be null - * @param project - may be null - * @return shared instance of IMetaDataLocator - * may return null if is IPathSensitiveMetaDataLocator and there is no project context - */ - public IMetaDataLocator getLocator(final String locatorClassName, final String bundleId, final IProject project){ - final Class klass = JSFCommonPlugin.loadClass(locatorClassName, bundleId); - String key = getKey(locatorClassName, bundleId); - IMetaDataLocator locator = null; - try { - IMetaDataLocator tempLocator = (IMetaDataLocator)klass.newInstance(); - if (tempLocator != null) { - if (tempLocator instanceof IPathSensitiveMetaDataLocator) { - if (project == null) - return null; - - key = getKey(locatorClassName, project.getName()); - } - - locator = getLocators().get(key); - if (locator == null) { - locator = tempLocator; - if (locator instanceof IPathSensitiveMetaDataLocator) - ((IPathSensitiveMetaDataLocator)locator).setProjectContext(project); - - if (DEBUG) - System.out.println("Created locator: "+locator.toString()); //$NON-NLS-1$ - - getLocators().put(key, locator); - locator.startLocating(); - } - } - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Could not instantiate IMetaDataLocator: "+key, e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException while creating IMetaDataLocator: "+key, e); //$NON-NLS-1$ - } - - return locator; - } - - /** - * @param locatorClassName - * @param contextId - this may be the bundleID or the projectName if it is a path sensitive locator - * @return key - */ - private String getKey(final String locatorClassName, final String contextId) { - StringBuffer buf = new StringBuffer(contextId); - buf.append(":"); //$NON-NLS-1$ - buf.append(locatorClassName); - return buf.toString(); - } - - /** - * Stops and disposes all locators - */ - public void dispose(){ - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - for (Iterator it=getLocators().values().iterator();it.hasNext();){ - IMetaDataLocator locator = (IMetaDataLocator)it.next(); - locator.stopLocating(); - } - getLocators().clear(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org - * .eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(final IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.PRE_CLOSE - || event.getType() == IResourceChangeEvent.PRE_DELETE) { - // a project is closing - release and cleanup - final IProject aProject = (IProject) event.getResource(); - - if (aProject != null) { - List<String> locatorsToRemove = new ArrayList<String>(); - for (Iterator it=getLocators().keySet().iterator();it.hasNext();){ - String key = (String)it.next(); - if (locatorIsForProject(key, aProject.getName())) { - locatorsToRemove.add(key); - } - } - - if (! locatorsToRemove.isEmpty()) { - for (String key : locatorsToRemove) { - IMetaDataLocator locator = getLocators().get(key); - - if (DEBUG) - System.out.println("Removed locator: "+locator.toString()); //$NON-NLS-1$ - - locator.stopLocating(); - getLocators().remove(key); - } - } - } - } - } - - private boolean locatorIsForProject(final String key, final String projectName) { - StringTokenizer t = new StringTokenizer(key, ":"); //$NON-NLS-1$ - String contextId = t.nextToken(); - if (contextId.equals(projectName)) - return true; - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java deleted file mode 100644 index 0a477c4dd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.Model; - -/** - * Responsible for loading and holding onto the standard metadata model using the IDomainLoadingStrategy. - * Wraps the model (root) with the strategy used for loading it, along with the identifying key (modelKeyDescriptor) - */ -public class MetaDataModel { - - private Object root; - private IMetaDataModelContext modelContext; - private ModelKeyDescriptor modelKeyDescriptor; - private IDomainLoadingStrategy strategy; - private boolean refresh; - - - - /** - * Constructor - * @param context - * @param strategy - */ - public MetaDataModel(final IMetaDataModelContext context, final IDomainLoadingStrategy strategy){ - this.modelContext = context; - this.strategy = strategy; - } - - /** - * @return the root of the model. - */ - public Object getRoot(){ - return root; - } - - /** - * @param root - */ - public void setRoot(Object root){ - this.root = root; - if (root != null) { - //setCurrentModelContext has been deprecated... ModelKeyDescriptor can die after that - Model m = (Model)root; - m.setCurrentModelContext(getModelKey()); - } - } - - private ModelKeyDescriptor getModelKey() { - if (modelKeyDescriptor == null) { - modelKeyDescriptor = (ModelKeyDescriptor)modelContext.getAdapter(ModelKeyDescriptor.class); - } - return modelKeyDescriptor; - } - - /** - * @return modelContext - */ - public IMetaDataModelContext getModelContext(){ - return modelContext; - } - -// public void accept(IEntityVisitor visitor){ -// if (getRoot() instanceof Model) -// visitor.visit((Model)getRoot()); -// } - - /** - * @return true if the model is null or is not, in fact, a {@link Model} - */ - public boolean isEmpty() { - if (root == null || !(root instanceof Model)) - return true; - - return false; - } - - /** - * Load the model. Delegates to the strategy. - */ - public synchronized void load(){ - StandardModelFactory.debug("> Begin Loading: "+modelContext.toString(), StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - strategy.load(this); - StandardModelFactory.debug("> End Loading: "+modelContext.toString(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - - /** - * Reloads the model delegating to strategy reload - * @throws ModelNotSetException - */ - public void reload()throws ModelNotSetException{ - setRoot(null); - refresh = false; - strategy.reload(); - } - - /** - * @return flag indicating that the model is stale - */ - public boolean needsRefresh() { - return refresh; - } - - /** - * Flag that model is stale - */ - public void setNeedsRefresh() { - refresh = true; - } - - /** - * Cleans up the model releasing references. - */ - public void cleanup(){ - if (strategy != null) - strategy.cleanup(); - strategy = null; - root = null; -// modelKeyDescriptor = null; - modelContext = null; - } - - public String toString() { - StringBuffer buf = new StringBuffer("MetaDataModel: "); //$NON-NLS-1$ - buf.append(modelContext.toString()); - return buf.toString(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContext.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContext.java deleted file mode 100644 index 742eb3552..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContext.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; - -/** - * Implementation of {@link IMetaDataModelContext} - * - */ -public class MetaDataModelContext implements IMetaDataModelContext { - - private final IProject _project; - private final String _domainId; - private final String _modelId; - - /** - * @param project - * @param domainId - * @param modelId - */ - public MetaDataModelContext(final IProject project, final String domainId, final String modelId) { - _project = project; - _domainId = domainId; - _modelId = fixJSPURIIfNecessary(modelId); //major hack carried forward from ModelKeyDescriptor! - } - - //this is a workaround for issue where jsp "uri" may upper or lower cased - private String fixJSPURIIfNecessary(final String tempuri) { - if (tempuri != null && tempuri.equals("jsp11")) //$NON-NLS-1$ - return tempuri.toUpperCase(); - return tempuri; - } - - public Object getAdapter(Class adapter) { - if (adapter == ModelKeyDescriptor.class) - return new ModelKeyDescriptor(_project, _domainId, _modelId); - if (adapter == IProject.class) - return _project; - return null; - } - -// /** -// * @return project -// */ -// public IProject getProject() { -// return _project; -// } - - public String getDomainId() { - return _domainId; - } - - public String getModelIdentifier() { - return _modelId; - } - - @Override - public String toString() { - final StringBuffer buf = new StringBuffer(); - if (_project != null) { - buf.append(_project.getName()).append(":"); //$NON-NLS-1$ - } - buf.append(getDomainId()).append(":"); //$NON-NLS-1$ - buf.append(getModelIdentifier()).append(":"); //$NON-NLS-1$ - return buf.toString(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java deleted file mode 100644 index 668f521ff..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.query.IMetaDataModelContext; - -/** - * Simple implementation of {@link IMetaDataModelContext} - * @deprecated - Helios - * - */ -public class MetaDataModelContextImpl implements IMetaDataModelContext, Cloneable { - private final String _domain; - - /** - * Constructor - * @param domain id - */ - public MetaDataModelContextImpl(final String domain){ - _domain = domain; - } - - public String getDomainID() { - return _domain; - } - - public Object getAdapter(final Class adapter) { - if (IMetaDataModelContext.class.equals(adapter)) - return this; - return null; - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java deleted file mode 100644 index 64a400970..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; - -/** - * Singleton instance for each IProject used to manage all standard metdata models for that project. - * - * Manager is responsible for loading and caching MetaDataModels. Models are keyed by URI. - * - * The manager listens for project closing resource events so that the resources can be freed up. - */ -public final class MetaDataModelManager extends AbstractMetaDataModelManager { - - private static IMetaDataModelManager SHARED_INSTANCE; - - // used to lock all instance calls for getModel - private static final Lock GLOBAL_INSTANCE_LOCK = new ReentrantLock(); - private final ModelMap models; - - - /** - * @return instance that is project agnostic. - */ - public synchronized static IMetaDataModelManager getSharedInstance(){ - if (SHARED_INSTANCE == null) { - SHARED_INSTANCE = new MetaDataModelManager(null); - } - return SHARED_INSTANCE; - } - - /** - * @param project - */ - MetaDataModelManager(final IProject project) { -// this.project = project; - models = new ModelMap(); - } - - public Model getModel( - final IMetaDataModelContext modelContext) - { - boolean gotLock = false; - try - { - final int maxTries = 6; - int numTries = 0; - final Job currentJob = Job.getJobManager().currentJob(); - while (numTries < maxTries && - !(gotLock = GLOBAL_INSTANCE_LOCK.tryLock(5000, TimeUnit.MILLISECONDS))) - { - numTries++; - if (currentJob != null) - { - currentJob.yieldRule(null); - } - } - - if (!gotLock) - { - return null; - } - StandardModelFactory.debug(">START getModel: "+modelContext, StandardModelFactory.DEBUG_MD_GET); //$NON-NLS-1$ - - MetaDataModel model = models.get(modelContext); - if (model == null) { - // long in = System.currentTimeMillis(); - model = loadMetadata(modelContext); - //System.out.println("Time to load "+modelContext.getURI()+": "+ - // String.valueOf(System.currentTimeMillis() - in)); - } else if (model.needsRefresh()) { - try { - model.reload(); - } catch (ModelNotSetException e) { - // simply load it - should not get here - model = loadMetadata(modelContext); - } - } - -// if (model != null && model.getRoot() != null) -// ((Model) model.getRoot()) -// .setCurrentModelContext(modelContext); - - StandardModelFactory.debug(">END getModel: "+modelContext, StandardModelFactory.DEBUG_MD_GET); //$NON-NLS-1$ - if (model != null && !model.isEmpty()){ - return (Model)model.getRoot(); - } - return null; - } - catch (final InterruptedException e) - { - return null; - } - finally - { - if (gotLock) - { - GLOBAL_INSTANCE_LOCK.unlock(); - } - } - } - - private MetaDataModel loadMetadata(final IMetaDataModelContext context) { -// if (!Thread.holdsLock(GLOBAL_INSTANCE_LOCK.)) { -// JSFCommonPlugin -// .log(IStatus.ERROR, -// "Internal Error: loadMetadata must not be called if class lock not held"); //$NON-NLS-1$ -// return null; -// } - - final IDomainLoadingStrategy strategy = DomainLoadingStrategyRegistry - .getInstance().getLoadingStrategy( - context.getDomainId()); - ; - if (strategy == null) { - JSFCommonPlugin - .log( - IStatus.ERROR, - "Internal Error: Unable to locate metadata loading strategy for: " + context.toString()); //$NON-NLS-1$ - return null; - } - final MetaDataModel model = StandardModelFactory.getInstance().createModel( - context, strategy);// new MetaDataModel(modelKey, - // strategy); - model.load(); - addModel(model); - - return model; - } - - private void addModel(final MetaDataModel model) { - if (model != null) - models.put(model); - } - - @Override - public void dispose() { - super.dispose(); - models.dispose(); - } - - @Override - public void destroy() { - // no persistent data to cleanup. just call dispose - dispose(); - } - - /** - * Map of models keyed by DOMAIN_ID:MODEL_ID from the context. Project is not part of key. - * - */ - private static class ModelMap - { - final Map<String, MetaDataModel> map; - private final AtomicBoolean _isDisposed = new AtomicBoolean(false); - - ModelMap() { - map = new HashMap<String, MetaDataModel>(); - } - - /** - * @param model - * adds model to the map using the given key descriptor - */ - public void put(final MetaDataModel model) { - assert !_isDisposed.get(); - final String key = calculateKey(model); - synchronized (this) { - map.put(key, model); - } - } - - /** - * @param context - * @return MetaDataModel for this context. May return null. - */ - public MetaDataModel get(final IMetaDataModelContext context) { - assert !_isDisposed.get(); - - final String key = calculateKey(context); - - synchronized (this) - { - return map.get(key); - } - } - - public void dispose() { - if (_isDisposed.compareAndSet(false, true)) { - synchronized(this) - { - for (final Iterator<Map.Entry<String, MetaDataModel>> it = map.entrySet().iterator(); it.hasNext();) - { - // System.out.println("kill mmModel: "+model.toString()); - final Map.Entry<String, MetaDataModel> entry = it.next(); - final MetaDataModel model = entry.getValue(); - - if (model != null) - { - model.cleanup(); - } - it.remove(); - } - } - } - } - - private String calculateKey(final MetaDataModel model) { - return calculateKey(model.getModelContext()); - } - - private String calculateKey(final IMetaDataModelContext context) { - final StringBuffer buf = new StringBuffer(context.getDomainId()).append(":").append(context.getModelIdentifier()); //$NON-NLS-1$; - return buf.toString(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManagerFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManagerFactory.java deleted file mode 100644 index 246755b52..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManagerFactory.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation and/or initial documentation - *******************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.internal.pde.AbstractSimpleClassExtensionRegistryReader; -import org.eclipse.jst.jsf.common.internal.resource.ResourceSingletonObjectManager; -import org.eclipse.jst.jsf.common.internal.strategy.AbstractTestableExtensibleDefaultProviderSelectionStrategy; -import org.eclipse.jst.jsf.common.internal.strategy.ISimpleStrategy; -import org.eclipse.jst.jsf.common.internal.strategy.TestableResourceFactoryStrategy; - -/** - * Produces {@link IMetaDataModelManager}s - * - */ -public final class MetaDataModelManagerFactory extends ResourceSingletonObjectManager<IMetaDataModelManager, IResource> { - - private static MetaDataModelManagerFactory INSTANCE; - - private IMetaDataModelManagerFactory EXT_PT_BASED_FACTORY; - - //private constructor - private MetaDataModelManagerFactory(final IWorkspace workspace) { - super(workspace); - } - - /** - * Project property session key for testing. - * Project value should hold the testable {@link IMetaDataModelManagerFactory} instance or null - * NOT API - for testing purposes - */ - public static final QualifiedName TESTABLE_FACTORY_SESSION_KEY = new QualifiedName(JSFCommonPlugin.PLUGIN_ID, "MDModelManagerFactoryInstance"); //$NON-NLS-1$ - - /** - * @param project - * @return IMetaDataModelManager - */ - public static IMetaDataModelManager getMetaDataModelManagerInstance(final IProject project) { - try { - return getMetaDataModelManagerFactoryInstance(project).getInstance(project != null ? project : ResourcesPlugin.getWorkspace().getRoot()); - } catch (ManagedObjectException e) { - if (project != null) - JSFCommonPlugin.log(e, "Cannot create IMetaDataModelManager for "+project.getName()+ " (1)"); //$NON-NLS-1$ //$NON-NLS-2$ - else - JSFCommonPlugin.log(e, "Cannot create workspace shared IMetaDataModelManager (1)"); //$NON-NLS-1$ - } - return null; - } - - private synchronized static MetaDataModelManagerFactory getMetaDataModelManagerFactoryInstance(final IProject project) { - if (INSTANCE == null) { - final IWorkspace workspace = getWorkspace(project); - INSTANCE = new MetaDataModelManagerFactory(workspace); - INSTANCE.init(); - } - return INSTANCE; - } - - private static IWorkspace getWorkspace(final IProject project) { - if (project != null) - return project.getWorkspace(); - - return ResourcesPlugin.getWorkspace(); - } - - - private void init() { - final MetaDataModelManagerFactoryExtensionPointReader reader = new MetaDataModelManagerFactoryExtensionPointReader(); - final List<IMetaDataModelManagerFactory> res = reader.getExtensions(); - if (res != null && res.size() > 0) {//return first - EXT_PT_BASED_FACTORY = res.get(0); - } - } - - @Override - protected IMetaDataModelManager createNewInstance(final IResource resource) { - try { - final IMetaDataModelManagerFactory factory = getMetaDataModelManagerFactoryProviderInstances(resource); - if (factory != null) - return factory.getInstance(resource); - } catch (Exception e) { - if (resource != null) - JSFCommonPlugin.log(e, "Cannot create IMetaDataModelManager for "+resource.getName()+ " (2)"); //$NON-NLS-1$ //$NON-NLS-2$ - else - JSFCommonPlugin.log(e, "Cannot create workspace shared IMetaDataModelManager (2)"); //$NON-NLS-1$ - } - return null; - } - - private IMetaDataModelManagerFactory getMetaDataModelManagerFactoryProviderInstances(final IResource resource) { - final CompositeFactorySelectionStrategyProvider factoryProvider = new CompositeFactorySelectionStrategyProvider(); - return factoryProvider != null ? factoryProvider.getFactoryToUse(resource) : null; - } - - private class CompositeFactorySelectionStrategyProvider - { - public IMetaDataModelManagerFactory getFactoryToUse(final IResource resource) { - final MetaDataModelManagerProviderSelectionStrategy providerSelector = new MetaDataModelManagerProviderSelectionStrategy(); - addStrategies(providerSelector); - - final IMetaDataModelManagerFactory provider = providerSelector.perform(resource); - if (provider != providerSelector.getNoResult()) - { - return provider; - } - return null; - } - - private void addStrategies(final MetaDataModelManagerProviderSelectionStrategy providerSelector) { - providerSelector.addDefaultStrategy(new DefaultManagerProviderStrategy()); - providerSelector.addExtensionStrategy(new ExtensionBasedManagerProviderStrategy()); - providerSelector.addTestableStrategy(new TestableManagerProviderStrategy(TESTABLE_FACTORY_SESSION_KEY)); - } - - } - - private static class MetaDataModelManagerProviderSelectionStrategy - extends - AbstractTestableExtensibleDefaultProviderSelectionStrategy<IResource, IMetaDataModelManagerFactory> { - - private static final IMetaDataModelManagerFactory NO_RESULT = null; - - @Override - public IMetaDataModelManagerFactory getNoResult() { - return NO_RESULT; - } - } - - private abstract class AbstractManagerProviderStrategy - implements ISimpleStrategy<IResource, IMetaDataModelManagerFactory> { - - private final IMetaDataModelManagerFactory NO_RESULT = null; - public IMetaDataModelManagerFactory getNoResult() { - return NO_RESULT; - } - } - - private class DefaultManagerProviderStrategy extends - AbstractManagerProviderStrategy { - - public IMetaDataModelManagerFactory perform(final IResource input) throws Exception { - return new DefaultManagerProvider(); - } - - } - - private static class DefaultManagerProvider - implements IMetaDataModelManagerFactory { - - public IMetaDataModelManager getInstance(final IResource project) { - if (project != null && project instanceof IProject) - return new MetaDataModelManager((IProject)project); - return MetaDataModelManager.getSharedInstance(); - } - - } - - private class ExtensionBasedManagerProviderStrategy - extends AbstractManagerProviderStrategy { - - public IMetaDataModelManagerFactory perform(final IResource input) throws Exception { - return EXT_PT_BASED_FACTORY != null ? EXT_PT_BASED_FACTORY : getNoResult(); - } - } - - private static class TestableManagerProviderStrategy<IMetaDataModelManagerFactory> - extends TestableResourceFactoryStrategy<IMetaDataModelManagerFactory> { - - /** - * @param testableFactorySessionKey - project property session key for property value holding testable instance - */ - public TestableManagerProviderStrategy(final QualifiedName testableFactorySessionKey) { - super(testableFactorySessionKey); - } - - } - - private static class MetaDataModelManagerFactoryExtensionPointReader extends - AbstractSimpleClassExtensionRegistryReader<IMetaDataModelManagerFactory> { - - private static final String EXT_PT_ID = "mdModelManagerFactory"; //$NON-NLS-1$ - private static final String EXT_PT_ELEMENT = "factory"; //$NON-NLS-1$ - private static final String EXT_PT_ATTR = "class"; //$NON-NLS-1$ - - protected MetaDataModelManagerFactoryExtensionPointReader() { - super( - JSFCommonPlugin.PLUGIN_ID, - EXT_PT_ID, EXT_PT_ELEMENT, EXT_PT_ATTR, - new CompareOrgEclipseJstContributorsLastComparator<IMetaDataModelManagerFactory>() - ); - } - - @Override - protected void handleLoadFailure(final CoreException ce) { - JSFCommonPlugin.log(ce, - "Error loading IMetaDataModelManagerFactory from extension"); //$NON-NLS-1$ - - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java deleted file mode 100644 index 564d7a854..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java +++ /dev/null @@ -1,398 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.MetaDataException; -import org.eclipse.jst.jsf.common.metadata.query.internal.HierarchicalSearchControl; -import org.eclipse.jst.jsf.common.metadata.query.internal.IMetaDataQuery; -import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryFactory; -import org.eclipse.jst.jsf.common.metadata.query.internal.SearchControl; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleEntityQueryVisitorImpl; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleResultSet; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleTraitQueryVisitorImpl; -/** - * Implements {@link IMetaDataModelMergeAssistant} - * - * Responsible for merging source models into one. The first model in has subsequent - * entities and traits added to it. - * - * TODO - make locating of existing entities and traits in the merged model more efficient - * TODO - refactor out Taglibdomain-only aspects of include-group processing - * - */ -public class MetaDataModelMergeAssistantImpl implements - IMetaDataModelMergeAssistant { - - private MetaDataModel mergedModel; - private SimpleEntityQueryVisitorImpl entityVisitor; - private SimpleTraitQueryVisitorImpl traitVisitor; - private IMetaDataSourceModelProvider provider; - - /** - * Constructor. Queries with search control limited to first found. - * @param model - */ - public MetaDataModelMergeAssistantImpl(final MetaDataModel model) { - this.mergedModel = model; - entityVisitor = new SimpleEntityQueryVisitorImpl(new HierarchicalSearchControl(1, - HierarchicalSearchControl.SCOPE_ALL_LEVELS)); - traitVisitor = new SimpleTraitQueryVisitorImpl(new SearchControl(1)); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#getMergedModel() - */ - public MetaDataModel getMergedModel() { - return mergedModel; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#getSourceModel() - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return provider; - } - - public void setSourceModelProvider(final IMetaDataSourceModelProvider provider) { - this.provider = provider; - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addEntityGroup(org.eclipse.jst.jsf.common.metadata.EntityGroup) - */ - public void addEntityGroup(final EntityGroup entityGroup) { - final Model model = (Model)getMergedModel().getRoot(); - if (!isExistingEntityGroup(model, entityGroup)){ - model.getEntityGroups().add(copyEntityGroup(entityGroup)); - } - } - - private EntityGroup copyEntityGroup(final EntityGroup entityGroup) { - final Copier copier = new Copier(); - final EntityGroup egc =(EntityGroup)copier.copy(entityGroup); - copier.copyReferences(); - return egc; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addEntity(org.eclipse.jst.jsf.common.metadata.Entity) - */ - public Entity addEntity(final Entity entity) { - Entity mmEntity = getMergedEntity(entity); - if (mmEntity == null){ - mmEntity = addEntityAsNecessary((Entity)entity.eContainer(), entity); - return mmEntity; - } - addIncludeGroupsAsNecessary(mmEntity, entity); - return mmEntity; - } - - public Entity getMergedEntity(final Entity queryRoot, final String entityKey){ - Entity ret = null; - SimpleResultSet rs = (SimpleResultSet)entityVisitor.findEntities(queryRoot, entityKey); - try { - if (! rs.getResults().isEmpty()) - ret = (Entity)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedEntity()", e); //$NON-NLS-1$ - } - return ret; - } - private void addIncludeGroupsAsNecessary(final Entity mmEntity, final Entity entity) { - for (final Iterator it=entity.getIncludeGroups().iterator();it.hasNext();){ - final IncludeEntityGroup grp = (IncludeEntityGroup)it.next(); - boolean found = false; - for (Iterator it2=mmEntity.getIncludeGroups().iterator();it2.hasNext();){ - final IncludeEntityGroup grp2 = (IncludeEntityGroup)it2.next(); - if (grp2.equals(grp)){ - found = true; - break; - } - } - if (!found){//maybe we should clone and add - mmEntity.getIncludeGroups().add(grp); - } - } - } - - /** - * Checks to see if the entity (by id) is present in the mergedModel or not. - * If not, it will perform a copy of the entity and it's attributes using - * EcoreUtil.Copier. - * - * @param parent - * @param entity - * @return - */ - private Entity addEntityAsNecessary(final Entity parent, final Entity entity) { - Entity mmParent = null; - Entity mmEntity = null; - if (parent != null){ - mmParent = getMergedEntity(parent); - if (mmParent == null){ - mmParent = addEntityAsNecessary((Entity)entity.eContainer(), entity); - } - } - if (mmParent != null){ - mmEntity = addEntityInternal(mmParent, entity); - return mmEntity; - } - return mmEntity; - } - - private boolean isExistingEntityGroup(final Model model, final EntityGroup entityGroup) { - boolean found = false; - for(final Iterator it=model.getEntityGroups().iterator();it.hasNext();){ - if (entityGroup.getId().equals(((EntityGroup)it.next()).getId())) - return true; - } - return found; - } - - private Entity getExistingChildEntity(final Entity parent, final Entity entity) { - for(final Iterator it=parent.getChildEntities().iterator();it.hasNext();){ - final Entity foundEntity = (Entity)it.next(); - if (entity.getId().equals(foundEntity.getId())) - return foundEntity; - } - return null; - } - - private /*synchronized*/ Entity addEntityInternal(final Entity parent, final Entity entity) { - final Copier copier = new Copier(); - final Entity mmEntity =(Entity)copier.copy(entity); - copier.copyReferences(); - parent.getChildEntities().add(mmEntity); - return mmEntity; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addTrait(org.eclipse.jst.jsf.common.metadata.Entity, org.eclipse.jst.jsf.common.metadata.Trait) - */ - public boolean addTrait(final Entity entity, final Trait trait) { - final Entity returnedEntity = getMergedEntity(entity); - if (returnedEntity != null){ - return addTraitAsNecessary(returnedEntity, trait); - } - return false; - } - - - private boolean addTraitAsNecessary(Entity mergedEntity, Trait trait) { - final Trait mmTrait = getMergedTrait(mergedEntity, trait); - if (mmTrait == null){ - addTraitInternal(mergedEntity, trait); - return true; - - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#setMergeComplete() - */ - public void setMergeComplete() { - final Model model = (Model)getMergedModel().getRoot(); - if (model != null){ - StandardModelFactory.debug(">> Begin processIncludeGroups for: "+getMergedModel().getModelContext(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - - processIncludeGroups(model); - - StandardModelFactory.debug(">> End processIncludeGroups for: "+getMergedModel().getModelContext(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - } - - /** - * Copies the passed trait and adds it to the merged entity. - * The source model provider of the trait is then set on the trait so that - * the trait can know where it came from. - * - * @param parent - * @param trait - * @return merged Trait - */ - private Trait addTraitInternal(final Entity parent, final Trait trait) { - final Copier copier = new Copier(); - final Trait mmTrait =(Trait)copier.copy(trait); - copier.copyReferences(); - parent.getTraits().add(mmTrait); - //set the model key to know from where the trait came - mmTrait.setSourceModelProvider(trait.getSourceModelProvider()); - return mmTrait; - } - - /** - * Locates the entity in the merged model matching by id only. - * If not located, this method returns null; - * - * @param entity - * @return merged entity - */ - private Entity getMergedEntity(final Entity entity){ - if (entity instanceof Model) - return (Entity)mergedModel.getRoot(); - - Entity ret = null; - final String entityKey = getIdRelativeToRoot(entity); - final SimpleResultSet rs = (SimpleResultSet)entityVisitor.findEntities((Entity)mergedModel.getRoot(), entityKey); - try { - if (! rs.getResults().isEmpty()) - ret = (Entity)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedEntity()", e); //$NON-NLS-1$ - } - return ret; - } - - private String getIdRelativeToRoot(final Entity entity) { - Entity e = entity; - final StringBuffer buf = new StringBuffer(); - while (e.eContainer() != null){ - buf.insert(0, e.getId()); - if (e.eContainer()!=null && e.eContainer().eContainer() != null) - buf.insert(0,"/"); //$NON-NLS-1$ - e = (Entity)e.eContainer(); - } - return buf.toString(); - } - - /** - * Locates the trait in the merged model matching by id only. - * If not located, this method returns null; - * - * @param entity - * @param trait - * @return merged Trait - */ - public Trait getMergedTrait(final Entity entity, final Trait trait){ - final SimpleResultSet rs = (SimpleResultSet)traitVisitor.findTraits(entity, trait.getId()); - Trait ret = null; - try { - if (! rs.getResults().isEmpty()) - ret = (Trait)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedTrait()", e); //$NON-NLS-1$ - } - return ret; - } - - private void processIncludeGroups(final Model root) { - addEntityGroupReferencesRecursively(root); - } - - private void addEntityGroupReferencesRecursively(final Entity entity) { - doIncludes(entity); - for (int i=0, size=entity.getChildEntities().size();i<size;i++){ - addEntityGroupReferencesRecursively((Entity)entity.getChildEntities().get(i)); - } - } - - private void doIncludes(final Entity entity){ - for (int j=0, groupsSize=entity.getIncludeGroups().size();j<groupsSize; j++){ - final IncludeEntityGroup include = (IncludeEntityGroup)entity.getIncludeGroups().get(j); - if (include.getId() != null){ - //is this a local merge? - if (include.getModelUri() == null|| - (include.getModelUri() - .equals(getMergedModel() - .getModelContext().getModelIdentifier())) ){ - final EntityGroup eg = ((Model)getMergedModel().getRoot()).findIncludeGroup(include.getId()); - addIncludeRefs(entity, eg); - } else //external model include - addIncludeRefs(entity, include); - } - } - } - /* - * Adds traits and child entities from an external entity group to the passed entity - * @param entity - * @param include - */ - private void addIncludeRefs(final Entity entity, final IncludeEntityGroup include) { - final IMetaDataModelContext modelContext = getMergedModel().getModelContext(); - final IMetaDataQuery query = MetaDataQueryFactory.getInstance().createQuery(modelContext); - final Model externalModel = query.getQueryHelper().getModel(include.getModelUri()); - if (externalModel != null){ - final EntityGroup entityGroup = externalModel.findIncludeGroup(include.getId()); - addIncludeRefs(entity, entityGroup); - } - else { - JSFCommonPlugin.log(IStatus.ERROR, "Unable to load external metadata model refs for "+modelContext.getModelIdentifier() //$NON-NLS-1$ - + " into "+ include.getModelUri()); //$NON-NLS-1$ - } - } - - /* - * Adds traits and child entities from a local entity group to the passed entity if not already present for the entity. - * First - * @param entity - * @param entityGroup - */ - private void addIncludeRefs(final Entity entity, final EntityGroup entityGroup) { - if (entityGroup == null) - return; - - for (int i=0, size=entityGroup.getTraits().size();i<size;i++){ - addTrait(entity, (Trait)entityGroup.getTraits().get(i)); - } - - for (int i=0, size=entityGroup.getChildEntities().size();i<size;i++){ - traverseAndAddIncludes(entity, (Entity)entityGroup.getChildEntities().get(i)); - } - } - - private void traverseAndAddIncludes(final Entity parent, final Entity entity){ - final Entity mergedEntity = addIncludedEntityAsNecessary(parent, entity); - - for (final Iterator/*<Trait>*/ it=entity.getTraits().iterator();it.hasNext();){ - final Trait trait = (Trait)it.next(); - addTraitAsNecessary(mergedEntity, trait); - } - - for (final Iterator/*<EntityKey>*/ it=entity.getChildEntities().iterator();it.hasNext();){ - final Entity e = (Entity)it.next(); - traverseAndAddIncludes(mergedEntity, e);//add as normal - } - - } - - /* - * Checks to see if the entity (by id) is present as a child entity in the parent or not. - * If not, it will add the entity to the childEntities without copying. - * - * @param parent - * @param entity - * @return Entity - */ - private Entity addIncludedEntityAsNecessary(final Entity parent, final Entity entity) { - Entity mergedEntity = getExistingChildEntity(parent, entity); - if (mergedEntity == null){ - mergedEntity = addEntityInternal(parent, entity); - } - return mergedEntity; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java deleted file mode 100644 index 380d21844..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; - -/** - * Meta data model key descriptor used to lazily load a model when it is required - * - */ -public class ModelKeyDescriptor { - private final IProject project; - private final String domain; - private final String uri; - private final String key; - - /** - * Constructor - * @param project - * @param domain - * @param uri - */ - public ModelKeyDescriptor(final IProject project, final String domain, final String uri){ - this.project = project; - this.domain = domain; - this.uri = fixJSPURIIfNecessary(uri); - final String proj = project != null ? project.getName() : "Null"; //$NON-NLS-1$ - final StringBuffer buf = new StringBuffer(proj); - buf.append(":"); //$NON-NLS-1$ - buf.append(this.domain); - buf.append(":"); //$NON-NLS-1$ - buf.append(this.uri); - key = buf.toString(); - } - - //this is a workaround for issue where jsp "uri" may upper or lower cased - private String fixJSPURIIfNecessary(final String tempuri) { - if (tempuri != null && tempuri.equals("jsp11")) //$NON-NLS-1$ - return tempuri.toUpperCase(); - return tempuri; - } - - /** - * @return domain id - */ - public final String getDomain(){ - return domain; - } - - /** - * @return model uri - */ - public final String getUri(){ - return uri; - } - - /** - * @return project - */ - public final IProject getProject(){ - return project; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public final String toString(){ - return key; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java deleted file mode 100644 index 34b90b125..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Experimental - * - */ -public class ModelNotSetException extends Exception { - private static final long serialVersionUID = 1L; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java deleted file mode 100644 index db7ed2a06..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; - -/** - * Default implementation of StandardMetaDataSourceFileLocator that will locate standard metadata files - * and resource bundles relative to the plugin that registered the files using the - * <code>org.eclipse.jst.jsf.common.StandardMetaDataFiles</code> ext-pt. - * - */ -public class PluginRelativeStandardMetaDataSourceFileLocator extends StandardMetaDataSourceFileLocator{ - - private ResourceBundle resourceBundle; - - /* - * Returns InputStream of standard metadata file from plugin relative location. - * - */ - public InputStream getInputStream() throws IOException { - URL url = getURL(); - if (url != null) - return url.openStream(); - - String fileName = Path.fromOSString(fileInfo.getLocation()).toString() + " (Plugin: " + fileInfo.getBundleId()+")" ; //$NON-NLS-1$ //$NON-NLS-2$ - throw new FileNotFoundException("Metadata file not found: "+ fileName); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataSourceFileLocator#getURL() - */ - public URL getURL() { - final Bundle bundle = Platform.getBundle(fileInfo.getBundleId()); - if (bundle == null) - { - return null; - } - final IPath fromOSString = Path.fromOSString(fileInfo.getLocation()); - return FileLocator.find(bundle, fromOSString, null); - } - - - /* - * Returns property resource bundle if it exists. May return null. - * This implementation assumes that the basename of the bundle is the same - * as the source file name and in the same directory. - * - */ - public ResourceBundle getResourceBundle() throws IOException, MalformedURLException { - if (resourceBundle == null){ - URL bundleURL = getStandardMetaDataSourceFileBasenameURL(); - if (bundleURL == null) - return null; - - resourceBundle = ResourceBundleHelper.getResourceBundle(bundleURL); - } - return resourceBundle; - } - - private URL getStandardMetaDataSourceFileBasenameURL() { - IPath annotationPath = Path.fromOSString(fileInfo.getLocation()); - IPath annotationFolder = annotationPath.removeLastSegments(1); - IPath propertiesLocation = annotationPath.removeFirstSegments(annotationPath.segmentCount() - 1).removeFileExtension(); - // append location of properties file - IPath propertiesFile = annotationFolder.append(propertiesLocation); - - // append .properties extension if needed - if (propertiesFile.getFileExtension() == null) - propertiesFile = propertiesFile.addFileExtension("properties"); //$NON-NLS-1$ - // create a URL out of the properties file location - return FileLocator.find(Platform.getBundle(fileInfo.getBundleId()), - propertiesFile, null); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java deleted file mode 100644 index fc55894db..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - copied from org.eclipse.wst.sse.core.internal.encoding.util and modified heavily - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Locale; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * ResourceBundleHelper - * - */ -public final class ResourceBundleHelper { - - /** - * @param resourceURL - * @return ResourceBundle - * @throws MalformedURLException - may return null - * @throws IOException - */ - public static ResourceBundle getResourceBundle(final URL resourceURL) throws MalformedURLException, IOException { - return getResourceBundle(resourceURL, Locale.getDefault()); - } - - /** - * @param resourceURL - * @param targetLocale - * @return ResourceBundle - may return null - * @throws MalformedURLException - * @throws IOException - */ - public static ResourceBundle getResourceBundle(final URL resourceURL, final Locale targetLocale) throws MalformedURLException, IOException { - // try to load bundle from the location specified in the resourceURL - // - final String protocol = resourceURL.getProtocol(); - final String host = resourceURL.getHost(); - final String file = resourceURL.getFile(); - final IPath path = new Path(file); - - String dir = "./"; //$NON-NLS-1$ - final String bundleName = path.removeFileExtension().segment(path.segmentCount() - 1); - if (path.segmentCount() > 1) - { - dir = path.removeLastSegments(1).toString(); - } - - // create a class loader with a class path that points to the resource - // bundle's location - // - final URL[] classpath = new URL[1]; - classpath[0] = FileLocator.resolve(new URL(protocol, host, dir)); - // TODO: does this need to be in a doPrivileged block? - final ClassLoader resourceLoader = new URLClassLoader(classpath, null); - - return ResourceBundle.getBundle(bundleName, targetLocale, resourceLoader); - } - - private ResourceBundleHelper() - { - // no instantiation - } -} - diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java deleted file mode 100644 index 25cc1c208..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Contains information about annotation files. - */ -public final class StandardMetaDataFileInfo implements IStandardMetaDataSourceInfo{ - - private final String fileLocation; - private final String fileLocatorClassname; - private final String bundleId; - - /** - * Constructor - * @param fileLocation - * @param bundleId - * @param fileLocatorClassname - */ - public StandardMetaDataFileInfo( String fileLocation, String bundleId, String fileLocatorClassname) { - this.fileLocation = fileLocation.trim(); - this.bundleId = bundleId.trim(); - this.fileLocatorClassname = fileLocatorClassname; - } - - /** - * Get the location of the annotation file as originally specified. - * - * @return String - */ - public String getLocation() { - return fileLocation; - } - - /** - * Get the annotation file locator classname that must implement ICMAnnotationSourceFileLocator. - * Can return null or empty string. Caller should provide default. - * - * @return String - */ - public String getLocatorClassname() { - return fileLocatorClassname != null ? fileLocatorClassname.trim() : null; - } - - /** - * Get the bundle id of the plugin where the annotation file is located. - * - * @return String - */ - public String getBundleId() { - return bundleId; - } - - public String toString(){ - StringBuffer buf = new StringBuffer("StandardMetaDataFileInfo"); //$NON-NLS-1$ - buf.append(": "); //$NON-NLS-1$ - buf.append(bundleId); - buf.append("/"); //$NON-NLS-1$ - buf.append(fileLocation); - if (getLocatorClassname() != null){ - buf.append(": "); //$NON-NLS-1$ - buf.append(getLocatorClassname()); - } - return buf.toString(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java deleted file mode 100644 index 49d0d4e5b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - code borrowed and repurposed for JSF subproject - * - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; - - -/** - * Registry of standard metadata files - */ -public final class StandardMetaDataFileRegistry { - private Map<String, List<IMetaDataSourceModelProvider>> mdFilesMap = new HashMap<String, List<IMetaDataSourceModelProvider>>(1); - private List<IMetaDataSourceModelProvider> EMPTY_LIST = new ArrayList<IMetaDataSourceModelProvider>(0); - - private static StandardMetaDataFileRegistry reg; - - /** - * @return the singleton instance of the registry - */ - public synchronized static StandardMetaDataFileRegistry getInstance() { - if (reg == null){ - reg = new StandardMetaDataFileRegistry(); - } - return reg; - } - - private StandardMetaDataFileRegistry() { - new StandardMetaDataFileRegistryReader(this).readRegistry(); - } - - /** - * @param uri as String - * @return list of standard metadata sources as <code>IMetaDataSourceModelProvider</code>s. - * Returns empty list of no standard metadata files are registered for the given uri. - */ - public synchronized List<IMetaDataSourceModelProvider> getStandardMetaDataModelProviders(String uri) { - List<IMetaDataSourceModelProvider> theList = mdFilesMap.get(uri); - return theList != null ? theList : EMPTY_LIST ; - } - - /** - * For use by registry reader only - * @param uri - * @param fileInfo - */ - public synchronized void addStandardMetaDataFileInfo(String uri, IStandardMetaDataSourceInfo fileInfo) { - List<IMetaDataSourceModelProvider> providers = mdFilesMap.get(uri); - if (providers == null) { - providers = new ArrayList<IMetaDataSourceModelProvider>(); - mdFilesMap.put(uri, providers); - } - providers.add(new StandardMetaDataFilesProvider(fileInfo)); - } - -/** - * Internal implementation of IMetaDataSourceModelProvider for "standard" metadata sources - * - */ -static class StandardMetaDataFilesProvider implements IMetaDataSourceModelProvider { - - private org.eclipse.jst.jsf.common.metadata.internal.IStandardMetaDataSourceInfo info; - private Object model; - private IMetaDataLocator locator; - private StandardMetaDataSourceFileLocator fileLocator = null; - - /** - * Constructor - * @param info - */ - StandardMetaDataFilesProvider(IStandardMetaDataSourceInfo info){ - this.info = info; - } - - private StandardMetaDataSourceFileLocator getFileLocator(){ - if (fileLocator == null){ - if (info.getLocatorClassname() == null){ - fileLocator = new PluginRelativeStandardMetaDataSourceFileLocator(); - } - else { - Class klass = JSFCommonPlugin.loadClass(info.getLocatorClassname(), info.getBundleId()); - try { - fileLocator = (StandardMetaDataSourceFileLocator)klass.newInstance(); - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InstantiationException: StandardMetaDataFilesProvider.getFileLocator()", e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException: StandardMetaDataFilesProvider.getFileLocator()", e); //$NON-NLS-1$ - } - } - if (fileLocator != null) - fileLocator.setFileInfo(info); - } - return fileLocator; - } - - private InputStream getInputStream() throws IOException { - if (getFileLocator() != null){ - return getFileLocator().getInputStream(); - } - return null; - - } - - private URI getMDFileURI() - { - try - { - StandardMetaDataSourceFileLocator fileLocator2 = getFileLocator(); - if (fileLocator2 != null) - { - final URL url = fileLocator2.getURL(); - if (url == null) - { - JSFCommonPlugin.log(new RuntimeException(), - "Couldn't locate meta-data file for " //$NON-NLS-1$ - + fileLocator2.getFileInfo() - .getLocation()); - return null; - } - - java.net.URI uri = url.toURI(); - return URI.createURI(uri.toString()); - } - } - catch (URISyntaxException e) - { - JSFCommonPlugin.log(IStatus.ERROR, "Metadata File Load Error: " //$NON-NLS-1$ - + getFileLocator().getFileInfo().toString() - + ": URISyntaxException: " + e.getMessage()); //$NON-NLS-1$ - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getSourceModel() - */ - public Object getSourceModel() { - if (model != null) - return model; - - InputStream inputStream = null; - try { - URI uri = getMDFileURI(); - inputStream = getInputStream(); - if (inputStream != null && uri != null){ - EList contents = StandardModelFactory.getInstance().loadStandardFileResource(inputStream, this, uri); - //check to see if this is a Model - if (contents != null && !contents.isEmpty() && - contents.get(0) instanceof Model){ - model = contents.get(0); - ((Model)model).setSourceModelProvider(this); - } - } - } catch (FileNotFoundException e){ - JSFCommonPlugin.log(IStatus.ERROR, e.getLocalizedMessage()); - } catch (IOException e) { - JSFCommonPlugin.log(IStatus.ERROR,"IOException(1): StandardMetaDataFilesProvider.getSourceModel():"+getModelName(), e); //$NON-NLS-1$ - } finally { - if (inputStream != null){ - try { - inputStream.close(); - } catch (IOException e) { - JSFCommonPlugin.log( IStatus.ERROR,"IOException (2): StandardMetaDataFilesProvider.getSourceModel():"+getModelName(), e); //$NON-NLS-1$ - } - } - } - return model; - } - - private String getModelName() { - return info.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getLocator() - */ - public IMetaDataLocator getLocator() { - return locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#setLocator(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator) - */ - public void setLocator(IMetaDataLocator locator) { - this.locator = locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getResourceBundle() - */ - private ResourceBundle internalGetResourceBundle() { - if (getFileLocator() != null){ - try { - return fileLocator.getResourceBundle(); - } catch (MissingResourceException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle1", e); //$NON-NLS-1$ - } catch (IOException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle2", e); //$NON-NLS-1$ - } - } - return null; - } - - public Object getAdapter(Class klass) { - final StandardMetaDataFilesProvider mdp = this; - if (klass == IImageDescriptorProvider.class){ - return new IImageDescriptorProvider(){ - String imageBase; - public ImageDescriptor getImageDescriptor(String imagePath) { - imagePath = appendImageBase(imagePath); - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - URL url = FileLocator.find(Platform.getBundle(bundleID), new Path(imagePath), null); - return ImageDescriptor.createFromURL(url); - } - private String appendImageBase(String imagePath) { - return getImageBase() + imagePath; - } - - private String getImageBase(){ - if (imageBase == null){ - final Model aModel = (Model)getSourceModel(); - final Trait t = getImageBasePath(aModel); - if (t == null){ - imageBase = ""; //$NON-NLS-1$ - } else { - imageBase = TraitValueHelper.getValueAsString(t); - if (imageBase != null && imageBase.length() > 0){ - imageBase = imageBase +"/"; //$NON-NLS-1$ - } - } - } - return imageBase; - } - - private Trait getImageBasePath(final Model aModel) { - for (final Iterator it= aModel.getTraits().iterator(); it.hasNext();) { - Trait t = (Trait)it.next(); - if (t.getId().equals("images-base-path")){ //$NON-NLS-1$ - return t; - } - } - return null; - } - - }; - - } else if (klass == IResourceBundleProvider.class) { - return new IResourceBundleProvider(){ - - public ResourceBundle getResourceBundle() { - return mdp.internalGetResourceBundle(); - } - - }; - - } else if (klass == IClassLoaderProvider.class){ - return new IClassLoaderProvider(){ - - public Class loadClass(String className) { - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - try { - return Platform.getBundle(bundleID).loadClass(className); - } catch (ClassNotFoundException e) { - return null; - } - } - - }; - } else if (klass == IResourceURLProvider.class) { - return new IResourceURLProvider() { - - public URL getResourceURL(String resourcePath) { - URL resourceURL = null; - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - try { - resourceURL = FileLocator.resolve(Platform.getBundle(bundleID).getResource(resourcePath)); - } catch (IOException ioe) { - //do nothing, will return null resourceURL - } - return resourceURL; - } - - }; - } - return null; - } - -} -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java deleted file mode 100644 index 802481b3c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - code borrowed and repurposed for JSF subproject - * - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - - -/** - * This class reads the standardMetaDataFiles extensions adds each specified standard metadata - * file to the StandardMetaDataFileRegistry. - * - * @see StandardMetaDataFileRegistry - * also see StandardMetaDataFile extension-point - */ -public class StandardMetaDataFileRegistryReader { - /** - * EXTENSION POINT ID - */ - protected static final String EXTENSION_POINT_ID = "standardMetaDataFiles"; //$NON-NLS-1$ - /** - * IConfigurationElement element name - */ - protected static final String TAG_NAME = "StandardMetaDataFile"; //$NON-NLS-1$ - /** - * Uri attribute name for IConfigurationElement - */ - protected static final String ATT_URI = "uri"; //$NON-NLS-1$ - /** - * Location attribute name for IConfigurationElement - */ - protected static final String ATT_LOCATION = "location"; //$NON-NLS-1$ - /** - * Locator attribute name for IConfigurationElement - */ - protected static final String ATT_LOCATOR = "locator"; //$NON-NLS-1$ - - private StandardMetaDataFileRegistry annotationFileRegistry; - - /** - * Constructor - * @param registry - */ - public StandardMetaDataFileRegistryReader(StandardMetaDataFileRegistry registry) { - this.annotationFileRegistry = registry; - } - - /** - * read the registery - */ - public void readRegistry() { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - readElement(elements[i]); - } - } - } - - private void readElement(IConfigurationElement element) { - if (element.getName().equalsIgnoreCase(TAG_NAME)) { - String uri = element.getAttribute(ATT_URI); - String location = element.getAttribute(ATT_LOCATION); - String locator = element.getAttribute(ATT_LOCATOR); - String bundleId = null; - if (uri != null && location != null) { - try { - bundleId = element.getContributor().getName(); - StandardMetaDataFileInfo fileInfo = new StandardMetaDataFileInfo(location, bundleId, locator); - annotationFileRegistry.addStandardMetaDataFileInfo(uri, fileInfo); - } - catch (Exception e) { - JSFCommonPlugin.log(IStatus.ERROR, "Internal Error: exception occurred while reading StandardMetaDataFile ext-pt: "+location + ":"+uri, e); //$NON-NLS-1$ //$NON-NLS-2$ } - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java deleted file mode 100644 index 6695ec5a1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataFileRegistry.StandardMetaDataFilesProvider; - - -/** - * A 'null' translation of a metadata file. Entities and traits are not transformed. - * - */ -public class StandardMetaDataFilesTranslator implements IMetaDataTranslator { - - public boolean canTranslate(final IMetaDataSourceModelProvider modelProvider) { - if (modelProvider instanceof StandardMetaDataFilesProvider) - return true; - return false; - } - - public void translate(final IMetaDataModelMergeAssistant assistant) {//TODO: throw proper errors - //null translate - sourceModel object are already Entities and traits - //traverse the tree and add to model - - //temp - throw proper errors - //assert assistant.getSourceModel() instanceof ModelKeyDescriptor; - - final MetaDataModel mm = assistant.getMergedModel(); - final Model mk = (Model)assistant.getSourceModelProvider().getSourceModel(); - if (mm.getRoot() == null) { - //create copy, otherwise source model becomes merged model because of reference - final Copier copier = new Copier(); - final Model newModel = (Model)copier.copy(mk.getModel()); - copier.copyReferences(); - mm.setRoot(newModel); - } - else { - //for each entity and trait call "add". assistant will handle merge. - if (mk != null) {//possible that model was not loaded - traverseAndAdd(assistant, mk); - } else if (StandardModelFactory.DEBUG_MD_LOAD) { - JSFCommonPlugin.log(IStatus.ERROR,"Unable to load source model: "+assistant.getSourceModelProvider()); //$NON-NLS-1$ - } - } - } - - /** - * Add entity and any children - * @param assistant - * @param entity - */ - protected void traverseAndAdd(final IMetaDataModelMergeAssistant assistant, final Entity entity){ - final Entity mmEntity = assistant.addEntity(entity); - - if (entity instanceof Model){ - final Model model = (Model)entity; - for (final Iterator/*EntityGroup*/ it=model.getEntityGroups().iterator();it.hasNext();){ - assistant.addEntityGroup((EntityGroup)it.next()); - } - } - - for (final Iterator/*<Trait>*/ it=entity.getTraits().iterator();it.hasNext();){ - final Trait trait = (Trait)it.next(); - assistant.addTrait(mmEntity, trait); - } - - for (final Iterator/*<EntityKey>*/ it=entity.getChildEntities().iterator();it.hasNext();){ - final Entity e = (Entity)it.next(); - traverseAndAdd(assistant, e); - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java deleted file mode 100644 index 331717055..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.List; - - -/** - * Implementation of IMetaDataLocator for standard metadata sources. - * Uses StandardMetaDataFileRegistry to locate instances. - * - */ -public class StandardMetaDataLocator extends AbstractMetaDataLocator { - - public List<IMetaDataSourceModelProvider> locateMetaDataModelProviders(String uri) { - return StandardMetaDataFileRegistry.getInstance().getStandardMetaDataModelProviders(uri); - } - - /* - * Does nothing. - */ - public void startLocating() { - //do nothing - } - - /* - * Does nothing. - */ - public void stopLocating() { - //do nothing - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java deleted file mode 100644 index e65d0dab2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - - -/** - * Used to supply an InputStream to the parser of an annotation - * meta-data file and the URL to the resource bundle for a properties file, if any. - * - * Implementors must provide a zero-argument constructor. - * - * CURRENTLY INTERNAL... WILL BE MADE API AT SOME POINT - * - */ -public abstract class StandardMetaDataSourceFileLocator { - /** - * metadata file to locate - */ - protected IStandardMetaDataSourceInfo fileInfo; - - /** - * Set the <code>IStandardMetaDataSourceInfo</code> for this locator - * @param fileInfo - */ - public final void setFileInfo(IStandardMetaDataSourceInfo fileInfo){ - this.fileInfo = fileInfo; - } - - /** - * @return the <code>IStandardMetaDataSourceInfo</code> for this locator - */ - protected final IStandardMetaDataSourceInfo getFileInfo(){ - return fileInfo; - } - /** - * Return InputStream to the meta-data source file. - * Callers are responsible for closing the stream. - * @return InputStream - * @throws IOException - */ - public abstract InputStream getInputStream() throws IOException; - - /** - * Return URL to the meta-data source file. - - * @return URL or null if cannot find a the file for getFileInfo - */ - public abstract URL getURL(); - - /** - * Return ResourceBundle for the property files if there are any. Return null if not. - * - * @return java.util.ResourceBundle - * @throws IOException - * @throws MissingResourceException - */ - public abstract ResourceBundle getResourceBundle() throws IOException, MissingResourceException; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java deleted file mode 100644 index fa24bb8c5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.BasicExtendedMetaData; -import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.xmi.ClassNotFoundException; -import org.eclipse.emf.ecore.xmi.FeatureNotFoundException; -import org.eclipse.emf.ecore.xmi.IllegalValueException; -import org.eclipse.emf.ecore.xmi.PackageNotFoundException; -import org.eclipse.emf.ecore.xmi.UnresolvedReferenceException; -import org.eclipse.emf.ecore.xmi.XMIException; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceImpl; - -/** - * Singleton that produces and loads standard metadata models. - * All models are loaded into the same ResourceSet. - * <p> - * All metadata extension models must be registered with org.eclipse.emf.ecore.generated_package extension-point. - * No other mechanism is provided for model uri resolution. - * <p> - * Debug tracing for model loading is available: <code>org.eclipse.jst.jsf.common/debug/metadataload=true</code> - * <p> - * When the /debug/metadataload trace flag is set, and in case extension models are known not to be available, - * and metadata is referencing those models, error logging can be suppressed by launching with the following properties set:<br> - * metadata.package.ignores<br> - * metadata.classname.ignores - * <p> - * eg. Usage for when WPE is not present<p> - * <code> - -Dmetadata.package.ignores=http://org.eclipse.jsf.pagedesigner/dtinfo.ecore,<br>http://org.eclipse.jsf.pagedesigner/QuickEditTabSections.ecore<br> - -Dmetadata.classname.ignores=DTInfo,QuickEditTabSections<br> - * </code> - * <p> - * see {@link Model} - */ -public class StandardModelFactory { - private static StandardModelFactory INSTANCE; - static boolean DEBUG_MD_LOAD = false; - static boolean DEBUG_MD_GET = false; - private ExtendedMetaData extendedMetaData; - private ResourceSet resourceSet; - - - /** - * @return singleton instance of the metadata model factory - */ - public synchronized static StandardModelFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new StandardModelFactory(); - INSTANCE.init(); - - if (JSFCommonPlugin.getPlugin().isDebugging()){ - DEBUG_MD_LOAD = Boolean.valueOf(Platform.getDebugOption(JSFCommonPlugin.PLUGIN_ID+"/debug/metadataload")).booleanValue();//$NON-NLS-1$ - DEBUG_MD_GET = Boolean.valueOf(Platform.getDebugOption(JSFCommonPlugin.PLUGIN_ID+"/debug/metadataget")).booleanValue();//$NON-NLS-1$ - } - } - return INSTANCE; - } - - private void init() { - resourceSet = new ResourceSetImpl(); - - extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); - - // Register the appropriate resource factory to handle all file extensions. - // - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put - (Resource.Factory.Registry.DEFAULT_EXTENSION, - new XMLResourceFactoryImpl()); - - //relying on the org.eclipse.emf.ecore.generated_package ext-pt to register traits - } - - private StandardModelFactory() { - super(); - } - -// /** -// * Factory method that probably belongs somewhere else! -// * @param key -// * @param strategy -// * @return an empty MetaDataModel -// * @deprecated -// */ -// public MetaDataModel createModel(ModelKeyDescriptor key, IDomainLoadingStrategy strategy){ -// return new MetaDataModel(key, strategy); -// } - - /** - * @param context - * @param strategy - * @return MetaDataModel - */ - public MetaDataModel createModel(final IMetaDataModelContext context, final IDomainLoadingStrategy strategy) { - return new MetaDataModel(context, strategy); - } -// -// /** -// * Factory method that probably belongs somewhere else! -// * @param modelContext -// * @return a ModelKeyDescriptor for the context -// * @deprecated -// */ -// public ModelKeyDescriptor createModelKeyDescriptor(final ITaglibDomainMetaDataModelContext modelContext) { -// return new ModelKeyDescriptor(modelContext.getProject(), modelContext.getDomainID(), modelContext.getURI()); -// } - - /** - * @param inputStream - * @param provider - * @param uri - * @return the root of the standard model from the resource as an EList - * @throws IOException - */ - public EList loadStandardFileResource(final InputStream inputStream, - final IMetaDataSourceModelProvider provider, - final org.eclipse.emf.common.util.URI uri) throws IOException - { - final XMLResource res = new MetadataResourceImpl(provider); - - debug(String.format( - ">>> Loading standard meta-data file for uri %s", uri), DEBUG_MD_LOAD); //$NON-NLS-1$ - - res.setURI(uri); - resourceSet.getResources().add(res); - setLoadOptions(res); - res.load(inputStream, null); - if (DEBUG_MD_LOAD) - { - reportErrors(res); - } - final EList root = res.getContents(); - return root; - } - - private void reportErrors(Resource res) { - EList<Resource.Diagnostic> errs = res.getErrors(); - if (! errs.isEmpty()){ - for (Iterator<Resource.Diagnostic> it= errs.iterator();it.hasNext();){ - StandardModelErrorMessageFactory.logErrorMessage(it.next()); - } - } - } - - /** - * Sets default load options for the resource - * @param resource - */ - protected void setLoadOptions(XMLResource resource) { - Map options = resource.getDefaultLoadOptions(); -// options.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true); - options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - options.put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); - options.put(XMLResource.OPTION_RESOURCE_HANDLER, resource); - options.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE); - options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.FALSE);//turning this off so that res.getErrors() has values to check! bizarre that I should need to do this. -// options.put(XMLResource.OPTION_DOM_USE_NAMESPACES_IN_SCOPE, Boolean.TRUE); - -// if (DEBUG_MD_LOAD) -// { -// System.out.println("Using load options: "+options); -// } - } - - - static class StandardModelErrorMessageFactory { - private static List<String> _missingPackageURIs; - private static List<String> _missingClassnames; - - /** - * Simply logs all messages against JSFCommonPlugin, for now. - * @param diagnostic - */ - public static void logErrorMessage(Resource.Diagnostic diagnostic) { - //should be XMIException - if (diagnostic instanceof XMIException) { - XMIException ex = (XMIException)diagnostic; - String msg = createMessage(ex); - if (msg != null) - JSFCommonPlugin.log(IStatus.ERROR, msg); - } - else { - JSFCommonPlugin.log(IStatus.ERROR, diagnostic.toString());//do better??? - } - } - - private static String createMessage(XMIException ex) { - - StringBuffer buf = new StringBuffer("Metadata Load Error: ") //$NON-NLS-1$ - .append(ex.getClass().getSimpleName()).append(": "); //$NON-NLS-1$ - - if (ex instanceof PackageNotFoundException) { - if (shouldIgnore(ex)) - return null; - - buf.append(((PackageNotFoundException)ex).uri()); - } - else if (ex instanceof ClassNotFoundException) { - if (shouldIgnore(ex)) - return null; - - buf.append(((ClassNotFoundException)ex).getName()); - } - else if (ex instanceof FeatureNotFoundException) - buf.append(((FeatureNotFoundException)ex).getName()); - else if (ex instanceof IllegalValueException) - buf.append(((IllegalValueException)ex).getValue().toString()); - else if (ex instanceof UnresolvedReferenceException) - buf.append(((UnresolvedReferenceException)ex).getReference()); - else - buf.append(ex.getMessage()); - - buf.append(" in ").append(ex.getLocation()).append(": Line = ") //$NON-NLS-1$ //$NON-NLS-2$ - .append(ex.getLine()).append(": Column = ").append(ex.getColumn()); //$NON-NLS-1$ - return buf.toString(); - } - - private static boolean shouldIgnore(XMIException ex) { - if (ex instanceof PackageNotFoundException) { - String uri = ((PackageNotFoundException)ex).uri(); - return getMissingPackageURIs().contains(uri); - } - else if (ex instanceof ClassNotFoundException) { - String className = ((ClassNotFoundException)ex).getName(); - return getMissingClassnames().contains(className); - } - return false; - } - - private static List<String> getMissingPackageURIs() { - if (_missingPackageURIs == null) { - _missingPackageURIs = buildList("metadata.package.ignores"); //$NON-NLS-1$ - - } - return _missingPackageURIs; - } - - private static List<String> getMissingClassnames() { - if (_missingClassnames == null) { - _missingClassnames = buildList("metadata.classname.ignores"); //$NON-NLS-1$ - } - return _missingClassnames; - } - - private static List<String> buildList(String propertyName) { - List<String> ret = new ArrayList<String>(); - String ignoreSet = System.getProperty(propertyName); - if (ignoreSet == null )//try env - ignoreSet = System.getenv(propertyName); - - if (ignoreSet != null && !(ignoreSet.equals(""))){ //$NON-NLS-1$ - StringTokenizer st = new StringTokenizer(ignoreSet, ","); //$NON-NLS-1$ - while(st.hasMoreTokens()){ - String uri = st.nextToken(); - if (!(uri.equals(""))) //$NON-NLS-1$ - ret.add(uri); - } - } - - return ret; - } - - } - - /** - * Debug output. The parenthesis shows thread id. - * @param msg - * @param debugFlag - */ - public static void debug(String msg, boolean debugFlag) { - if (debugFlag) - System.out.println(msg + "["+Thread.currentThread().getId()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java deleted file mode 100644 index 4f8f4ad99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; - -/** - * Simple implementation of {@link ITaglibDomainMetaDataModelContext} - * @deprecated - Helios - */ -public class TaglibDomainMetaDataModelContextImpl extends MetaDataModelContextImpl implements IMetaDataModelContext, ITaglibDomainMetaDataModelContext, Cloneable -{ - private final IProject _project; - private final String _uri; - - /** - * Constructor - * @param project - * @param domain - * @param uri - */ - public TaglibDomainMetaDataModelContextImpl(final String domain, final IProject project, final String uri){ - super(domain); - this._project = project; - this._uri = uri; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext#getProject() - */ - public IProject getProject() { - return _project; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext#getURI() - */ - public String getURI() { - return _uri; - } - - public Object getAdapter(Class adapter) { - if (adapter.equals(ITaglibDomainMetaDataModelContext.class)) - return this; - if (adapter.equals(IProject.class)) - return _project; - - return super.getAdapter(adapter); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - - public String getDomainId() { - return getDomainID(); - } - - public String getModelIdentifier() { - return getURI(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java deleted file mode 100644 index a0812fe9e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.BasicEObjectImpl; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.eclipse.emf.ecore.xml.type.SimpleAnyType; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.osgi.util.NLS; - -/** - * Experimental/prototype class to assist with decoding trait values. - * This could/should be made API at some point after "hardening". (https://bugs.eclipse.org/bugs/show_bug.cgi?id=192052) - */ -public class TraitValueHelper { - private static final String KEY_NOT_FOUND = Messages.Key_not_found; - /** - * @param trait - * @return EClass of trait value - */ - public static EClass getValueType(final Trait trait){ - if (trait == null) - return null; - if (trait.getValue() != null) - return trait.getValue().eClass(); - return null; - } - - /** - * @param trait - * @return value of trait as String Object. - */ - public static Object getValue(final Trait trait){ - if (trait == null) - return null; - - if (trait.getValue() == null) - return null; - - if (trait.getValue() instanceof StringValue) { - return ((StringValue)trait.getValue()).getValue(); - } - else if (trait.getValue() instanceof SimpleAnyType){ - return ((SimpleAnyType)trait.getValue()).getRawValue(); - } - else if (trait.getValue() instanceof AnyType){ - AnyType any = (AnyType)trait.getValue(); - FeatureMap map = any.getMixed(); - return getTextValueFromFeatureMap(map); - } - else if ( trait.getValue().eIsProxy() && trait.getValue() instanceof BasicEObjectImpl){ - BasicEObjectImpl o = (BasicEObjectImpl)trait.getValue(); - return o.eProxyURI().toString(); - } - return trait.getValue(); - } - - private static String getTextValueFromFeatureMap(final FeatureMap map) { - for (final Iterator it=map.iterator();it.hasNext();){ - final FeatureMap.Entry entry = (FeatureMap.Entry)it.next(); - if (entry.getEStructuralFeature().getName().equals("text")) //$NON-NLS-1$ - return (String)entry.getValue(); - } - return null; - } - - /** - * @param trait - * @return value of trait as String. If externalized, will resolve from resource bundle. - */ - public static String getValueAsString(final Trait trait){ - final Object val = getValue(trait); - if (val instanceof String){ - return getNLSValue(trait, (String)val); - } - else if (val instanceof BooleanValue) - return String.valueOf(((BooleanValue)val).isTrue()); - - return null; - } - - /** - * - * @param trait whose value a {@link ListOfValues} or is a single string - * @return List of Strings. If externalized, will resolve from resource bundle - * using getNLSValue(Trait trait, String rawValue) - */ - public synchronized static List getValueAsListOfStrings(final Trait trait){ - //PROTO ONLY!!! Need to make WAY more robust! - final List ret = new ArrayList(); - if (trait.getValue() instanceof ListOfValues) { - for(final Iterator it=trait.getValue().eContents().iterator();it.hasNext();){ - final Object o = it.next(); - if (o instanceof SimpleAnyType){ - final SimpleAnyType sat = (SimpleAnyType)o; - final String rawValue = getTextValueFromFeatureMap(sat.getMixed()); - final String nlsValue = getNLSValue(trait, rawValue); - - ret.add(nlsValue); - } - } - } - else { - //may be single value - String o = getValueAsString(trait); - if (o != null) - ret.add(o); - } - return ret; - } - - /** - * Looks for '%' (and not '%%') at beginning of rawValue. If found, looks to the - * traits sourceModelProvider for resource bundle to resolve the key after - * stripping the '%' sign. - * @param trait - * @param rawValue of string in from metadata - * @return the NLS Value or rawValue if it cannot be located - */ - public static String getNLSValue(final Trait trait, final String rawValue) { - String result = rawValue; - if (rawValue.startsWith("%") && !rawValue.startsWith("%%")){ //$NON-NLS-1$//$NON-NLS-2$ - final String key = rawValue.substring(1); - result = getNLSPropertyValue(trait, key); - if (result == null){ - result = rawValue; - } - } - return result == null ? null : result.trim(); - } - - //will return null if there is an IOException with ResourceBundle - private static String getNLSPropertyValue(final Trait trait, final String key){ - try{ - IMetaDataSourceModelProvider provider = trait.getSourceModelProvider(); - IResourceBundleProvider resourceBundleProvider = (IResourceBundleProvider)provider.getAdapter(IResourceBundleProvider.class); - if (resourceBundleProvider != null){ - ResourceBundle resourceBundle_ = resourceBundleProvider.getResourceBundle(); - if (resourceBundle_ != null){ - String replVal = resourceBundle_.getString(key); - return replVal; - } - } - //return original string - return key; - - } catch (MissingResourceException e){ - //fall thru - JSFCommonPlugin.log(e, NLS.bind(Messages.MissingResource_exception, new String[]{key})); - } - return key + KEY_NOT_FOUND; - } - - /** - * If trait type is {@link BooleanValue} returns value, otherwise - * it will get the value as a String and attempt to coerce to boolean. - * Will return 'false' if coercion fails, or value was null. - * @param trait - * @return true or false - */ - public static boolean getValueAsBoolean(final Trait trait) { - if (trait != null && trait.getValue() instanceof BooleanValue) { - return ((BooleanValue)trait.getValue()).isTrue(); - } - final String val = getValueAsString(trait); - if (val == null) - return false; - - return Boolean.valueOf(val).booleanValue(); - } - -// /** -// * @param trait -// * @return name of class or primitive datatype that the value is defined as. -// * For SimpleAnyTypes, the getInstanceType().getInstanceClassName() is returned. -// * For AnyType, java.lang.String is always returned. -// * For all others, the class.getName() is returned. -// */ -// public static String getValueInstanceClassName(Trait trait) {String.class.getName(); -// if (trait.getValue() instanceof SimpleAnyType) { -// return ((SimpleAnyType)trait.getValue()).getInstanceType().getInstanceClassName(); -// } -// else if (trait.getValue() instanceof AnyType) { -// return String.class.getName(); -// } -// else { -// return trait.getValue().getClass().getName(); -// } -// -// } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper2.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper2.java deleted file mode 100644 index 64238d775..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper2.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.BasicEObjectImpl; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.eclipse.emf.ecore.xml.type.SimpleAnyType; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.osgi.util.NLS; - -/** - * Experimental/prototype class to assist with decoding trait values. - * This could/should be made API at some point after "hardening". (https://bugs.eclipse.org/bugs/show_bug.cgi?id=192052) - * <p> - * May be subclassed - * <p> - * Note: non-static copy of TraitValueHelper - */ -public class TraitValueHelper2 { - private static final String KEY_NOT_FOUND = Messages.Key_not_found; - - /** - * @param trait - * @return EClass of trait value - */ - public EClass getValueType(final Trait trait){ - if (trait == null) - return null; - if (trait.getValue() != null) - return trait.getValue().eClass(); - return null; - } - - /** - * @param trait - * @return value of trait as String Object. - */ - public Object getValue(final Trait trait){ - if (trait == null) - return null; - - if (trait.getValue() == null) - return null; - - if (trait.getValue() instanceof StringValue) { - return ((StringValue)trait.getValue()).getValue(); - } - else if (trait.getValue() instanceof SimpleAnyType){ - return ((SimpleAnyType)trait.getValue()).getRawValue(); - } - else if (trait.getValue() instanceof AnyType){ - AnyType any = (AnyType)trait.getValue(); - FeatureMap map = any.getMixed(); - return getTextValueFromFeatureMap(map); - } - else if ( trait.getValue().eIsProxy() && trait.getValue() instanceof BasicEObjectImpl){ - BasicEObjectImpl o = (BasicEObjectImpl)trait.getValue(); - return o.eProxyURI().toString(); - } - return trait.getValue(); - } - - /** - * @param map - * @return String - */ - protected String getTextValueFromFeatureMap(final FeatureMap map) { - for (final Iterator it=map.iterator();it.hasNext();){ - final FeatureMap.Entry entry = (FeatureMap.Entry)it.next(); - if (entry.getEStructuralFeature().getName().equals("text")) //$NON-NLS-1$ - return (String)entry.getValue(); - } - return null; - } - - /** - * @param trait - * @return value of trait as String. If externalized, will resolve from resource bundle. - */ - public String getValueAsString(final Trait trait){ - final Object val = getValue(trait); - if (val instanceof String){ - return getNLSValue(trait, (String)val); - } - else if (val instanceof BooleanValue) - return String.valueOf(((BooleanValue)val).isTrue()); - - return null; - } - - /** - * @param trait whose value a {@link ListOfValues} or is a single string - * @return List of Strings. If externalized, will resolve from resource bundle - * using getNLSValue(Trait trait, String rawValue) - */ - public synchronized List getValueAsListOfStrings(final Trait trait){ - //PROTO ONLY!!! Need to make WAY more robust! - final List ret = new ArrayList(); - if (trait.getValue() instanceof ListOfValues) { - for(final Iterator it=trait.getValue().eContents().iterator();it.hasNext();){ - final Object o = it.next(); - if (o instanceof SimpleAnyType){ - final SimpleAnyType sat = (SimpleAnyType)o; - final String rawValue = getTextValueFromFeatureMap(sat.getMixed()); - final String nlsValue = getNLSValue(trait, rawValue); - - ret.add(nlsValue); - } - } - } - else { - //may be single value - String o = getValueAsString(trait); - if (o != null) - ret.add(o); - } - return ret; - } - - /** - * Looks for '%' (and not '%%') at beginning of rawValue. If found, looks to the - * traits sourceModelProvider for resource bundle to resolve the key after - * stripping the '%' sign. - * @param trait - * @param rawValue of string in from metadata - * @return the NLS Value or rawValue if it cannot be located - */ - public String getNLSValue(final Trait trait, final String rawValue) { - String result = rawValue; - if (rawValue.startsWith("%") && !rawValue.startsWith("%%")){ //$NON-NLS-1$//$NON-NLS-2$ - final String key = rawValue.substring(1); - result = getNLSPropertyValue(trait, key); - if (result == null){ - result = rawValue; - } - } - return result == null ? null : result.trim(); - } - - /** - * @param trait - * @param key - * @return String - */ - //will return null if there is an IOException with ResourceBundle - protected String getNLSPropertyValue(final Trait trait, final String key){ - try{ - IMetaDataSourceModelProvider provider = trait.getSourceModelProvider(); - IResourceBundleProvider resourceBundleProvider = (IResourceBundleProvider)provider.getAdapter(IResourceBundleProvider.class); - if (resourceBundleProvider != null){ - ResourceBundle resourceBundle_ = resourceBundleProvider.getResourceBundle(); - if (resourceBundle_ != null){ - String replVal = resourceBundle_.getString(key); - return replVal; - } - } - //return original string - return key; - - } catch (MissingResourceException e){ - //fall thru - JSFCommonPlugin.log(e, NLS.bind(Messages.MissingResource_exception, new String[]{key})); - } - return key + KEY_NOT_FOUND; - } - - /** - * If trait type is {@link BooleanValue} returns value, otherwise - * it will get the value as a String and attempt to coerce to boolean. - * Will return 'false' if coercion fails, or value was null. - * @param trait - * @return true or false - */ - public boolean getValueAsBoolean(final Trait trait) { - if (trait != null && trait.getValue() instanceof BooleanValue) { - return ((BooleanValue)trait.getValue()).isTrue(); - } - final String val = getValueAsString(trait); - if (val == null) - return false; - - return Boolean.valueOf(val).booleanValue(); - } - -// /** -// * @param trait -// * @return name of class or primitive datatype that the value is defined as. -// * For SimpleAnyTypes, the getInstanceType().getInstanceClassName() is returned. -// * For AnyType, java.lang.String is always returned. -// * For all others, the class.getName() is returned. -// */ -// public String getValueInstanceClassName(Trait trait) {String.class.getName(); -// if (trait.getValue() instanceof SimpleAnyType) { -// return ((SimpleAnyType)trait.getValue()).getInstanceType().getInstanceClassName(); -// } -// else if (trait.getValue() instanceof AnyType) { -// return String.class.getName(); -// } -// else { -// return trait.getValue().getClass().getName(); -// } -// -// } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java deleted file mode 100644 index 18fd3c5b2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: EntityGroupImpl.java,v 1.7 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Entity Group</b></em>'. - * <!-- end-user-doc --> - * <p> - * </p> - * - * @generated - */ -@SuppressWarnings("hiding") -public class EntityGroupImpl extends EntityImpl implements EntityGroup { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EntityGroupImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return MetadataPackage.Literals.ENTITY_GROUP; - } - -} //EntityGroupImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java deleted file mode 100644 index 74d9ea3cf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java +++ /dev/null @@ -1,439 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: EntityImpl.java,v 1.9 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; -import org.eclipse.jst.jsf.common.metadata.query.internal.IHierarchicalEntityVisitor; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Entity</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getChildEntities <em>Child Entities</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getTraits <em>Traits</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getType <em>Type</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getIncludeGroups <em>Include Groups</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class EntityImpl extends EObjectImpl implements Entity { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached value of the '{@link #getChildEntities() <em>Child Entities</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getChildEntities() - * @generated - * @ordered - */ - protected EList<Entity> childEntities; - - /** - * The cached value of the '{@link #getTraits() <em>Traits</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getTraits() - * @generated - * @ordered - */ - protected EList<Trait> traits; - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The default value of the '{@link #getType() <em>Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getType() - * @generated - * @ordered - */ - protected static final String TYPE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getType() <em>Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getType() - * @generated - * @ordered - */ - protected String type = TYPE_EDEFAULT; - - /** - * The cached value of the '{@link #getIncludeGroups() <em>Include Groups</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIncludeGroups() - * @generated - * @ordered - */ - protected EList<IncludeEntityGroup> includeGroups; - - /** - * The cached value of the Model - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private Model _model; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EntityImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return MetadataPackage.Literals.ENTITY; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<Entity> getChildEntities() { - if (childEntities == null) { - childEntities = new EObjectContainmentEList<Entity>(Entity.class, this, MetadataPackage.ENTITY__CHILD_ENTITIES); - } - return childEntities; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<Trait> getTraits() { - if (traits == null) { - traits = new EObjectContainmentEList<Trait>(Trait.class, this, MetadataPackage.ENTITY__TRAITS); - } - return traits; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<IncludeEntityGroup> getIncludeGroups() { - if (includeGroups == null) { - includeGroups = new EObjectResolvingEList<IncludeEntityGroup>(IncludeEntityGroup.class, this, MetadataPackage.ENTITY__INCLUDE_GROUPS); - } - return includeGroups; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.ENTITY__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getType() { - return type; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setType(String newType) { - String oldType = type; - type = newType; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.ENTITY__TYPE, oldType, type)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private boolean accept(final IHierarchicalEntityVisitor visitor) { - if (visitor.visitEnter( this )) { - acceptChildren(visitor); - } - return visitor.visitLeave(this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void accept(final IEntityVisitor visitor) { - if (visitor instanceof IHierarchicalEntityVisitor) { - accept((IHierarchicalEntityVisitor)visitor); - } - else { - if (visitor.stopVisiting()) - return; - - visitor.visit(this); - if (visitor.stopVisiting()) - return; - - acceptChildren(visitor); - - visitor.visitCompleted(this); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private void acceptChildren(final IEntityVisitor visitor) { - if (!getChildEntities().isEmpty()){ - for (final Iterator/*<Entity>*/ it = getChildEntities().iterator(); it.hasNext();){ - final Entity k = (Entity)it.next(); - k.accept(visitor); - if (visitor.stopVisiting()) - return; - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Model getModel() { - if (_model == null){ - EObject parent = this.eContainer(); - while (true){ - if (parent instanceof Model){ - _model = (Model)parent; - break; - } - if (parent != null) - parent = parent.eContainer(); - else - break; - } - } - return _model; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return ((InternalEList<?>)getChildEntities()).basicRemove(otherEnd, msgs); - case MetadataPackage.ENTITY__TRAITS: - return ((InternalEList<?>)getTraits()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return getChildEntities(); - case MetadataPackage.ENTITY__TRAITS: - return getTraits(); - case MetadataPackage.ENTITY__ID: - return getId(); - case MetadataPackage.ENTITY__TYPE: - return getType(); - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - return getIncludeGroups(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - getChildEntities().clear(); - getChildEntities().addAll((Collection<? extends Entity>)newValue); - return; - case MetadataPackage.ENTITY__TRAITS: - getTraits().clear(); - getTraits().addAll((Collection<? extends Trait>)newValue); - return; - case MetadataPackage.ENTITY__ID: - setId((String)newValue); - return; - case MetadataPackage.ENTITY__TYPE: - setType((String)newValue); - return; - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - getIncludeGroups().clear(); - getIncludeGroups().addAll((Collection<? extends IncludeEntityGroup>)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - getChildEntities().clear(); - return; - case MetadataPackage.ENTITY__TRAITS: - getTraits().clear(); - return; - case MetadataPackage.ENTITY__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.ENTITY__TYPE: - setType(TYPE_EDEFAULT); - return; - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - getIncludeGroups().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return childEntities != null && !childEntities.isEmpty(); - case MetadataPackage.ENTITY__TRAITS: - return traits != null && !traits.isEmpty(); - case MetadataPackage.ENTITY__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.ENTITY__TYPE: - return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type); - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - return includeGroups != null && !includeGroups.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", type: "); //$NON-NLS-1$ - result.append(type); - result.append(')'); - return result.toString(); - } - -} //EntityImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java deleted file mode 100644 index 089dbbd1b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: IncludeEntityGroupImpl.java,v 1.4 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Include Entity Group</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl#getModelUri <em>Model Uri</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class IncludeEntityGroupImpl extends EObjectImpl implements IncludeEntityGroup { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The default value of the '{@link #getModelUri() <em>Model Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getModelUri() - * @generated - * @ordered - */ - protected static final String MODEL_URI_EDEFAULT = null; - - /** - * The cached value of the '{@link #getModelUri() <em>Model Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getModelUri() - * @generated - * @ordered - */ - protected String modelUri = MODEL_URI_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IncludeEntityGroupImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return MetadataPackage.Literals.INCLUDE_ENTITY_GROUP; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.INCLUDE_ENTITY_GROUP__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getModelUri() { - return modelUri; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setModelUri(String newModelUri) { - String oldModelUri = modelUri; - modelUri = newModelUri; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI, oldModelUri, modelUri)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - return getId(); - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - return getModelUri(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - setId((String)newValue); - return; - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - setModelUri((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - setModelUri(MODEL_URI_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - return MODEL_URI_EDEFAULT == null ? modelUri != null : !MODEL_URI_EDEFAULT.equals(modelUri); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", modelUri: "); //$NON-NLS-1$ - result.append(modelUri); - result.append(')'); - return result.toString(); - } - -} //IncludeEntityGroupImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java deleted file mode 100644 index fce3aa79b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataFactoryImpl.java,v 1.6 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; - - - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class MetadataFactoryImpl extends EFactoryImpl implements MetadataFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public static MetadataFactory init() { - try { - MetadataFactory theMetadataFactory = (MetadataFactory)EPackage.Registry.INSTANCE.getEFactory("http://org.eclipse.jst.jsf.common.metadata/metadata.ecore"); //$NON-NLS-1$ - if (theMetadataFactory != null) { - return theMetadataFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new MetadataFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case MetadataPackage.MODEL: return createModel(); - case MetadataPackage.ENTITY_GROUP: return createEntityGroup(); - case MetadataPackage.ENTITY: return createEntity(); - case MetadataPackage.INCLUDE_ENTITY_GROUP: return createIncludeEntityGroup(); - case MetadataPackage.TRAIT: return createTrait(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$//$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object createFromString(EDataType eDataType, String initialValue) { - switch (eDataType.getClassifierID()) { - case MetadataPackage.IMETA_DATA_SOURCE_MODEL_PROVIDER: - return createIMetaDataSourceModelProviderFromString(eDataType, initialValue); - case MetadataPackage.MODEL_CONTEXT: - return createModelContextFromString(eDataType, initialValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$//$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String convertToString(EDataType eDataType, Object instanceValue) { - switch (eDataType.getClassifierID()) { - case MetadataPackage.IMETA_DATA_SOURCE_MODEL_PROVIDER: - return convertIMetaDataSourceModelProviderToString(eDataType, instanceValue); - case MetadataPackage.MODEL_CONTEXT: - return convertModelContextToString(eDataType, instanceValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$//$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Trait createTrait() { - TraitImpl trait = new TraitImpl(); - return trait; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IncludeEntityGroup createIncludeEntityGroup() { - IncludeEntityGroupImpl includeEntityGroup = new IncludeEntityGroupImpl(); - return includeEntityGroup; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Model createModel() { - ModelImpl model = new ModelImpl(); - return model; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Entity createEntity() { - EntityImpl entity = new EntityImpl(); - return entity; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EntityGroup createEntityGroup() { - EntityGroupImpl entityGroup = new EntityGroupImpl(); - return entityGroup; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IMetaDataSourceModelProvider createIMetaDataSourceModelProviderFromString(EDataType eDataType, String initialValue) { - return (IMetaDataSourceModelProvider)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertIMetaDataSourceModelProviderToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ModelKeyDescriptor createModelContextFromString(EDataType eDataType, String initialValue) { - return (ModelKeyDescriptor)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertModelContextToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataPackage getMetadataPackage() { - return (MetadataPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @deprecated - * @generated - */ - @Deprecated - public static MetadataPackage getPackage() { - return MetadataPackage.eINSTANCE; - } - -} //MetadataFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java deleted file mode 100644 index b4ef529ba..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java +++ /dev/null @@ -1,583 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataPackageImpl.java,v 1.9 2011/04/04 22:22:38 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; -import org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor; - - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -@SuppressWarnings("nls") -public class MetadataPackageImpl extends EPackageImpl implements MetadataPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass traitEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass includeEntityGroupEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass modelEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass entityEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass entityGroupEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iTraitVisitorEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iEntityVisitorEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iMetaDataSourceModelProviderEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType modelContextEDataType = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#eNS_URI - * @see #init() - * @generated - */ - private MetadataPackageImpl() { - super(eNS_URI, MetadataFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. - * - * <p>This method is used to initialize {@link MetadataPackage#eINSTANCE} when that field is accessed. - * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static MetadataPackage init() { - if (isInited) return (MetadataPackage)EPackage.Registry.INSTANCE.getEPackage(MetadataPackage.eNS_URI); - - // Obtain or create and register package - MetadataPackageImpl theMetadataPackage = (MetadataPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof MetadataPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new MetadataPackageImpl()); - - isInited = true; - - // Create package meta-data objects - theMetadataPackage.createPackageContents(); - - // Initialize created meta-data - theMetadataPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theMetadataPackage.freeze(); - - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(MetadataPackage.eNS_URI, theMetadataPackage); - return theMetadataPackage; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getTrait() { - return traitEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getTrait_Value() { - return (EReference)traitEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTrait_SourceModelProvider() { - return (EAttribute)traitEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getIncludeEntityGroup() { - return includeEntityGroupEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getIncludeEntityGroup_Id() { - return (EAttribute)includeEntityGroupEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getIncludeEntityGroup_ModelUri() { - return (EAttribute)includeEntityGroupEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTrait_Id() { - return (EAttribute)traitEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getModel() { - return modelEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getModel_SourceModelProvider() { - return (EAttribute)modelEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getModel_CurrentModelContext() { - return (EAttribute)modelEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getModel_EntityGroups() { - return (EReference)modelEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getEntity() { - return entityEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_ChildEntities() { - return (EReference)entityEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_Traits() { - return (EReference)entityEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getEntity_Id() { - return (EAttribute)entityEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getEntity_Type() { - return (EAttribute)entityEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_IncludeGroups() { - return (EReference)entityEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getEntityGroup() { - return entityGroupEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getITraitVisitor() { - return iTraitVisitorEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getIEntityVisitor() { - return iEntityVisitorEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getIMetaDataSourceModelProvider() { - return iMetaDataSourceModelProviderEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getModelContext() { - return modelContextEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataFactory getMetadataFactory() { - return (MetadataFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - modelEClass = createEClass(MODEL); - createEReference(modelEClass, MODEL__ENTITY_GROUPS); - createEAttribute(modelEClass, MODEL__SOURCE_MODEL_PROVIDER); - createEAttribute(modelEClass, MODEL__CURRENT_MODEL_CONTEXT); - - entityGroupEClass = createEClass(ENTITY_GROUP); - - entityEClass = createEClass(ENTITY); - createEReference(entityEClass, ENTITY__CHILD_ENTITIES); - createEReference(entityEClass, ENTITY__TRAITS); - createEAttribute(entityEClass, ENTITY__ID); - createEAttribute(entityEClass, ENTITY__TYPE); - createEReference(entityEClass, ENTITY__INCLUDE_GROUPS); - - includeEntityGroupEClass = createEClass(INCLUDE_ENTITY_GROUP); - createEAttribute(includeEntityGroupEClass, INCLUDE_ENTITY_GROUP__ID); - createEAttribute(includeEntityGroupEClass, INCLUDE_ENTITY_GROUP__MODEL_URI); - - traitEClass = createEClass(TRAIT); - createEAttribute(traitEClass, TRAIT__ID); - createEReference(traitEClass, TRAIT__VALUE); - createEAttribute(traitEClass, TRAIT__SOURCE_MODEL_PROVIDER); - - // Create data types - iTraitVisitorEDataType = createEDataType(ITRAIT_VISITOR); - iEntityVisitorEDataType = createEDataType(IENTITY_VISITOR); - iMetaDataSourceModelProviderEDataType = createEDataType(IMETA_DATA_SOURCE_MODEL_PROVIDER); - modelContextEDataType = createEDataType(MODEL_CONTEXT); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Create type parameters - - // Set bounds for type parameters - - // Add supertypes to classes - modelEClass.getESuperTypes().add(this.getEntity()); - entityGroupEClass.getESuperTypes().add(this.getEntity()); - - // Initialize classes and features; add operations and parameters - initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getModel_EntityGroups(), this.getEntityGroup(), null, "entityGroups", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - getModel_EntityGroups().getEKeys().add(this.getEntity_Id()); - getModel_EntityGroups().getEKeys().add(this.getEntity_Type()); - initEAttribute(getModel_SourceModelProvider(), this.getIMetaDataSourceModelProvider(), "sourceModelProvider", null, 0, 1, Model.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getModel_CurrentModelContext(), this.getModelContext(), "currentModelContext", null, 0, 1, Model.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - EOperation op = addEOperation(modelEClass, this.getEntityGroup(), "findIncludeGroup", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - addEParameter(op, ecorePackage.getEString(), "groupId", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - - op = addEOperation(modelEClass, null, "accept", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - addEParameter(op, this.getIEntityVisitor(), "visitor", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - - initEClass(entityGroupEClass, EntityGroup.class, "EntityGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - - initEClass(entityEClass, Entity.class, "Entity", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getEntity_ChildEntities(), this.getEntity(), null, "childEntities", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - getEntity_ChildEntities().getEKeys().add(this.getEntity_Id()); - getEntity_ChildEntities().getEKeys().add(this.getEntity_Type()); - initEReference(getEntity_Traits(), this.getTrait(), null, "traits", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - getEntity_Traits().getEKeys().add(this.getTrait_Id()); - initEAttribute(getEntity_Id(), ecorePackage.getEString(), "id", null, 1, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getEntity_Type(), ecorePackage.getEString(), "type", null, 0, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEReference(getEntity_IncludeGroups(), this.getIncludeEntityGroup(), null, "includeGroups", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - op = addEOperation(entityEClass, null, "accept", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - addEParameter(op, this.getIEntityVisitor(), "visitor", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - - addEOperation(entityEClass, this.getModel(), "getModel", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - - initEClass(includeEntityGroupEClass, IncludeEntityGroup.class, "IncludeEntityGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getIncludeEntityGroup_Id(), ecorePackage.getEString(), "id", null, 1, 1, IncludeEntityGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getIncludeEntityGroup_ModelUri(), ecorePackage.getEString(), "modelUri", null, 0, 1, IncludeEntityGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - initEClass(traitEClass, Trait.class, "Trait", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getTrait_Id(), ecorePackage.getEString(), "id", null, 1, 1, Trait.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEReference(getTrait_Value(), ecorePackage.getEObject(), null, "value", null, 1, 1, Trait.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getTrait_SourceModelProvider(), this.getIMetaDataSourceModelProvider(), "sourceModelProvider", null, 0, 1, Trait.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - op = addEOperation(traitEClass, null, "accept", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - addEParameter(op, this.getITraitVisitor(), "visitor", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ - - // Initialize data types - initEDataType(iTraitVisitorEDataType, ITraitVisitor.class, "ITraitVisitor", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(iEntityVisitorEDataType, IEntityVisitor.class, "IEntityVisitor", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(iMetaDataSourceModelProviderEDataType, IMetaDataSourceModelProvider.class, "IMetaDataSourceModelProvider", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(modelContextEDataType, ModelKeyDescriptor.class, "ModelContext", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - - // Create resource - createResource(eNS_URI); - - // Create annotations - // http:///org/eclipse/emf/ecore/util/ExtendedMetaData - createExtendedMetaDataAnnotations(); - } - - /** - * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createExtendedMetaDataAnnotations() { - String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$ - addAnnotation - (modelEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "metadatamodel" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getModel_EntityGroups(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entityGroup" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (entityEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entity" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_ChildEntities(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entity" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_Traits(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "trait" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_IncludeGroups(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "include-entity-group" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getIncludeEntityGroup_ModelUri(), - source, - new String[] { - "name", "uri" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (traitEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "trait" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getTrait_Value(), - source, - new String[] { - "kind", "element" //$NON-NLS-1$ //$NON-NLS-2$ - }); - } - -} //MetadataPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java deleted file mode 100644 index b7f78d906..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java +++ /dev/null @@ -1,281 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ModelImpl.java,v 1.10 2011/04/04 22:22:38 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Model</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getEntityGroups <em>Entity Groups</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getSourceModelProvider <em>Source Model Provider</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getCurrentModelContext <em>Current Model Context</em>}</li> - * </ul> - * </p> - * - * @generated - */ -@SuppressWarnings("hiding") -public class ModelImpl extends EntityImpl implements Model { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached value of the '{@link #getEntityGroups() <em>Entity Groups</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getEntityGroups() - * @generated - * @ordered - */ - protected EList<EntityGroup> entityGroups; - - /** - * The default value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected static final IMetaDataSourceModelProvider SOURCE_MODEL_PROVIDER_EDEFAULT = null; - - /** - * The default value of the '{@link #getCurrentModelContext() <em>Current Model Context</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCurrentModelContext() - * @generated - * @ordered - */ - protected static final ModelKeyDescriptor CURRENT_MODEL_CONTEXT_EDEFAULT = null; - - private IMetaDataSourceModelProvider sourceModelProvider; - - private ModelKeyDescriptor _modelContext; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModelImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return MetadataPackage.Literals.MODEL; - } - - /** - * <!-- begin-user-doc --> - * May return null. - * <!-- end-user-doc --> - * @generated NOT - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return sourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider newSourceModelProvider) { - sourceModelProvider = newSourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public ModelKeyDescriptor getCurrentModelContext() { - return _modelContext; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void setCurrentModelContext(ModelKeyDescriptor newCurrentModelContext) { - _modelContext = newCurrentModelContext; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList<EntityGroup> getEntityGroups() { - if (entityGroups == null) { - entityGroups = new EObjectContainmentEList<EntityGroup>(EntityGroup.class, this, MetadataPackage.MODEL__ENTITY_GROUPS); - } - return entityGroups; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - return getEntityGroups(); - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - return getSourceModelProvider(); - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - return getCurrentModelContext(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("unchecked") - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - getEntityGroups().clear(); - getEntityGroups().addAll((Collection<? extends EntityGroup>)newValue); - return; - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - setSourceModelProvider((IMetaDataSourceModelProvider)newValue); - return; - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - setCurrentModelContext((ModelKeyDescriptor)newValue); - return; - } - super.eSet(featureID, newValue); - } - - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public EntityGroup findIncludeGroup(String groupId){ - EntityGroup ret = null; - for (Iterator it=getEntityGroups().iterator();it.hasNext();){ - EntityGroup entityGroup = (EntityGroup)it.next(); - if (entityGroup.getId().equals(groupId)){ - ret = entityGroup; - break; - } - } - return ret; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - return ((InternalEList<?>)getEntityGroups()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - getEntityGroups().clear(); - return; - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - setSourceModelProvider(SOURCE_MODEL_PROVIDER_EDEFAULT); - return; - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - setCurrentModelContext(CURRENT_MODEL_CONTEXT_EDEFAULT); - return; - } - super.eUnset(featureID); - } - /** - * <!-- begin-user-doc --> - * Due to a mistake in the EMF model, Model is not inheriting accept method from Entity. This should be fixed. - * <!-- end-user-doc --> - * @generated NOT - */ - - public void accept(IEntityVisitor visitor) { - super.accept(visitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Model getModel() { - return this; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - return entityGroups != null && !entityGroups.isEmpty(); - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - return SOURCE_MODEL_PROVIDER_EDEFAULT == null ? getSourceModelProvider() != null : !SOURCE_MODEL_PROVIDER_EDEFAULT.equals(getSourceModelProvider()); - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - return CURRENT_MODEL_CONTEXT_EDEFAULT == null ? getCurrentModelContext() != null : !CURRENT_MODEL_CONTEXT_EDEFAULT.equals(getCurrentModelContext()); - } - return super.eIsSet(featureID); - } - -} //ModelImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java deleted file mode 100644 index 33e546c3b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java +++ /dev/null @@ -1,339 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitImpl.java,v 1.10 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor; - - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Trait</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl#getValue <em>Value</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl#getSourceModelProvider <em>Source Model Provider</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class TraitImpl extends EObjectImpl implements Trait { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected EObject value; - - /** - * The default value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected static final IMetaDataSourceModelProvider SOURCE_MODEL_PROVIDER_EDEFAULT = null; - - /** - * The cached value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected IMetaDataSourceModelProvider sourceModelProvider = SOURCE_MODEL_PROVIDER_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TraitImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() { - return MetadataPackage.Literals.TRAIT; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject getValue() { - return value; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param newValue - * @param msgs - * @return NotificationChain - * @generated - */ - public NotificationChain basicSetValue(EObject newValue, NotificationChain msgs) { - EObject oldValue = value; - value = newValue; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__VALUE, oldValue, newValue); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setValue(EObject newValue) { - if (newValue != value) { - NotificationChain msgs = null; - if (value != null) - msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MetadataPackage.TRAIT__VALUE, null, msgs); - if (newValue != null) - msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MetadataPackage.TRAIT__VALUE, null, msgs); - msgs = basicSetValue(newValue, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__VALUE, newValue, newValue)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return sourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider newSourceModelProvider) { - IMetaDataSourceModelProvider oldSourceModelProvider = sourceModelProvider; - sourceModelProvider = newSourceModelProvider; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER, oldSourceModelProvider, sourceModelProvider)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void accept(ITraitVisitor visitor) { - visitor.visit(this); - visitor.visitCompleted(this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case MetadataPackage.TRAIT__VALUE: - return basicSetValue(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - return getId(); - case MetadataPackage.TRAIT__VALUE: - return getValue(); - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - return getSourceModelProvider(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - setId((String)newValue); - return; - case MetadataPackage.TRAIT__VALUE: - setValue((EObject)newValue); - return; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - setSourceModelProvider((IMetaDataSourceModelProvider)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.TRAIT__VALUE: - setValue((EObject)null); - return; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - setSourceModelProvider(SOURCE_MODEL_PROVIDER_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.TRAIT__VALUE: - return value != null; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - return SOURCE_MODEL_PROVIDER_EDEFAULT == null ? sourceModelProvider != null : !SOURCE_MODEL_PROVIDER_EDEFAULT.equals(sourceModelProvider); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", sourceModelProvider: "); //$NON-NLS-1$ - result.append(sourceModelProvider); - result.append(')'); - return result.toString(); - } - - public boolean equals(Object value_){ - if (!(value_ instanceof String)) - return super.equals(value_); - - String key = (String)value_; - if (key.equals(getId())) - return true; - - return false; - } - - @Override - public int hashCode() - { - // try to match convention x.equals(y) => x.hashCode() == y.hashCode() - return getId() != null ? getId().hashCode() : 0xDEADBEEF; - } -} //TraitImpl
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties deleted file mode 100644 index 5e9fd47a8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2007 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### - -MissingResource_exception=MissingResourceException for NLSPropertyValue: {0} -Key_not_found=(key not found) diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java deleted file mode 100644 index 58ce7a24a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataAdapterFactory.java,v 1.6 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; - - - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage - * @generated - */ -public class MetadataAdapterFactory extends AdapterFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static MetadataPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataAdapterFactory() { - if (modelPackage == null) { - modelPackage = MetadataPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - @Override - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch that delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MetadataSwitch<Adapter> modelSwitch = - new MetadataSwitch<Adapter>() { - @Override - public Adapter caseModel(Model object) { - return createModelAdapter(); - } - @Override - public Adapter caseEntityGroup(EntityGroup object) { - return createEntityGroupAdapter(); - } - @Override - public Adapter caseEntity(Entity object) { - return createEntityAdapter(); - } - @Override - public Adapter caseIncludeEntityGroup(IncludeEntityGroup object) { - return createIncludeEntityGroupAdapter(); - } - @Override - public Adapter caseTrait(Trait object) { - return createTraitAdapter(); - } - @Override - public Adapter defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - @Override - public Adapter createAdapter(Notifier target) { - return modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Trait <em>Trait</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Trait - * @generated - */ - public Adapter createTraitAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup <em>Include Entity Group</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup - * @generated - */ - public Adapter createIncludeEntityGroupAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Model <em>Model</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Model - * @generated - */ - public Adapter createModelAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Entity <em>Entity</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Entity - * @generated - */ - public Adapter createEntityAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.EntityGroup <em>Entity Group</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.EntityGroup - * @generated - */ - public Adapter createEntityGroupAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //MetadataAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java deleted file mode 100644 index 708b72f1e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataResourceFactoryImpl.java,v 1.3 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * <!-- begin-user-doc --> - * The <b>Resource Factory</b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceImpl - * @generated - */ -public class MetadataResourceFactoryImpl extends ResourceFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates an instance of the resource factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Resource createResource(URI uri) { - XMLResource result = new MetadataResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //MetadataResourceFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java deleted file mode 100644 index 2db23d2b8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataResourceImpl.java,v 1.12 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.xmi.PackageNotFoundException; -import org.eclipse.emf.ecore.xmi.XMLHelper; -import org.eclipse.emf.ecore.xmi.XMLLoad; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler; -import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.xml.sax.helpers.DefaultHandler; - -/** - * <!-- begin-user-doc --> - * The <b>Resource </b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceFactoryImpl - * @generated NOT - */ -public class MetadataResourceImpl extends XMLResourceImpl implements XMLResource.ResourceHandler { - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Oracle inc."; //$NON-NLS-1$ - - /** - * IMetaDataSourceModelProvider - */ - protected IMetaDataSourceModelProvider _provider; - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param uri the URI of the new resource. - * @generated - */ - public MetadataResourceImpl(URI uri) { - super(uri); - } - - /** - * Constructor - */ - public MetadataResourceImpl() { - super(); - } - - - /** - * Constructor - * @param provider - */ - public MetadataResourceImpl(IMetaDataSourceModelProvider provider){ - super(); - _provider = provider; - } - - /** - * @generated NOT - */ - protected XMLLoad createXMLLoad() { - return new MetadataXMLLoad(createXMLHelper()); - } - /** - * Override createXMLHelper so that MetadataPackage.eINSTANCE is used for the NoNamespace package - * @generated NOT - */ - protected XMLHelper createXMLHelper() { - return new XMLHelperImpl(){ - @Override - public EPackage getNoNamespacePackage() { - return MetadataPackage.eINSTANCE; - } - }; - } - - public void postLoad(XMLResource resource, InputStream inputStream, - Map options) - { - final List<EObject> resContents = resource.getContents(); - - if (resContents.size() > 0) - { - final Object aRoot = resContents.get(0); - if (aRoot instanceof Model) - { - setModelKeyInTraits((Model) aRoot, (Model) aRoot); - } - } - else - { - JSFCommonPlugin.log(IStatus.WARNING, - "No model loaded for "+getURI()); //$NON-NLS-1$ - } - } - - private void setModelKeyInTraits(Model root, Entity currentEntity) { - // TODO: does this have side effect that we care about? nothing is done with the return value - MetadataPackage.eINSTANCE.getTrait_SourceModelProvider(); - for (int i=0;i < currentEntity.getTraits().size();i++){ - ((Trait)currentEntity.getTraits().get(i)).setSourceModelProvider(_provider); - } - for (int j=0;j < currentEntity.getChildEntities().size();j++){ - setModelKeyInTraits(root,(Entity)currentEntity.getChildEntities().get(j)); - } - - if (currentEntity == root){ - for (int k=0;k < root.getEntityGroups().size();k++){ - setModelKeyInTraits(root,(Entity)root.getEntityGroups().get(k)); - } - } - } - - - public void postSave(XMLResource resource, OutputStream outputStream, - Map options) { - // do nothing - } - - public void preLoad(XMLResource resource, InputStream inputStream, - Map options) { - // do nothing - } - - public void preSave(XMLResource resource, OutputStream outputStream, - Map options) { - // do nothing - } - - /** - * Override the handleErrors() method so that resource will load gracefully, and errors reported later - * when appropriate - * - * @generated NOT - */ - private static class MetadataXMLLoad extends XMLLoadImpl { - - public MetadataXMLLoad(XMLHelper helper) { - super(helper); - } - - @Override - protected void handleErrors() throws IOException { - //by doing nothing here, this allows the list of non-fatal errors (res.getErrors()) to be returned - } - - @Override - protected DefaultHandler makeDefaultHandler() { - return new MetadataXMLHandler(resource, helper, options); - } - } - - /** - * Ensures that only EMF extension models registered with the EMF Package Registry are considered. - * @generated NOT - */ - private static class MetadataXMLHandler extends SAXXMLHandler { - - public MetadataXMLHandler(XMLResource xmiResource, XMLHelper helper, - Map<?, ?> options) { - super(xmiResource, helper, options); - } - - @Override - protected EPackage getPackageForURI(String uriString) { - //code taken from super and modified so that only package registry is considered - if (uriString == null) - { - return null; - } - - EPackage ePackage = packageRegistry.getEPackage(uriString); - - if (ePackage != null && ePackage.eIsProxy()) - { - ePackage = null; - } - - if (ePackage == null) - { - ePackage = handleMissingPackage(uriString); - } - - if (ePackage == null) - { - error - (new PackageNotFoundException - (uriString, - getLocation(), - getLineNumber(), - getColumnNumber())); - } - - return ePackage; - } - } -} //MetadataResourceImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java deleted file mode 100644 index aa6204175..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataSwitch.java,v 1.9 2011/04/04 22:22:38 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.util.Switch; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; - - - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage - * @generated - */ -public class MetadataSwitch<T> extends Switch<T> { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static MetadataPackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataSwitch() { - if (modelPackage == null) { - modelPackage = MetadataPackage.eINSTANCE; - } - } - - /** - * Checks whether this is a switch for the given package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @parameter ePackage the package in question. - * @return whether this is a switch for the given package. - * @generated - */ - @Override - protected boolean isSwitchFor(EPackage ePackage) { - return ePackage == modelPackage; - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - @Override - protected T doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case MetadataPackage.MODEL: { - Model model = (Model)theEObject; - T result = caseModel(model); - if (result == null) result = caseEntity(model); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.ENTITY_GROUP: { - EntityGroup entityGroup = (EntityGroup)theEObject; - T result = caseEntityGroup(entityGroup); - if (result == null) result = caseEntity(entityGroup); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.ENTITY: { - Entity entity = (Entity)theEObject; - T result = caseEntity(entity); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.INCLUDE_ENTITY_GROUP: { - IncludeEntityGroup includeEntityGroup = (IncludeEntityGroup)theEObject; - T result = caseIncludeEntityGroup(includeEntityGroup); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.TRAIT: { - Trait trait = (Trait)theEObject; - T result = caseTrait(trait); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Trait</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Trait</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseTrait(Trait object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Include Entity Group</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Include Entity Group</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseIncludeEntityGroup(IncludeEntityGroup object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Model</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Model</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseModel(Model object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Entity</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Entity</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseEntity(Entity object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Entity Group</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Entity Group</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public T caseEntityGroup(EntityGroup object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - @Override - public T defaultCase(EObject object) { - return null; - } - -} //MetadataSwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java deleted file mode 100644 index cc5fdbb33..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataXMLProcessor.java,v 1.5 2011/03/16 21:14:13 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - - -/** - * This class contains helper methods to serialize and deserialize XML documents - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class MetadataXMLProcessor extends XMLProcessor { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - - /** - * Public constructor to instantiate the helper. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - MetadataPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the MetadataResourceFactoryImpl factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected Map<String, Resource.Factory> getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new MetadataResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new MetadataResourceFactoryImpl()); - } - return registrations; - } - -} //MetadataXMLProcessor |