Java Code Examples for org.eclipse.emf.ecore.resource.ResourceSet

The following are top voted examples for showing how to use org.eclipse.emf.ecore.resource.ResourceSet. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: neoscada   File: Generate.java   Source Code and License 6 votes vote down vote up
/**
 * This can be used to update the resource set's resource factory registry with all needed factories.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
    super.registerResourceFactories(resourceSet);
    /*
     * If you want to change the content of this method, do NOT forget to change the "@generated"
     * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
     * of the Acceleo module with the main template that has caused the creation of this class will
     * revert your modifications.
     */
    
    /*
     * TODO If you need additional resource factories registrations, you can register them here. the following line
     * (in comment) is an example of the resource factory registration for UML.
     *
     * If you want to use the generator in stand alone, the resource factory registration will be required.
     *  
     * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). 
     */ 
    
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*.xmi", new XMIResourceFactoryImpl());
}
 
Example 2
Project: time4sys   File: SoftwareInterfaceGeneralPropertiesEditionComponent.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final SoftwareInterface softwareInterface = (SoftwareInterface)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.General.Properties.name))
			generalPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, softwareInterface.getName()));
		
		// init filters
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 3
Project: time4sys   File: HardwareBusTimingPropertiesEditionComponent.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final HardwareBus hardwareBus = (HardwareBus)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		// init filters
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 4
Project: neoscada   File: ModelLoader.java   Source Code and License 6 votes vote down vote up
public T load ( final URI uri, final String contentTypeId ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( uri, contentTypeId );
    r.load ( null );

    for ( final Object o : r.getContents () )
    {
        if ( this.clazz.isAssignableFrom ( o.getClass () ) )
        {
            return this.clazz.cast ( o );
        }
    }

    throw new IllegalStateException ( String.format ( "Model %s does not contain an object of type %s", uri, this.clazz ) );
}
 
Example 5
Project: OCCI-Studio   File: Main.java   Source Code and License 6 votes vote down vote up
/**
 * This can be used to update the resource set's resource factory registry with all needed factories.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated
 */
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
    super.registerResourceFactories(resourceSet);
    /*
     * If you want to change the content of this method, do NOT forget to change the "@generated"
     * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
     * of the Acceleo module with the main template that has caused the creation of this class will
     * revert your modifications.
     */
    
    /*
     * TODO If you need additional resource factories registrations, you can register them here. the following line
     * (in comment) is an example of the resource factory registration for UML.
     *
     * If you want to use the generator in stand alone, the resource factory registration will be required.
     *  
     * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). 
     */ 
    
    // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
}
 
Example 6
Project: gemoc-studio-modeldebugging   File: SelectAnyEObjectDialog.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 7
Project: time4sys   File: ResourceProtectionParameterValuePropertiesEditionComponent.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * @generated
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final ResourceProtectionParameterValue resourceProtectionParameterValue = (ResourceProtectionParameterValue)elt;
		final ResourceProtectionParameterValuePropertiesEditionPart basePart = (ResourceProtectionParameterValuePropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(AnalysisViewsRepository.ResourceProtectionParameterValue.Properties.name))
			basePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, resourceProtectionParameterValue.getName()));
		
		if (isAccessible(AnalysisViewsRepository.ResourceProtectionParameterValue.Properties.value))
			basePart.setValue(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, resourceProtectionParameterValue.getValue()));
		
		// init filters
		
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 8
Project: n4js   File: N4HeadlessCompiler.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the common resource set to use during compilation. Installs a light weight index.
 *
 * @return the resource set
 */
private ResourceSet createResourceSet() {
	// TODO try to reuse code from IN4JSCore.createResourceSet

	XtextResourceSet resourceSet = xtextResourceSetProvider.get();
	resourceSet.setClasspathURIContext(classLoader);

	// Install containerState as adapter.
	resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(rsbAcs));

	// Install a lightweight index.
	OrderedResourceDescriptionsData index = new OrderedResourceDescriptionsData(Collections.emptyList());
	ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, index);

	return resourceSet;
}
 
Example 9
Project: OCCI-Studio   File: RegisterOCCIExtensionAction.java   Source Code and License 6 votes vote down vote up
/**
 * @see IActionDelegate#run(IAction)
 */
public void run(IAction action) {
	if (selection != null) {
		IFile selectedFile = (IFile) ((IStructuredSelection) selection)
				.getFirstElement();

		// Use a platform:/resource/ URI
		URI uri = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);

		ResourceSet rs = new ResourceSetImpl();
		Resource r = rs.getResource(uri, true);

		Extension extension = (Extension) r.getContents().get(0);
		OcciRegistry.getInstance().registerExtension(extension.getScheme(),
				uri.toString());
		closeOtherSessions(selectedFile.getProject());
		MessageDialog.openInformation(shell,
				Messages.RegisterExtensionAction_ExtRegistration,
				Messages.RegisterExtensionAction_RegisteredExtension
						+ extension.getScheme());
	}
}
 
Example 10
Project: time4sys   File: ProtectionParameterGeneralPropertiesEditionComponent.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final ProtectionParameter protectionParameter = (ProtectionParameter)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(GrmViewsRepository.General.Properties.name))
			generalPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, protectionParameter.getName()));
		
		// init filters
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 11
Project: n4js   File: EclipseBasedN4JSWorkspace.java   Source Code and License 6 votes vote down vote up
ProjectDescription loadManifest(URI manifest) {
	try {
		ProjectDescription result = null;
		ResourceSet resourceSet = resourceSetProvider.get(null /* we don't care about the project right now */);
		String platformPath = manifest.toPlatformString(true);
		if (manifest.isArchive() || platformPath != null) {
			if (manifest.isArchive() || workspace.getFile(new Path(platformPath)).exists()) {
				Resource resource = resourceSet.getResource(manifest, true);
				if (resource != null) {
					List<EObject> contents = resource.getContents();
					if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
						return null;
					}
					result = (ProjectDescription) contents.get(0);
					contents.clear();
				}
			}
		}
		return result;
	} catch (WrappedException e) {
		throw new IllegalStateException("Unexpected manifest URI: " + manifest, e);
	}
}
 
Example 12
Project: time4sys   File: TimerResourceTimingPropertiesEditionComponent.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final TimerResource timerResource = (TimerResource)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(GrmViewsRepository.Timing.TimingProperties.duration)) {
			timingPart.setDuration(EEFConverterUtil.convertToString(EcorePackage.Literals.EFLOAT, timerResource.getDuration()));
		}
		
		// init filters
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 13
Project: neoscada   File: DaveDriverImpl.java   Source Code and License 6 votes vote down vote up
/**
 * @generated NOT
 */
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ), "org.eclipse.scada.configuration.world.osgi.profile" );
        try
        {
            r.load ( null );
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( e );
        }
        this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
        if ( this.profile == null )
        {
            throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
        }
    }

    return this.profile;
}
 
Example 14
Project: neoscada   File: CommonPackageHandler.java   Source Code and License 6 votes vote down vote up
/**
 * Inject the CA bootstrap property to the profile
 *
 * @param file
 *            the profile.xml file in the package target
 * @throws IOException
 */
protected void patchProfile ( final String appName, final File file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) );
    r.load ( null );

    final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
    Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" );
    r.save ( null );
}
 
Example 15
Project: gemoc-studio-modeldebugging   File: GemocToggleBreakpointAction.java   Source Code and License 6 votes vote down vote up
@Override
protected DSLToggleBreakpointsUtils createToggleBreakpointsUtils() {
	return new DSLToggleBreakpointsUtils(getModelIdentifier()){
		
		@Override
		protected DSLBreakpoint createBreakpoint(Object selected,
				EObject instruction) throws CoreException {
			final Resource res = ((EObject)instruction).eResource();
			final ResourceSet resSet = res.getResourceSet();
			final MelangeResource mr = resSet.getResources().stream().filter(r -> {
				return r instanceof MelangeResource;
			}).map(r -> (MelangeResource)r).findFirst().orElse(null);
			if (mr != null) {
				final String fragmentURI = res.getURIFragment(instruction);
				instruction = mr.getWrappedResource().getEObject(fragmentURI);
			}
			return new GemocBreakpoint(identifier, instruction, true);
		}
		
	};
}
 
Example 16
Project: n4js   File: N4JSDirtyStateEditorSupport.java   Source Code and License 6 votes vote down vote up
private List<Resource> collectTransitivelyDependentResources(XtextResource resource,
		Set<URI> deltaURIs) {
	List<Resource> result = Lists.newArrayList();
	ResourceSet resourceSet = resource.getResourceSet();
	for (Resource candidate : resourceSet.getResources()) {
		if (candidate != resource) {
			URI uri = candidate.getURI();
			if (deltaURIs.contains(uri)) {
				// the candidate is contained in the delta list
				// schedule it for unloading
				result.add(candidate);
			} else if (candidate instanceof N4JSResource) {
				// the candidate does depend on one of the changed resources
				// schedule it for unloading
				if (canLoadFromDescriptionHelper.dependsOnAny(candidate, deltaURIs)) {
					result.add(candidate);
				}
			}
		}
	}
	return result;
}
 
Example 17
Project: gemoc-studio-modeldebugging   File: DebugPermissionProvider.java   Source Code and License 6 votes vote down vote up
@Override
public boolean provides(ResourceSet set) {
	final boolean res;

	if (set != null && set.getURIConverter() != null) {
		URIConverter converter = set.getURIConverter();
		if (converter.getURIHandlers().size() > 0) {
			res = converter.getURIHandlers().get(0) instanceof DebugURIHandler;
		} else {
			res = false;
		}
	} else {
		res = false;
	}

	return res;
}
 
Example 18
Project: n4js   File: ASTGraphProvider.java   Source Code and License 6 votes vote down vote up
private List<Resource> getElements(ResourceSet resSet, final List<Object> result) {
	final List<Resource> ignoredResources = new ArrayList<>();

	for (Resource res : new ArrayList<>(resSet.getResources())) {
		final boolean isFirstResource = result.isEmpty();
		// only show contents of first resource + .n4js resources
		// (avoid showing built-in types or letting graph become to large)
		String uriStr = res.getURI().toString();
		if (isFirstResource || uriStr.endsWith(".n4js") || uriStr.endsWith(".n4jsd")) {
			getElementsForN4JSs(result, res);

		} else if (SHOW_BUILT_IN.length > 0
				&& (uriStr.endsWith("builtin_js.n4ts") || uriStr.endsWith("builtin_n4.n4ts"))) {

			getElementsForBuiltIns(result, ignoredResources, res);

		} else {
			// ignore the resource
			ignoredResources.add(res);
		}
	}
	return ignoredResources;
}
 
Example 19
Project: gemoc-studio-modeldebugging   File: CommandExecution.java   Source Code and License 6 votes vote down vote up
public static Object execute(TransactionalEditingDomain editingDomain, RecordingCommand command) {
	final CommandStack commandStack = editingDomain.getCommandStack();
	ResourceSet rs = editingDomain.getResourceSet();
	IExecutionCheckpoint checkpoint = IExecutionCheckpoint.CHECKPOINTS.get(rs);
	Object result = null;
	try {
		if (checkpoint != null) {
			checkpoint.allow(rs, true);
		}
		commandStack.execute(command);
		if (command.getResult() != null && command.getResult().size() == 1) {
			result = command.getResult().iterator().next();
		}
	} finally {
		if (checkpoint != null) {
			checkpoint.allow(rs, false);
		}
	}
	return result;
}
 
Example 20
Project: OCCI-Studio   File: Generate.java   Source Code and License 6 votes vote down vote up
/**
 * This can be used to update the resource set's resource factory registry with all needed factories.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated
 */
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
    super.registerResourceFactories(resourceSet);
    /*
     * If you want to change the content of this method, do NOT forget to change the "@generated"
     * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
     * of the Acceleo module with the main template that has caused the creation of this class will
     * revert your modifications.
     */
    
    /*
     * TODO If you need additional resource factories registrations, you can register them here. the following line
     * (in comment) is an example of the resource factory registration for UML.
     *
     * If you want to use the generator in stand alone, the resource factory registration will be required.
     *  
     * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents). 
     */ 
    
    // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
}
 
Example 21
Project: time4sys   File: SoftwarePortOtherPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final SoftwarePort softwarePort = (SoftwarePort)elt;
		final OtherPropertiesEditionPart otherPart = (OtherPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.Other.Properties.packetSize)) {
			otherPart.setPacketSize(EEFConverterUtil.convertToString(EcorePackage.Literals.EINT, softwarePort.getPacketSize()));
		}
		
		if (isAccessible(SrmViewsRepository.Other.Properties.pInterface)) {
			pInterfaceSettings = new ReferencesTableSettings(softwarePort, GrmPackage.eINSTANCE.getResourcePort_PInterface());
			otherPart.initPInterface(pInterfaceSettings);
		}
		if (isAccessible(SrmViewsRepository.Other.Properties.rInterface)) {
			rInterfaceSettings = new ReferencesTableSettings(softwarePort, GrmPackage.eINSTANCE.getResourcePort_RInterface());
			otherPart.initRInterface(rInterfaceSettings);
		}
		// init filters
		
		if (isAccessible(SrmViewsRepository.Other.Properties.pInterface)) {
			otherPart.addFilterToPInterface(new EObjectFilter(GrmPackage.Literals.RESOURCE_INTERFACE));
			// Start of user code for additional businessfilters for pInterface
			// End of user code
		}
		if (isAccessible(SrmViewsRepository.Other.Properties.rInterface)) {
			otherPart.addFilterToRInterface(new EObjectFilter(GrmPackage.Literals.RESOURCE_INTERFACE));
			// Start of user code for additional businessfilters for rInterface
			// End of user code
		}
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 22
Project: time4sys   File: HardwareWatchdogPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == HrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Timing.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}
 
Example 23
Project: time4sys   File: HardwareSupportTimingPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final HardwareSupport hardwareSupport = (HardwareSupport)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(HrmViewsRepository.Timing.TimingProperties.clock)) {
			// init part
			clockSettings = new EObjectFlatComboSettings(hardwareSupport, HrmPackage.eINSTANCE.getHardwareResource_Clock());
			timingPart.initClock(clockSettings);
			// set the button mode
			timingPart.setClockButtonMode(ButtonsModeEnum.BROWSE);
		}
		// init filters
		if (isAccessible(HrmViewsRepository.Timing.TimingProperties.clock)) {
			timingPart.addFilterToClock(new ViewerFilter() {
			
				/**
				 * {@inheritDoc}
				 * 
				 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
				 */
				public boolean select(Viewer viewer, Object parentElement, Object element) {
					return (element instanceof String && element.equals("")) || (element instanceof HardwareClock); //$NON-NLS-1$ 
				}
				
			});
			// Start of user code for additional businessfilters for clock
			// End of user code
		}
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 24
Project: time4sys   File: SchedulerPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == GrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == GrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}
 
Example 25
Project: neoscada   File: CreateProjectOperation.java   Source Code and License 5 votes vote down vote up
private static Selector createSelector ( final IPath path ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( path.toString () ) );
    r.load ( bundleResource ( path ), null );
    return EcoreUtil.copy ( (Selector)r.getContents ().get ( 0 ) );
}
 
Example 26
Project: n4js   File: XcoreReader.java   Source Code and License 5 votes vote down vote up
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
		Issues issues) {
	ResourceSet resourceSet = getResourceSet();

	// due to some Xcore peculiarity we have to access the IAllContainerState here
	// to trigger some lazy init logic
	IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			IAllContainersState.class);
	allContainerState.isEmpty("");

	Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes,
			new Predicate<URI>() {
		@Override
		public boolean apply(URI input) {
			return input.fileExtension().equals(XCORE_FILE_EXT);
		}
	});
	List<Resource> resources = new ArrayList<>();
	for (URI uri : uris.values()) {
		LOGGER.info(uri);
		try {
			resources.add(parse(uri, resourceSet));
		} catch (Exception e) {
			LOGGER.error("Problem during loading of resource @ " + uri, e);
		}
	}
	installIndex(resourceSet);
	for (Resource r : resources) {
		EcoreUtil.resolveAll(r);
		for (Diagnostic x : r.getErrors()) {
			issues.addError(x.getMessage(), x);
		}

	}
	ctx.set(slot, resources);
}
 
Example 27
Project: time4sys   File: ResourceBrokerPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == GrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == GrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}
 
Example 28
Project: neoscada   File: XmlConfigurator.java   Source Code and License 5 votes vote down vote up
private RootType parse ( final URI uri ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () );
    final Resource r = rs.createResource ( uri );
    r.load ( null );
    final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT );
    if ( doc == null )
    {
        return null;
    }
    return doc.getRoot ();
}
 
Example 29
Project: OCCI-Studio   File: Generate.java   Source Code and License 5 votes vote down vote up
/**
 * This can be used to update the resource set's package registry with all needed EPackages.
 * 
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated
 */
@Override
public void registerPackages(ResourceSet resourceSet) {
    super.registerPackages(resourceSet);
    if (!isInWorkspace(org.eclipse.emf.ecore.EcorePackage.class)) {
        resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
    }
    
    /*
     * If you want to change the content of this method, do NOT forget to change the "@generated"
     * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
     * of the Acceleo module with the main template that has caused the creation of this class will
     * revert your modifications.
     */
    
    /*
     * If you need additional package registrations, you can register them here. The following line
     * (in comment) is an example of the package registration for UML.
     * 
     * You can use the method  "isInWorkspace(Class c)" to check if the package that you are about to
     * register is in the workspace.
     * 
     * To register a package properly, please follow the following conventions:
     *
     * If the package is located in another plug-in, already installed in Eclipse. The following content should
     * have been generated at the beginning of this method. Do not register the package using this mechanism if
     * the metamodel is located in the workspace.
     *  
     * if (!isInWorkspace(UMLPackage.class)) {
     *     // The normal package registration if your metamodel is in a plugin.
     *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
     * }
     * 
     * If the package is located in another project in your workspace, the plugin containing the package has not
     * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
     * stand alone, the regular registration (seen a couple lines before) is needed.
     * 
     * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
     */
}
 
Example 30
Project: time4sys   File: SoftwareArchitectureTimingPropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final SoftwareArchitecture softwareArchitecture = (SoftwareArchitecture)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.Timing.Properties.resCtrlPolicy)) {
			resCtrlPolicySettings = new ReferencesTableSettings(softwareArchitecture, GrmPackage.eINSTANCE.getResourceManager_ResCtrlPolicy());
			timingPart.initResCtrlPolicy(resCtrlPolicySettings);
		}
		// init filters
		if (isAccessible(SrmViewsRepository.Timing.Properties.resCtrlPolicy)) {
			timingPart.addFilterToResCtrlPolicy(new ViewerFilter() {
				/**
				 * {@inheritDoc}
				 * 
				 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
				 */
				public boolean select(Viewer viewer, Object parentElement, Object element) {
					return (element instanceof ResourceControlPolicy);
				}
		
			});
			// Start of user code for additional businessfilters for resCtrlPolicy
			// End of user code
		}
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 31
Project: n4js   File: AbstractBuilderParticipantTest.java   Source Code and License 5 votes vote down vote up
/***/
protected ResourceSet getResourceSet(IProject project) {
	if (resourceSet == null) {
		resourceSet = getInjector().getInstance(IResourceSetProvider.class).get(project);
	}
	return resourceSet;
}
 
Example 32
Project: neoscada   File: ModelWriter.java   Source Code and License 5 votes vote down vote up
public void store ( final URI uri ) throws IOException
{
    logger.debug ( "Storing model to: {}", uri );

    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( uri );
    r.getContents ().add ( this.content );
    r.save ( null );
}
 
Example 33
Project: neoscada   File: CreateProjectOperation.java   Source Code and License 5 votes vote down vote up
private static CustomizationPipeline createPipeline ( final IPath path ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( path.toString () ) );
    r.load ( bundleResource ( path ), null );
    return EcoreUtil.copy ( (CustomizationPipeline)r.getContents ().get ( 0 ) );
}
 
Example 34
Project: time4sys   File: HardwareCommunicationResourcePropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == HrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Timing.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}
 
Example 35
Project: time4sys   File: SoftwareAccessServicePropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final SoftwareAccessService softwareAccessService = (SoftwareAccessService)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.General.Properties.name))
			generalPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, softwareAccessService.getName()));
		
		if (isAccessible(SrmViewsRepository.General.Properties.isModifier)) {
			generalPart.setIsModifier(softwareAccessService.isIsModifier());
		}
		if (isAccessible(SrmViewsRepository.General.Properties.accessedElement))
			generalPart.setAccessedElement(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, softwareAccessService.getAccessedElement()));
		
		// init filters
		
		
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 36
Project: neoscada   File: CreateProjectOperation.java   Source Code and License 5 votes vote down vote up
protected static Resource save ( final ResourceSet rs, final URI base, final String localName, final EObject content, final String contentType ) throws IOException
{
    final Resource resource = rs.createResource ( base.appendSegments ( localName.split ( "\\/" ) ), contentType );
    resource.getContents ().add ( content );
    resource.save ( null );
    return resource;
}
 
Example 37
Project: time4sys   File: HardwareDevicePropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == HrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Timing.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == HrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}
 
Example 38
Project: time4sys   File: SoftwareResourcePackagePropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, 
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final SoftwareResourcePackage softwareResourcePackage = (SoftwareResourcePackage)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.General.Properties.name))
			generalPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, softwareResourcePackage.getName()));
		
		if (isAccessible(SrmViewsRepository.General.Properties.ownedElement)) {
			ownedElementSettings = new ReferencesTableSettings(softwareResourcePackage, GrmPackage.eINSTANCE.getResourcePackage_OwnedElement());
			generalPart.initOwnedElement(ownedElementSettings);
		}
		// init filters
		
		if (isAccessible(SrmViewsRepository.General.Properties.ownedElement)) {
			generalPart.addFilterToOwnedElement(new ViewerFilter() {
				/**
				 * {@inheritDoc}
				 * 
				 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
				 */
				public boolean select(Viewer viewer, Object parentElement, Object element) {
					return (element instanceof String && element.equals("")) || (element instanceof ResourcePackageableElement); //$NON-NLS-1$ 
				}
		
			});
			// Start of user code for additional businessfilters for ownedElement
			// End of user code
		}
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 39
Project: Tarski   File: ModelIO.java   Source Code and License 5 votes vote down vote up
public ResourceSet getResourceSet() {
  if (this.resourceSet == null) {
    this.resourceSet = new ResourceSetImpl();
    this.resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
        .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new persistenceResourceFactoryImpl());
    this.registerPackages(this.resourceSet.getPackageRegistry());
    this.resourceSet.getPackageRegistry().put(persistencePackage.eNS_URI,
        persistencePackage.eINSTANCE);
  }

  return this.resourceSet;
}
 
Example 40
Project: time4sys   File: SoftwareMutualExclusionResourcePropertiesEditionComponent.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.eef.runtime.impl.components.ComposedPropertiesEditionComponent#
 *      initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 * 
 */
public void initPart(java.lang.Object key, int kind, EObject element, ResourceSet allResource) {
	if (key == SrmViewsRepository.General.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == SrmViewsRepository.Timing.class) {
		super.initPart(key, kind, element, allResource);
	}
	if (key == SrmViewsRepository.Other.class) {
		super.initPart(key, kind, element, allResource);
	}
}