当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getAllContents方法代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.resource.Resource.getAllContents方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getAllContents方法的具体用法?Java Resource.getAllContents怎么用?Java Resource.getAllContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.ecore.resource.Resource的用法示例。


在下文中一共展示了Resource.getAllContents方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Validate

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public Validate()
{
	Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("calender", new XMIResourceFactoryImpl());
    

	ResourceSet rs = new ResourceSetImpl();
	Resource r = rs.getResource(URI.createFileURI("model/mynew.calender"), true);
	
	EObject root = r.getContents().get(0);
	
	Iterator<EObject> i = r.getAllContents();
	while(i.hasNext())
		System.out.println(i.next());
}
 
开发者ID:Nielko,项目名称:MBSE-Vacation-Manager,代码行数:17,代码来源:Validate.java

示例2: cosem

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static void cosem(Resource cosemResource, Root root, Hashtable<String, MeterAsset> allMeterAssets) {
	HashSet<PhysicalDevice> devices = new HashSet<>();
	HashSet<MeterAssetPhysicalDevicePair> devicePairs = new HashSet<>();
	TreeIterator<EObject> cosemIterator = cosemResource.getAllContents();
	while (cosemIterator.hasNext()) {
		EObject eOb = cosemIterator.next();
		if (eOb instanceof PhysicalDevice) {
			PhysicalDevice device = (PhysicalDevice) eOb;
			devices.add(device);
			String idNs = device.getID();
			if (allMeterAssets.containsKey(idNs)) {
				MeterAssetPhysicalDevicePair pair = GluemodelFactory.eINSTANCE
						.createMeterAssetPhysicalDevicePair();
				pair.setB(device);
				pair.setA(allMeterAssets.get(idNs));
				devicePairs.add(pair);
			}
		}
	}

	root.getMeterAssetToPhysicalDevice().addAll(devicePairs);
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:23,代码来源:GlueModelCreator.java

示例3: SelectAnyEObjectDialog

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public SelectAnyEObjectDialog(Shell parent, ResourceSet resourceSet, ILabelProvider renderer) {
	super(parent, renderer);
	_searchedResourceSet = resourceSet;
	ArrayList<EObject> all = new ArrayList<EObject>();
	EcoreUtil.resolveAll(resourceSet);
	for (Resource r : _searchedResourceSet.getResources())
	{
		for (TreeIterator<EObject> iterator = r.getAllContents(); iterator.hasNext();) {
			EObject o =  iterator.next();
			if(select(o)) all.add(o);
		}
	}
	
	Object[] elements = all.toArray();
	this.setElements(elements);
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:17,代码来源:SelectAnyEObjectDialog.java

示例4: addInitialState

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void addInitialState() {
	if (lastState == null) {
		// Creation of the initial state
		Set<Resource> allResources = getAllExecutedModelResources();
		lastState = fsmTrace.States.StatesFactory.eINSTANCE.createSpecificState();
		for (Resource r : allResources) {
			for (TreeIterator<EObject> i = r.getAllContents(); i.hasNext();) {
				EObject o = i.next();

				if (o instanceof org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement) {
					org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement o_cast = (org.eclipse.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.NamedElement) o;
					addNewObjectToState(o_cast, lastState);
				}
			}
		}
		this.traceRoot.getStates().add(lastState);
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:19,代码来源:FsmTraceConstructor.java

示例5: compute

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param object_p: The model element for which the Contextual Explorer extension is generated
* @return List of object to display in the parent category
* @generated
*/
public List<Object> compute(Object object_p) {
	List<Object> result = new ArrayList<Object>();
	Resource resource = ((EObject) object_p).eResource();
	if (resource != null) {
		for (TreeIterator<EObject> iter = resource.getAllContents(); iter.hasNext();) {
			EObject eObject = iter.next();

			if (eObject instanceof Alarm) {
				Alarm referencingElement = (Alarm) eObject;
				if (referencingElement.getTimers() != null && referencingElement.getTimers().contains(object_p))
					result.add(eObject);
			}
		}
	}
	return result;
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:24,代码来源:ReferencingViewpointElementQuery.java

示例6: compute

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @param object_p:
 *            The model element for which the Contextual Explorer extension
 *            is generated
 * @return List of object to display in the parent category
 * @generated
 */
public List<Object> compute(Object object_p) {
	List<Object> result = new ArrayList<Object>();
	Resource resource = ((EObject) object_p).eResource();
	if (resource != null) {
		for (TreeIterator<EObject> iter = resource.getAllContents(); iter.hasNext();) {
			EObject eObject = iter.next();
			if (eObject instanceof Step) {
				Step referencingElement = (Step) eObject;
				if (referencingElement.getConcurRes() != null && referencingElement.getConcurRes().equals(object_p))
					result.add(eObject);
			}
		}
	}
	return result;
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:25,代码来源:ReferencingViewpointElementQuery.java

示例7: getSuperTypeImports

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
protected List<ImportNormalizer> getSuperTypeImports(Resource res, EReference reference) {
	List<ImportNormalizer> result = Lists.newArrayList();
	TreeIterator<EObject> allContents = res.getAllContents();
	while (allContents.hasNext()) {
		EObject next = allContents.next();
		if (next instanceof ContractDefinition) {
			ContractDefinition contract = (ContractDefinition) next;
			EList<ComplexType> superTypes = contract.getSuperTypes();
			for (ComplexType complexType : superTypes) {
				// if (complexType.eIsProxy() || complexType.getName() ==
				// null)
				// continue;
				ImportNormalizer resolver = createImportedNamespaceResolver(complexType.getName() + ".*", false);
				result.add(resolver);
			}
			allContents.prune();
		}
	}
	return result;
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:21,代码来源:SolidityImportedNamespaceAwareLocalScopeProvider.java

示例8: getAllMMXU

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private static HashSet<MMXU> getAllMMXU(Resource resource) {
	HashSet<MMXU> mmxus = new HashSet<MMXU>();
	TreeIterator<EObject> iterator = resource.getAllContents();
	while (iterator.hasNext()) {
		EObject eOb = iterator.next();
		if (eOb instanceof MMXU) {
			MMXU asset = (MMXU) eOb;
			mmxus.add(asset);
		}
	}
	return mmxus;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:13,代码来源:GlueModelCreator.java

示例9: getAllMeterAssets

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private static Hashtable<String, MeterAsset> getAllMeterAssets(Resource resource) {
	Hashtable<String, MeterAsset> assets = new Hashtable<>();
	TreeIterator<EObject> iterator = resource.getAllContents();
	while (iterator.hasNext()) {
		EObject eOb = iterator.next();
		if (eOb instanceof MeterAsset) {
			MeterAsset asset = (MeterAsset) eOb;
			assets.put(asset.getMRID(), asset);
		}
	}
	return assets;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:13,代码来源:GlueModelCreator.java

示例10: computeCrossRefs

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
/**
 * Collects all Types, TVariables, TLiterals and IdentifiableElements that are directly referenced somewhere in the
 * given resource and aren't contained in this resource. References between AST element to its defined type and vice
 * versa as well as references to built-in and primitive types are ignored.
 *
 * @param resource
 *            the given fully resolved resource
 * @param acceptor
 *            the logic that collects the passed EObject found in a cross reference
 */
public void computeCrossRefs(Resource resource, IAcceptor<EObject> acceptor) {
	TreeIterator<EObject> allASTContentsIter;
	if (resource instanceof N4JSResource) {
		Script script = ((N4JSResource) resource).getScript();
		// We traverse the AST but not the TModule tree
		allASTContentsIter = script.eAllContents();
	} else {
		allASTContentsIter = resource.getAllContents();
	}
	while (allASTContentsIter.hasNext()) {
		EObject eObject = allASTContentsIter.next();
		computeCrossRefs(resource, eObject, acceptor);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:25,代码来源:N4JSCrossReferenceComputer.java

示例11: addInitialState

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void addInitialState() {
	if (lastState == null) {
		// Creation of the initial state
		Set<Resource> allResources = getAllExecutedModelResources();
		
		lastState = GenerictraceFactory.eINSTANCE.createGenericState();
		for (Resource r : allResources) {
			for (TreeIterator<EObject> i = r.getAllContents(); i.hasNext();) {
				final EObject o = i.next();
				addNewObjectToStateIfDynamic(o, lastState);
			}
		}
		this.traceRoot.getStates().add(lastState);
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:16,代码来源:GenericTraceConstructor.java

示例12: main

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
public static void main(String[] args) {
	CalenderPackage.eINSTANCE.eClass();

	
	Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
    Map<String, Object> m = reg.getExtensionToFactoryMap();
    m.put("calender", new XMIResourceFactoryImpl());
    

	ResourceSet rs = new ResourceSetImpl();
	Resource r = rs.getResource(URI.createFileURI("my.calender111"), true);
	
	EObject root = r.getContents().get(0);
	
	Iterator<EObject> i = r.getAllContents();
	while(i.hasNext())
		System.out.println(i.next());
}
 
开发者ID:Nielko,项目名称:MBSE-Vacation-Manager,代码行数:19,代码来源:Vacation_Manager_Loader.java

示例13: initializeMutableDatas

import org.eclipse.emf.ecore.resource.Resource; //导入方法依赖的package包/类
private void initializeMutableDatas() {
	mutableFields.clear();
	lastSuspendMutableFields = new HashMap<MutableField, Object>();
	nextSuspendMutableFields = new HashMap<MutableField, Object>();

	// We fetch all resources concerned by the execution,
	// since they may contain mutable fields
	Resource executedResource = executedModelRoot.eResource();
	Set<Resource> allResources = org.eclipse.gemoc.commons.eclipse.emf.EMFResource.getRelatedResources(executedResource);
	allResources.add(executedResource);
	allResources.removeIf(r -> r == null);

	// We try each extractor
	for (IMutableFieldExtractor extractor : mutableFieldExtractors) {

		// On all objects of all resources
		for (Resource resource : allResources) {
			TreeIterator<EObject> iterator = resource.getAllContents();
			while (iterator.hasNext()) {
				EObject eObject = iterator.next();
				mutableFields.addAll(extractor.extractMutableField(eObject));

				// If we found private stuff, we make it public
				Arrays.asList(eObject.getClass().getDeclaredFields()).stream().forEach((f) -> {
					try {
						f.setAccessible(true);
					} catch (Exception e) {
					}
				});
			}
		}

		// If we found stuff with an extractor, we stop searching to
		// avoid redundancies
		if (!mutableFields.isEmpty())
			break;
	}

	// we sort the list of mutable data objects by name
	mutableFields.sort(new Comparator<MutableField>() {
		@Override
		public int compare(MutableField o1, MutableField o2) {
			return o1.getName().compareTo(o2.getName());
		}
	});
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:47,代码来源:AbstractGemocDebugger.java


注:本文中的org.eclipse.emf.ecore.resource.Resource.getAllContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。