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);
	}
}
 
Example 41
Project: neoscada   File: GenerateData.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 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 42
Project: bromium   File: DslParserTest.java   Source Code and License 5 votes vote down vote up
private void initMocks(File file) {
    applicationConfiguration = mock(ApplicationConfiguration.class);
    model = mock(Model.class);
    resource = mock(Resource.class, RETURNS_DEEP_STUBS);
    when(resource.getAllContents().next()).thenReturn(model);
    resourceSet = mock(ResourceSet.class);
    when(resourceSet.getResource(URI.createFileURI(file.getAbsolutePath()), true)).thenReturn(resource);
    resourceValidator = mock(IResourceValidator.class);
    ASTNodeConverter = mock(ASTNodeConverter.class);
    when(ASTNodeConverter.convert(model)).thenReturn(applicationConfiguration);
}
 
Example 43
Project: time4sys   File: HardwarePldTimingPropertiesEditionComponent.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 HardwarePld hardwarePld = (HardwarePld)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(HrmViewsRepository.Timing.TimingProperties.clock)) {
			// init part
			clockSettings = new EObjectFlatComboSettings(hardwarePld, 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 44
Project: gemoc-studio   File: FSM.java   Source Code and License 5 votes vote down vote up
public static FSM load(final String uri) {
  ResourceSet rs = new ResourceSetImpl();
  Resource res = rs.getResource(URI.createURI(uri), true);
  FSM mm = new FSM();
  mm.setResource(res);
  return mm ;
}
 
Example 45
Project: OCCI-Studio   File: GenUtils.java   Source Code and License 5 votes vote down vote up
public static Extension resolveExtension(final EPackage ePackage) {
	Boolean put = true;
	Extension extension = null;

	String metamodelURI = ePackage.getNsURI();
	extension = namespace2extension.get(metamodelURI);
	// If extension not found then
	// System.out.println("beforeExtension "+namespace2extension);
	// System.out.println("beforeExtension "+extension);
	if (extension == null) {
		// Search URI of the extension into the OCCI extension registry.
		String scheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(metamodelURI);
		String extensionURI = OcciRegistry.getInstance().getExtensionURI(scheme);
		// If extension URI not found then
		if (extensionURI == null) {
			// This is no way to resolve the kind of the given entity :-(
			// TODO: perhaps compute extensionURI of the ePackage of the entity's eClass.
			put = false;
			// Use OCCI Core resource, link or entity kind instances.
			extensionURI = OcciRegistry.getInstance().getExtensionURI(OcciCoreConstants.OCCI_CORE_SCHEME);
		}
		// Here extensionURI is set.
		assert (extensionURI != null);
		// Compute the resource set where loading the extension.
		ResourceSet resourceSet = new ResourceSetImpl();
		// Load the extension.
		Resource extensionResource = resourceSet.getResource(URI.createURI(extensionURI), true);
		extension = (Extension) extensionResource.getContents().get(0);
		// Map the metamodelURI to the found extension for optimizing next searches.
		if (put)
			namespace2extension.put(metamodelURI, extension);
	}
	// Return the found entity's kind.
	// System.out.println("afterExtension "+namespace2extension);
	// System.out.println("afterExtension "+extension);
	return extension;
}
 
Example 46
Project: time4sys   File: HardwareInterfacePackagePropertiesEditionComponent.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 HardwareInterfacePackage hardwareInterfacePackage = (HardwareInterfacePackage)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(HrmViewsRepository.General.Properties.name))
			generalPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, hardwareInterfacePackage.getName()));
		
		if (isAccessible(HrmViewsRepository.General.Properties.ownedElement)) {
			ownedElementSettings = new ReferencesTableSettings(hardwareInterfacePackage, GrmPackage.eINSTANCE.getResourcePackage_OwnedElement());
			generalPart.initOwnedElement(ownedElementSettings);
		}
		// init filters
		
		if (isAccessible(HrmViewsRepository.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 47
Project: time4sys   File: HardwareActuatorPropertiesEditionComponent.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 48
Project: time4sys   File: HardwareTimingResourcePropertiesEditionComponent.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 49
Project: n4js   File: N4HeadlessCompiler.java   Source Code and License 5 votes vote down vote up
private void unloadResource(Resource resource, ResourceSet resourceSet, ResourceDescriptionsData index,
		N4ProgressStateRecorder recorder) {
	recorder.markUnloadingOf(resource);
	if (index != null)
		index.removeDescription(resource.getURI());
	resource.unload();
	resourceSet.getResources().remove(resource);
}
 
Example 50
Project: time4sys   File: MemoryPartitionTimingPropertiesEditionComponent.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 MemoryPartition memoryPartition = (MemoryPartition)elt;
		final TimingPropertiesEditionPart timingPart = (TimingPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(SrmViewsRepository.Timing.Properties.resCtrlPolicy)) {
			resCtrlPolicySettings = new ReferencesTableSettings(memoryPartition, GrmPackage.eINSTANCE.getResourceManager_ResCtrlPolicy());
			timingPart.initResCtrlPolicy(resCtrlPolicySettings);
		}
		// FIXME NO VALID CASE INTO template public updater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) in widgetControl.mtl module, with the values : concurrentResources, Timing, MemoryPartition.
		// 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
		}
		// FIXME NO VALID CASE INTO template public filterUpdater(editionElement : PropertiesEditionElement, view : View, pec : PropertiesEditionComponent) in widgetControl.mtl module, with the values : concurrentResources, Timing, MemoryPartition.
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 51
Project: OCCI-Studio   File: OCCIExtension2Ecore.java   Source Code and License 5 votes vote down vote up
private Resource createAndLoadOCCIEcoreResource(String pathToDDLEcore) {
	// creating a proper URI is vitally important since this is how
	// referenced objects in the is ecore file will be found from the ecore
	// file that we produce.
	ResourceSet resSet = new ResourceSetImpl();
	final URI uri = URI.createPlatformPluginURI(pathToDDLEcore, true);
	Resource res = resSet.createResource(uri);
	try {
		res.load(Collections.emptyMap());
	} catch (IOException e) {
		e.printStackTrace();
	}
	return res;
}
 
Example 52
Project: time4sys   File: UsageDemandPropertiesEditionComponent.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 UsageDemand usageDemand = (UsageDemand)elt;
		final GeneralPropertiesEditionPart generalPart = (GeneralPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(GrmViewsRepository.General.Properties.usage)) {
			usageSettings = new ReferencesTableSettings(usageDemand, GrmPackage.eINSTANCE.getUsageDemand_Usage());
			generalPart.initUsage(usageSettings);
		}
		if (isAccessible(GrmViewsRepository.General.Properties.event))
			generalPart.setEvent(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, usageDemand.getEvent()));
		
		// init filters
		if (isAccessible(GrmViewsRepository.General.Properties.usage)) {
			generalPart.addFilterToUsage(new EObjectFilter(GrmPackage.Literals.RESOURCE_USAGE));
			// Start of user code for additional businessfilters for usage
			// End of user code
		}
		
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}
 
Example 53
Project: time4sys   File: ResourcePortOtherPropertiesEditionComponent.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 ResourcePort resourcePort = (ResourcePort)elt;
		final OtherPropertiesEditionPart otherPart = (OtherPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(GrmViewsRepository.Other.OtherProperties.pInterface)) {
			pInterfaceSettings = new ReferencesTableSettings(resourcePort, GrmPackage.eINSTANCE.getResourcePort_PInterface());
			otherPart.initPInterface(pInterfaceSettings);
		}
		if (isAccessible(GrmViewsRepository.Other.OtherProperties.rInterface)) {
			rInterfaceSettings = new ReferencesTableSettings(resourcePort, GrmPackage.eINSTANCE.getResourcePort_RInterface());
			otherPart.initRInterface(rInterfaceSettings);
		}
		// init filters
		if (isAccessible(GrmViewsRepository.Other.OtherProperties.pInterface)) {
			otherPart.addFilterToPInterface(new EObjectFilter(GrmPackage.Literals.RESOURCE_INTERFACE));
			// Start of user code for additional businessfilters for pInterface
			// End of user code
		}
		if (isAccessible(GrmViewsRepository.Other.OtherProperties.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 54
Project: n4js   File: TypeVisibilityChecker.java   Source Code and License 5 votes vote down vote up
private boolean isPublicInternalVisible(Resource contextResource, URI elementLocation) {
	// for more detailed checks, we have to obtain the referenced type from the resource set
	ResourceSet resourceSet = contextResource.getResourceSet();

	EObject loadedType = resourceSet.getEObject(elementLocation, false);
	if (loadedType == null) {
		loadedType = resourceSet.getEObject(elementLocation, true);
	}
	if (loadedType instanceof Type) {
		// delegate to the *real* impl
		return isVisible(contextResource, TypeAccessModifier.PUBLIC_INTERNAL, (Type) loadedType).visibility;
	}
	return false;
}
 
Example 55
Project: time4sys   File: DeviceResourcePropertiesEditionComponent.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 56
Project: gemoc-studio-modeldebugging   File: DebugPermissionProvider.java   Source Code and License 5 votes vote down vote up
@Override
public IPermissionAuthority getAuthority(final ResourceSet set) {
	final DebugPermissionAuthority res;

	final DebugPermissionAuthority existing = (DebugPermissionAuthority) IExecutionCheckpoint.CHECKPOINTS
			.get(set);

	if (existing != null) {
		res = existing;
	} else {
		res = new DebugPermissionAuthority();
		IExecutionCheckpoint.CHECKPOINTS.put(set, res);
		if (set.getResources().size() > 0) {
			final Session session = SessionManager.INSTANCE.getSession(set
					.getResources().get(0));
			if (session != null) {
				session.addListener(new SessionListener() {
					@Override
					public void notify(int changeKind) {
						if (changeKind == SessionListener.CLOSED) {
							IExecutionCheckpoint.CHECKPOINTS.remove(set);
						}
					}
				});
			}
		}
	}

	return res;
}
 
Example 57
Project: time4sys   File: HardwareRamPropertiesEditionComponent.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 58
Project: neoscada   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 NOT
 */
@Override
public void registerPackages ( final ResourceSet resourceSet )
{
    super.registerPackages ( resourceSet );

    /*
     * TODO 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. 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. 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 (!isInWorkspace(UMLPackage.class)) {
     *     // The normal package registration if your metamodel is in a plugin.
     *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
     * } else {
     *     // The package registration that will be used if the metamodel is not deployed in a plugin.
     *     // This should be used if your metamodel is in your workspace and if you are using binary resource serialization.
     *     resourceSet.getPackageRegistry().put("/myproject/myfolder/mysubfolder/MyUMLMetamodel.ecore", UMLPackage.eINSTANCE);
     * }
     * 
     * To learn more about Package Registration, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
     */
    if ( !isInWorkspace ( ProtocolPackage.class ) )
    {
        resourceSet.getPackageRegistry ().put ( ProtocolPackage.eNS_URI, ProtocolPackage.eINSTANCE );
    }
    else
    {
        resourceSet.getPackageRegistry ().put ( "platform:/plugin/org.eclipse.scada.protocol.ngp.model/model/ngp.ecore", ProtocolPackage.eINSTANCE );
    }
}
 
Example 59
Project: n4js   File: JSDoc2SpecProcessor.java   Source Code and License 5 votes vote down vote up
/**
 * @throws InterruptedException
 *             thrown when user cancels the operation
 * @see N4JSDReader#readN4JSDs(Collection, Function, SubMonitorMsg)
 */
public Map<String, SpecInfo> readN4JSDs(Collection<IN4JSProject> projects,
		Function<IN4JSProject, ResourceSet> resSetProvider, SubMonitorMsg monitor) throws InterruptedException {

	SubMonitorMsg sub = monitor.convert(100 * (projects.size() + 2));
	n4jsdReader.issueAcceptor = this.issueAcceptor;
	return n4jsdReader.readN4JSDs(projects, resSetProvider, sub);
}
 
Example 60
Project: time4sys   File: DesignModelPropertiesEditionComponent.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)
 * @generated
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
	setInitializing(true);
	if (editingPart != null && key == partKey) {
		editingPart.setContext(elt, allResource);
		
		final DesignModel designModel = (DesignModel)elt;
		final DesignModelPropertiesEditionPart basePart = (DesignModelPropertiesEditionPart)editingPart;
		// init values
		if (isAccessible(DesignViewsRepository.DesignModel.Properties.name))
			basePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, designModel.getName()));
		
		if (isAccessible(DesignViewsRepository.DesignModel.Properties.endToEndFlows)) {
			endToEndFlowsSettings = new ReferencesTableSettings(designModel, DesignPackage.eINSTANCE.getDesignModel_EndToEndFlows());
			basePart.initEndToEndFlows(endToEndFlowsSettings);
		}
		// init filters
		
		if (isAccessible(DesignViewsRepository.DesignModel.Properties.endToEndFlows)) {
			basePart.addFilterToEndToEndFlows(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 EndToEndFlow); //$NON-NLS-1$ 
				}
		
			});
		}
		// init values for referenced views
		
		// init filters for referenced views
		
	}
	setInitializing(false);
}