Java Code Examples for org.eclipse.emf.ecore.util.EcoreUtil

The following examples show how to use org.eclipse.emf.ecore.util.EcoreUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
protected List<IEObjectDescription> computeExportedObjects() {
	if (!getResource().isLoaded()) {
		try {
			getResource().load(null);
		} catch (IOException e) {
			log.error(e.getMessage(), e);
			return Collections.<IEObjectDescription> emptyList();
		}
	}
	final List<IEObjectDescription> exportedEObjects = newArrayList();
	IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
		@Override
		public void accept(IEObjectDescription eObjectDescription) {
			exportedEObjects.add(eObjectDescription);
		}
	};
	TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(getResource(), false);
	while (allProperContents.hasNext()) {
		EObject content = allProperContents.next();
		if (!strategy.createEObjectDescriptions(content, acceptor))
			allProperContents.prune();
	}
	return exportedEObjects;
}
 
Example 2
Source Project: openhab1-addons   Source File: MDualRelayImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setMbrick(MDualRelayBricklet newMbrick) {
    if (newMbrick != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.MDUAL_RELAY__MBRICK && newMbrick != null)) {
        if (EcoreUtil.isAncestor(this, newMbrick))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newMbrick != null)
            msgs = ((InternalEObject) newMbrick).eInverseAdd(this, ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES,
                    MSubDeviceHolder.class, msgs);
        msgs = basicSetMbrick(newMbrick, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MDUAL_RELAY__MBRICK, newMbrick,
                newMbrick));
}
 
Example 3
Source Project: birt   Source File: DataSourceAdapter.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public boolean isDataSourceHandleAndDataSourceDesignEqual(
		OdaDataSourceHandle sourceHandle, DataSourceDesign sourceDesign )
{

	EqualityHelper equalityHelper = new EcoreUtil.EqualityHelper( );
	// compare public properties
	Properties sourceHandlePublicProperties = newOdaPublicProperties(
			sourceHandle.getExtensionPropertyDefinitionList( ),
			sourceHandle );
	if ( !equalityHelper.equals( sourceHandlePublicProperties,
			sourceDesign.getPublicProperties( ) ) )
	{
		return false;
	}

	// compare private properties
	Properties sourceHandlePrivateProperties = newOdaPrivateProperties(
			sourceHandle.privateDriverPropertiesIterator( ) );
	return equalityHelper.equals( sourceHandlePrivateProperties,
			sourceDesign.getPrivateProperties( ) );
}
 
Example 4
Source Project: ifml-editor   Source File: ConditionalExpressionImpl.java    License: MIT License 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setParentViewComponentPart(ViewComponentPart newParentViewComponentPart) {
	if (newParentViewComponentPart != eInternalContainer() || (eContainerFeatureID() != CorePackage.CONDITIONAL_EXPRESSION__PARENT_VIEW_COMPONENT_PART && newParentViewComponentPart != null)) {
		if (EcoreUtil.isAncestor(this, newParentViewComponentPart))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newParentViewComponentPart != null)
			msgs = ((InternalEObject)newParentViewComponentPart).eInverseAdd(this, CorePackage.VIEW_COMPONENT_PART__SUB_VIEW_COMPONENT_PARTS, ViewComponentPart.class, msgs);
		msgs = basicSetParentViewComponentPart(newParentViewComponentPart, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.CONDITIONAL_EXPRESSION__PARENT_VIEW_COMPONENT_PART, newParentViewComponentPart, newParentViewComponentPart));
}
 
Example 5
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setMbrick(MBrickletLaserRangeFinder newMbrick) {
    if (newMbrick != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.LASER_RANGE_FINDER_DISTANCE__MBRICK && newMbrick != null)) {
        if (EcoreUtil.isAncestor(this, newMbrick))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newMbrick != null)
            msgs = ((InternalEObject) newMbrick).eInverseAdd(this, ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES,
                    MSubDeviceHolder.class, msgs);
        msgs = basicSetMbrick(newMbrick, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.LASER_RANGE_FINDER_DISTANCE__MBRICK,
                newMbrick, newMbrick));
}
 
Example 6
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.MBRICKLET_INDUSTRIAL_DUAL020M_A__BRICKD
                    && newBrickd != null)) {
        if (EcoreUtil.isAncestor(this, newBrickd))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newBrickd != null)
            msgs = ((InternalEObject) newBrickd).eInverseAdd(this, ModelPackage.MBRICKD__MDEVICES, MBrickd.class,
                    msgs);
        msgs = basicSetBrickd(newBrickd, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_INDUSTRIAL_DUAL020M_A__BRICKD,
                newBrickd, newBrickd));
}
 
Example 7
Source Project: xtext-extras   Source File: JvmMemberImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setDeclaringType(JvmDeclaredType newDeclaringType)
{
	if (newDeclaringType != eInternalContainer() || (eContainerFeatureID() != TypesPackage.JVM_MEMBER__DECLARING_TYPE && newDeclaringType != null))
	{
		if (EcoreUtil.isAncestor(this, newDeclaringType))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newDeclaringType != null)
			msgs = ((InternalEObject)newDeclaringType).eInverseAdd(this, TypesPackage.JVM_DECLARED_TYPE__MEMBERS, JvmDeclaredType.class, msgs);
		msgs = basicSetDeclaringType(newDeclaringType, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, TypesPackage.JVM_MEMBER__DECLARING_TYPE, newDeclaringType, newDeclaringType));
}
 
Example 8
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setTable(PhysicalTable newTable) {
	if (newTable != eInternalContainer() || (eContainerFeatureID() != PhysicalModelPackage.PHYSICAL_COLUMN__TABLE && newTable != null)) {
		if (EcoreUtil.isAncestor(this, newTable))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newTable != null)
			msgs = ((InternalEObject) newTable).eInverseAdd(this, PhysicalModelPackage.PHYSICAL_TABLE__COLUMNS, PhysicalTable.class, msgs);
		msgs = basicSetTable(newTable, msgs);
		if (msgs != null)
			msgs.dispatch();
	} else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, PhysicalModelPackage.PHYSICAL_COLUMN__TABLE, newTable, newTable));
}
 
Example 9
Source Project: xtext-extras   Source File: JvmTypesBuilder.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a deep copy of the given object and associates each copied instance with the
 * clone. Does not resolve any proxies.
 *	
 * @param original the root element to be cloned.
 * @return a clone of tree rooted in original associated with the original, <code>null</code> if original is <code>null</code>. 
 */
protected <T extends EObject> T cloneAndAssociate(T original) {
	final boolean canAssociate = languageInfo.isLanguage(original.eResource());
	EcoreUtil.Copier copier = new EcoreUtil.Copier(false) {
		private static final long serialVersionUID = 1L;

		@Override/* @Nullable */ 
		protected EObject createCopy(/* @Nullable */ EObject eObject) {
			EObject result = super.createCopy(eObject);
			if (canAssociate && result != null && eObject != null && !eObject.eIsProxy()) {
				associator.associate(eObject, result);
			}
			return result;
		}
	};
	@SuppressWarnings("unchecked")
	T copy = (T) copier.copy(original);
	copier.copyReferences();
	return copy;
}
 
Example 10
@Test public void testPerformance() throws Exception {
		GenericResourceDescriptionManager manager = getEmfResourceDescriptionsManager();
		Collection<String> uris = ImmutableList.copyOf(EPackage.Registry.INSTANCE.keySet());
		for(String uri: uris) {
			EPackage pack = EPackage.Registry.INSTANCE.getEPackage(uri);
			IResourceDescription description = manager.getResourceDescription(pack.eResource());
			assertNotNull(description);
			for(int i = 0; i < 10; i++) {
				Iterator<EObject> iter = EcoreUtil.getAllProperContents(pack, true);
				while(iter.hasNext()) {
					EObject next = iter.next();
					if (next instanceof ENamedElement) {
						String name = ((ENamedElement) next).getName();
//						Iterable<IEObjectDescription> objects = 
						description.getExportedObjects(EcorePackage.Literals.EOBJECT, QualifiedName.create(name), false);
//						assertFalse(name + " - " + uri + " - " + next, Iterables.isEmpty(objects));
					}
				}
			}
		}
	}
 
Example 11
public AbstractDefinitionWizard(final String windowTitle, final ConnectorDefinition definition,
        final AbstractDefinitionRepositoryStore<? extends IRepositoryFileStore> defStore,
        final DefinitionResourceProvider messageProvider) {
    Assert.isTrue(defStore instanceof IDefinitionRepositoryStore);
    setWindowTitle(windowTitle);
    setDefaultPageImageDescriptor(Pics.getWizban());
    editMode = true;
    originalDefinition = definition;
    this.defStore = defStore;
    fileStore = defStore.getChild(
            NamingUtils.toConnectorDefinitionFilename(definition.getId(), definition.getVersion(), true), true);
    definitionWorkingCopy = EcoreUtil.copy(definition);
    this.messageProvider = messageProvider;
    messages = messageProvider.getDefaultMessageProperties(definition);
    setNeedsProgressMonitor(true);
}
 
Example 12
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setMbrick(MBrickletVoltageCurrent newMbrick) {
    if (newMbrick != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.VC_DEVICE_VOLTAGE__MBRICK && newMbrick != null)) {
        if (EcoreUtil.isAncestor(this, newMbrick))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newMbrick != null)
            msgs = ((InternalEObject) newMbrick).eInverseAdd(this, ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES,
                    MSubDeviceHolder.class, msgs);
        msgs = basicSetMbrick(newMbrick, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.VC_DEVICE_VOLTAGE__MBRICK, newMbrick,
                newMbrick));
}
 
Example 13
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
	super.updatePart(msg);
	if (editingPart.isVisible()) {
		GatewayPropertiesEditionPart basePart = (GatewayPropertiesEditionPart)editingPart;
		if (EipPackage.eINSTANCE.getEndpoint_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Gateway.Properties.name)) {
			if (msg.getNewValue() != null) {
				basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setName("");
			}
		}
		if (EipPackage.eINSTANCE.getEndpoint_ToChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Gateway.Properties.toChannels))
			basePart.updateToChannels();
		if (EipPackage.eINSTANCE.getEndpoint_FromChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Gateway.Properties.fromChannels))
			basePart.updateFromChannels();
		
	}
}
 
Example 14
Source Project: n4js   Source File: ComposedContentImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setOwner(Composite newOwner) {
	if (newOwner != eInternalContainer() || (eContainerFeatureID() != DomPackage.COMPOSED_CONTENT__OWNER && newOwner != null)) {
		if (EcoreUtil.isAncestor(this, newOwner))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newOwner != null)
			msgs = ((InternalEObject)newOwner).eInverseAdd(this, DomPackage.COMPOSITE__CONTENTS, Composite.class, msgs);
		msgs = basicSetOwner(newOwner, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, DomPackage.COMPOSED_CONTENT__OWNER, newOwner, newOwner));
}
 
Example 15
@Test public void testHasChanges_DifferentTypes() throws Exception {
	TestResDesc resourceDesc = new TestResDesc();
	resourceDesc.imported.add(FOO);
	resourceDesc.exported.add(EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
	
	TestResDesc resourceDesc2 = new TestResDesc();
	resourceDesc2.imported.add(FOO);
	resourceDesc2.exported.add(new EObjectDescription(BAR, EcorePackage.Literals.EANNOTATION__CONTENTS, Collections.singletonMap("foo", "bar")){
		@Override
		public URI getEObjectURI() {
			return EcoreUtil.getURI(EcorePackage.Literals.EANNOTATION);
		}
	}
	);
	
	assertTrue(new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2).haveEObjectDescriptionsChanged());
}
 
Example 16
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(Messages.creatingNewForm, IProgressMonitor.UNKNOWN);
    try {
        setArtifactName(getNewName());
        URL url = pageDesignerURLBuilder.newPageFromContract(formScope, artifactName);
        Pool parentPool = new ModelSearch(Collections::emptyList).getDirectParentOfType(contract, Pool.class);
        BusinessDataStore businessDataStore = new BusinessDataStore(parentPool, getRepositoryAccessor());
        ContractToBusinessDataResolver contractToBusinessDataResolver = new ContractToBusinessDataResolver(
                businessDataStore);
        Contract tmpContract = EcoreUtil.copy(contract); // will contains unwanted contractInput for readOnly attributes 
        openReadOnlyAttributeDialog(tmpContract, businessDataStore);
        TreeResult treeResult = contractToBusinessDataResolver.resolve(tmpContract, buildReadOnlyAttributes);
        Representation body = new JacksonRepresentation<>(new ToWebContract(treeResult).apply(tmpContract));
        responseObject = createArtifact(url, body);
    } catch (MalformedURLException e) {
        throw new InvocationTargetException(e, "Failed to create new form url.");
    }
}
 
Example 17
Source Project: xtext-xtend   Source File: LinePartImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setLine(Line newLine)
{
	if (newLine != eInternalContainer() || (eContainerFeatureID() != ProcessedRichStringPackage.LINE_PART__LINE && newLine != null))
	{
		if (EcoreUtil.isAncestor(this, newLine))
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
		NotificationChain msgs = null;
		if (eInternalContainer() != null)
			msgs = eBasicRemoveFromContainer(msgs);
		if (newLine != null)
			msgs = ((InternalEObject)newLine).eInverseAdd(this, ProcessedRichStringPackage.LINE__PARTS, Line.class, msgs);
		msgs = basicSetLine(newLine, msgs);
		if (msgs != null) msgs.dispatch();
	}
	else if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET, ProcessedRichStringPackage.LINE_PART__LINE, newLine, newLine));
}
 
Example 18
protected void recomputeAndCheckIdentifiers(Resource resource) {
	Iterator<JvmMember> iter = Iterators.filter(EcoreUtil.getAllContents(resource, false), JvmMember.class);
	while (iter.hasNext()) {
		JvmMember member = iter.next();
		String identifier = member.getIdentifier();
		member.internalSetIdentifier(null);
		String computed = member.getIdentifier();
		assertNotNull(String.valueOf(member), computed);
		assertEquals(identifier, computed);
		checkDeprecatedBitSet(member);
	}
	Iterator<JvmFormalParameter> params = Iterators.filter(EcoreUtil.getAllContents(resource, false),
			JvmFormalParameter.class);
	while (params.hasNext()) {
		JvmFormalParameter parameter = params.next();
		assertNotNull(parameter.eContainer().toString(), parameter.getName());
	}
}
 
Example 19
@Test
public void should_createExpressionFromEObject_Returns_a_ContractInputExpression_of_type_FileInputValue_if_EObject_is_a_FILE_ContractInput()
        throws Exception {
    final ContractInput input = ProcessFactory.eINSTANCE.createContractInput();
    input.setName("inputName");
    input.setType(ContractInputType.FILE);
    final Expression expression = ExpressionHelper.createExpressionFromEObject(input);
    assertThat(expression).hasContent(input.getName()).
            hasInterpreter("").
            hasType(ExpressionConstants.CONTRACT_INPUT_TYPE).
            hasName(input.getName()).
            hasReturnType(FileInputValue.class.getName());
    assertThat(expression.getReferencedElements()).hasSize(1);
    final EObject refElement = expression.getReferencedElements().get(0);
    assertThat(EcoreUtil.equals(input, refElement)).isTrue();
}
 
Example 20
Source Project: xtext-eclipse   Source File: SerializerTester.java    License: Eclipse Public License 2.0 6 votes vote down vote up
protected List<Pair<EObject, ICompositeNode>> detachNodeModel(EObject eObject) {
	EcoreUtil.resolveAll(eObject);
	List<Pair<EObject, ICompositeNode>> result = Lists.newArrayList();
	Iterator<Object> iterator = EcoreUtil.getAllContents(eObject.eResource(), false);
	while (iterator.hasNext()) {
		EObject object = (EObject) iterator.next();
		Iterator<Adapter> adapters = object.eAdapters().iterator();
		while (adapters.hasNext()) {
			Adapter adapter = adapters.next();
			if (adapter instanceof ICompositeNode) {
				adapters.remove();
				result.add(Tuples.create(object, (ICompositeNode) adapter));
				break;
			}
		}
	}
	return result;
}
 
Example 21
Source Project: openhab1-addons   Source File: MBrickletTiltImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setBrickd(MBrickd newBrickd) {
    if (newBrickd != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.MBRICKLET_TILT__BRICKD && newBrickd != null)) {
        if (EcoreUtil.isAncestor(this, newBrickd))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newBrickd != null)
            msgs = ((InternalEObject) newBrickd).eInverseAdd(this, ModelPackage.MBRICKD__MDEVICES, MBrickd.class,
                    msgs);
        msgs = basicSetBrickd(newBrickd, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.MBRICKLET_TILT__BRICKD, newBrickd,
                newBrickd));
}
 
Example 22
Source Project: neoscada   Source File: DaveDriverImpl.java    License: Eclipse Public License 1.0 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 23
Source Project: openhab1-addons   Source File: ColorColorImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setMbrick(MBrickletColor newMbrick) {
    if (newMbrick != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.COLOR_COLOR__MBRICK && newMbrick != null)) {
        if (EcoreUtil.isAncestor(this, newMbrick))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newMbrick != null)
            msgs = ((InternalEObject) newMbrick).eInverseAdd(this, ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES,
                    MSubDeviceHolder.class, msgs);
        msgs = basicSetMbrick(newMbrick, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.COLOR_COLOR__MBRICK, newMbrick,
                newMbrick));
}
 
Example 24
Source Project: openhab1-addons   Source File: RemoteSwitchCImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
@Override
public void setMbrick(MBrickletRemoteSwitch newMbrick) {
    if (newMbrick != eInternalContainer()
            || (eContainerFeatureID() != ModelPackage.REMOTE_SWITCH_C__MBRICK && newMbrick != null)) {
        if (EcoreUtil.isAncestor(this, newMbrick))
            throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
        NotificationChain msgs = null;
        if (eInternalContainer() != null)
            msgs = eBasicRemoveFromContainer(msgs);
        if (newMbrick != null)
            msgs = ((InternalEObject) newMbrick).eInverseAdd(this, ModelPackage.MSUB_DEVICE_HOLDER__MSUBDEVICES,
                    MSubDeviceHolder.class, msgs);
        msgs = basicSetMbrick(newMbrick, msgs);
        if (msgs != null)
            msgs.dispatch();
    } else if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.REMOTE_SWITCH_C__MBRICK, newMbrick,
                newMbrick));
}
 
Example 25
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
	super.updatePart(msg);
	if (editingPart.isVisible()) {
		RouterPropertiesEditionPart basePart = (RouterPropertiesEditionPart)editingPart;
		if (EipPackage.eINSTANCE.getEndpoint_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Router.Properties.name)) {
			if (msg.getNewValue() != null) {
				basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setName("");
			}
		}
		if (EipPackage.eINSTANCE.getEndpoint_ToChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Router.Properties.toChannels))
			basePart.updateToChannels();
		if (EipPackage.eINSTANCE.getEndpoint_FromChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Router.Properties.fromChannels))
			basePart.updateFromChannels();
		if (EipPackage.eINSTANCE.getRouter_OwnedRoutes().equals(msg.getFeature()) && isAccessible(EipViewsRepository.Router.Properties.ownedRoutes))
			basePart.updateOwnedRoutes();
		if (EipPackage.eINSTANCE.getRouter_Type().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && isAccessible(EipViewsRepository.Router.Properties.type))
			basePart.setType((RoutingType)msg.getNewValue());
		
		
	}
}
 
Example 26
Source Project: xtext-extras   Source File: TypeResource.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public EObject resolveJavaObjectURIProxy(InternalEObject proxy, EObject sender) {
	final URI proxyURI = proxy.eProxyURI();
       if (proxyURI != null && URIHelperConstants.PROTOCOL.equals(proxyURI.scheme())) {
           if ("Objects".equals(proxyURI.segment(0))) {
			if (indexedJvmTypeAccess != null) {
				try {
					EObject result = indexedJvmTypeAccess.getIndexedJvmType(proxy.eProxyURI(), getResourceSet());
					if (result != null) {
						return result;
					}
				} catch(UnknownNestedTypeException e) {
					return proxy;
				}
			}
			return EcoreUtil.resolve(proxy, sender);
           }
       }
       return null;
}
 
Example 27
protected List<? extends IRenameElementContext> createRenameElementContexts(Object element) {
	if (element instanceof IRenameElementContext) {
		IRenameElementContext triggeringContext = (IRenameElementContext) element;
		IProject project = projectUtil.getProject(triggeringContext.getTargetElementURI());
		if (project != null) {
			ResourceSet resourceSet = resourceSetProvider.get(project);
			EObject originalTarget = resourceSet.getEObject(triggeringContext.getTargetElementURI(), true);
			List<EObject> renamedElements = getRenamedElementsOrProxies(originalTarget);
			if (renamedElements == null || renamedElements.isEmpty())
				return null;
			List<IRenameElementContext> contexts = newArrayListWithCapacity(renamedElements.size());
			for (EObject renamedElement : renamedElements)
				contexts.add(new IRenameElementContext.Impl(EcoreUtil.getURI(renamedElement), renamedElement
						.eClass(), triggeringContext.getTriggeringEditor(), triggeringContext
						.getTriggeringEditorSelection(), triggeringContext.getContextResourceURI()));
			return contexts;
		}
	}
	return null;
}
 
Example 28
Source Project: ice   Source File: EMFTreeComposite.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This operation performs a deep copy of the attributes of another
 * EMFTreeComposite into the current EMFTreeComposite. It copies ALL of the
 * children of the EMFTreeComposite, data and child nodes alike.
 * 
 * @param otherTreeComposite
 */
public void copy(EMFTreeComposite otherTreeComposite) {

	// If null, return
	if (otherTreeComposite == null) {
		return;
	}

	if (otherTreeComposite.ecoreNodeMetaData != null) {
		ecoreNodeMetaData = otherTreeComposite.ecoreNodeMetaData;
		ecoreNode = EcoreUtil.create(ecoreNodeMetaData);
	}
	super.copy(otherTreeComposite, true);

	return;
}
 
Example 29
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated
 */
@Override
public void setModel(Model newModel) {
	if (newModel != eInternalContainer()
		|| eContainerFeatureID() != MigrationPackage.MODEL_RESOURCE__MODEL && newModel != null) {
		if (EcoreUtil.isAncestor(this, (EObject) newModel)) {
			throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
		}
		NotificationChain msgs = null;
		if (eInternalContainer() != null) {
			msgs = eBasicRemoveFromContainer(msgs);
		}
		if (newModel != null) {
			msgs = ((InternalEObject) newModel).eInverseAdd(this, MigrationPackage.MODEL__RESOURCES, Model.class,
				msgs);
		}
		msgs = basicSetModel(newModel, msgs);
		if (msgs != null) {
			msgs.dispatch();
		}
	}
	else if (eNotificationRequired()) {
		eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.MODEL_RESOURCE__MODEL, newModel,
			newModel));
	}
}
 
Example 30
public static List<URI> getURIs(EStructuralFeature.Setting setting) {
	Object it = setting.get(false);
	if (it instanceof EObject) {
		return ImmutableList.of(EcoreUtil.getURI(((EObject) it)));
	}
	if (it instanceof List) {
		List<URI> result = new ArrayList<>();
		for (Object o : ((List<?>) it)) {
			if (o instanceof EObject) {
				result.add(EcoreUtil.getURI((EObject) o));
			}
		}
		return result;
	}
	return null;
}