/** * Loads a new instance of an aspect. This is required, because lower-level aspects that contain * dependencies will be modified, i.e., it's dependencies are woven into it. If this (lower-level) * aspect is loaded somewhere else, e.g., a GUI, the modifications are reflected there, which is * unwanted behavior. If the aspect were cloned, it would require the mappings of the * instantiation for this lower-level aspect to be updated to the new elements, which would be * more time-consuming to do. Therefore, to circumvent this, the aspect is saved in a temporary * file and loaded again using a separate resource set, which forces to load other aspects to be * loaded as new instances. Otherwise the existing resource set would get the resources for the * lower-level aspects from its cache. * * @param aspect the aspect to load a new instance for * @return a new instance of the given aspect */ public Aspect loadNewInstance(Aspect aspect) { // Given aspect has to be cloned. Otherwise, when adding the aspect to the new resource // it gets removed from its current resource. This will mean that the given aspect // is directly modified. Aspect result = EcoreUtil.copy(aspect); String pathName = TEMPORARY_ASPECT.getAbsolutePath(); // Use our own resource set for saving and loading to workaround the issue. ResourceSet resourceSet = new ResourceSetImpl(); // Create a resource to temporarily save the aspect. Resource resource = resourceSet.createResource(URI.createFileURI(pathName)); resource.getContents().add(result); try { resource.save(Collections.EMPTY_MAP); // Load the temporary aspect ... resource = resourceSet.getResource(URI.createFileURI(pathName), true); result = (Aspect) resource.getContents().get(0); // Copy the aspect to loose the reference to the temporary file... result = EcoreUtil.copy(result); } catch (IOException e) { e.printStackTrace(); } // Delete the temporary file ... TEMPORARY_ASPECT.delete(); return result; }
/** * Gets the serializable string for design values. Design values include data set parameter * definitions and result set definitions. * * @param setDesign the data set desgin * @return the serializable string for design values */ private String serializeOdaValues(DataSetDesign setDesign) { DataSetParameters params = SchemaConversionUtil.convertToAdapterParameters(setDesign.getParameters()); ResultSets resultSets = setDesign.getResultSets(); DesignValues values = ModelFactory.eINSTANCE.createDesignValues(); values.setVersion(IConstants.DESINGER_VALUES_VERSION); boolean hasData = false; if (params != null) { values.setDataSetParameters((DataSetParameters) EcoreUtil.copy(params)); hasData = true; } if (resultSets != null) { values.setResultSets((ResultSets) EcoreUtil.copy(resultSets)); hasData = true; } if (!hasData) return IConstants.EMPTY_STRING; try { return SerializerImpl.instance().write(values); } catch (IOException e) { return null; } }
@Override public void setUp() throws Exception { super.setUp(); EcoreFactory factory = EcoreFactory.eINSTANCE; EPackage p = factory.createEPackage(); p.setName("TestPackage1"); EClass class0 = factory.createEClass(); class0.setName("Class0"); EClass class1 = factory.createEClass(); class1.setName("Class1"); EClass class2 = factory.createEClass(); class2.setName("Class2"); p.getEClassifiers().add(class0); p.getEClassifiers().add(class1); p.getEClassifiers().add(class2); leftModel = EcoreUtil.copy(p); URI leftURI = URI.createURI("leftmodel.ecore"); ModelUtils.attachResource(leftURI, leftModel); expectedModel = EcoreUtil.copy(leftModel); URI expectedURI = URI.createURI("expectedmodel.ecore"); ModelUtils.attachResource(expectedURI, expectedModel); p.getEClassifiers().remove(class1); rightModel = EcoreUtil.copy(p); URI rightURI = URI.createURI("rightmodel.ecore"); ModelUtils.attachResource(rightURI, rightModel); }
@Override public Object visit( NegativeOperatorExpression negativeOperatorExpression, TypeResolutionContext context, EolVisitorController<TypeResolutionContext, Object> controller) { controller.visit(negativeOperatorExpression.getExpr(), context); Expression expression = negativeOperatorExpression.getExpr(); // get the expression Type exprType = expression.getResolvedType(); if (exprType instanceof BooleanType) { // if expression is of type boolean context.getLogBook().addError(expression, "Expression cannot be Boolean"); } if (exprType instanceof StringType) { // if expression is of type string // handle string context.getLogBook().addError(expression, "Expression cannot be String"); } if (exprType instanceof RealType) { // if expression is of type real negativeOperatorExpression.setResolvedType(EcoreUtil.copy(exprType)); } if (exprType instanceof IntegerType) { negativeOperatorExpression.setResolvedType(EcoreUtil.copy(exprType)); } return null; }
protected void addConnectorImplementation( ConnectorImplementation impl, List<IResource> resourcesToExport, boolean includeSources) throws FileNotFoundException, CoreException { final IRepositoryStore store = getImplementationStore(); String fileName = NamingUtils.getEResourceFileName(impl, true); final EMFFileStore fileStore = (EMFFileStore) store.getChild(fileName); if (!fileStore.canBeShared()) { File f = new File(fileStore.getEMFResource().getURI().toFileString()); if (f.exists()) { IFile implFile = store.getResource().getFile(f.getName()); implFile.create(new FileInputStream(f), true, Repository.NULL_PROGRESS_MONITOR); resourcesToExport.add(implFile); cleanAfterExport.add(implFile); } } else { implBackup = EcoreUtil.copy(impl); String jarName = NamingUtils.toConnectorImplementationFilename( impl.getImplementationId(), impl.getImplementationVersion(), false) + ".jar"; if (!impl.getJarDependencies().getJarDependency().contains(jarName)) { impl.getJarDependencies().getJarDependency().add(jarName); } impl.setHasSources(includeSources); IRepositoryFileStore file = store.getChild(fileName); file.save(EcoreUtil.copy(impl)); resourcesToExport.add(file.getResource()); } }
private void copyContent(Scenario source, Scenario target) { target.setContent(EcoreUtil.copy(source.getContent())); target.setTeslaContent(EcoreUtil.copy(source.getTeslaContent())); target.getAttachments().clear(); target.getAttachments().addAll(EcoreUtil.copyAll(source.getAttachments())); target.getContexts().clear(); target.getContexts().addAll(source.getContexts()); target.getVerifications().clear(); target.getVerifications().addAll(source.getVerifications()); target.setDescription(source.getDescription()); }
/** * Bind an operation by copying the signature from the actual. * * @param copy the copier * @param actual the actual. If an operation, its signature is copied to the template * @param operation The operation template * @return */ public static Operation instantiateOperation( LazyCopier copy, Element actual, Operation operation) { try { Operation newOperation = copy.getCopy(operation); if (actual instanceof Operation) { for (Parameter parameter : ((Operation) actual).getOwnedParameters()) { Parameter newParam = EcoreUtil.copy(parameter); // copy parameter via EcoreUtil newParam.setType(copy.getCopy(parameter.getType())); newOperation.getOwnedParameters().add(newParam); } } TransformationContext.classifier = newOperation.getClass_(); if (actual instanceof Classifier) { bindOperation(newOperation, (Classifier) actual); } String newName = AcceleoDriverWrapper.evaluate(operation.getName(), actual, null); newOperation.setName(newName); return newOperation; } catch (TransformationException e) { // throw runtime exception throw new RuntimeException( String.format(Messages.TemplateInstantiationListener_TrafoException, e.getMessage())); } }
/** * @param eObject The {@link EObject} to create a view for * @param context a key-value-map from String to Object * @return a view model for the given eObject */ public VView createView(EObject eObject, Map<String, Object> context) { final Map<VView, Map<String, String>> viewMap = map.get(eObject.eClass()); if (context == null) { return viewMap.keySet().iterator().next(); } VView bestFitting = null; int maxNumberFittingKeyValues = -1; for (final VView view : viewMap.keySet()) { final Map<String, String> viewFilter = viewMap.get(view); int currentFittingKeyValues = 0; for (final String viewFilterKey : viewFilter.keySet()) { if (context.containsKey(viewFilterKey)) { final Object contextValue = context.get(viewFilterKey); final String viewFilterValue = viewFilter.get(viewFilterKey); if (contextValue.toString().equalsIgnoreCase(viewFilterValue)) { currentFittingKeyValues++; } else { currentFittingKeyValues = -1; break; } } else { currentFittingKeyValues = -1; break; } } if (currentFittingKeyValues > maxNumberFittingKeyValues) { maxNumberFittingKeyValues = currentFittingKeyValues; bestFitting = view; } } return EcoreUtil.copy(bestFitting); }
public static HexFile merge(HexFile... hexFiles) { List<Entry> entries = new LinkedList<Entry>(); for (HexFile hf : hexFiles) { hf = EcoreUtil.copy(hf); entries.addAll(hf.getEntries()); } HexFile output = HexfileFactory.eINSTANCE.createHexFile(); Collections.sort( entries, new Comparator<Entry>() { @Override public int compare(Entry o1, Entry o2) { Integer a1 = o1.getAddress(); Integer a2 = o2.getAddress(); return a1.compareTo(a2); } }); output.setAddressType(AddressType.EXTENDED_LINEAR); output.getEntries().addAll(entries); return output; }
protected DynamicValuesQuery updateDynamicValueQuery( DataSetHandle setHandle, Object valueColumn, Object labelColumn, DataSetDesign dataSetDesign, boolean isEnabled) { DynamicValuesQuery valueQuery = null; if (setHandle instanceof OdaDataSetHandle && valueColumn != null) { valueQuery = designFactory.createDynamicValuesQuery(); if (dataSetDesign != null) { DataSetDesign targetDataSetDesign = (DataSetDesign) EcoreUtil.copy(dataSetDesign); if (!setHandle.getName().equals(dataSetDesign.getName())) targetDataSetDesign = new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle); valueQuery.setDataSetDesign(targetDataSetDesign); } else { DataSetDesign targetDataSetDesign = new ModelOdaAdapter().createDataSetDesign((OdaDataSetHandle) setHandle); valueQuery.setDataSetDesign(targetDataSetDesign); } valueQuery.setDisplayNameColumn(AdapterUtil.extractColumnName(labelColumn)); valueQuery.setValueColumn(AdapterUtil.extractColumnName(valueColumn)); valueQuery.setEnabled(isEnabled); } return valueQuery; }
private void fromDSLtoXMI(URI inputModelURI, URI outputModelURI, ResourceSet resourceSet) { // set load options Map<Object, Object> loadOptionsMap = resourceSet.getLoadOptions(); // loadOptionsMap.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE); // loadOptionsMap.put(XMLResource.OPTION_RECORD_ANY_TYPE_NAMESPACE_DECLARATIONS, // Boolean.TRUE); loadOptionsMap.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); loadOptionsMap.put(XMIResource.OPTION_SUPPRESS_DOCUMENT_ROOT, Boolean.TRUE); // set save options Map<Object, Object> saveOptionsMap = new HashMap<Object, Object>(); saveOptionsMap.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); saveOptionsMap.put(XMIResource.OPTION_SUPPRESS_DOCUMENT_ROOT, Boolean.TRUE); // load input model from file Resource inputResource = resourceSet.getResource(inputModelURI, true); // create output model resource by copying contents of input model Resource outputResource = resourceSet.createResource(outputModelURI); outputResource.getContents().add(EcoreUtil.copy(inputResource.getContents().get(0))); // save output model to file try { outputResource.save(saveOptionsMap); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * Performs the step of a single weave. The lower-level aspect from the instantiation is woven * into the given aspect. * * @param base the higher-level aspect the lower-level aspect is woven into * @param instantiation the lower-level aspect to weave into the base aspect */ public void doWeaveSingle(Aspect base, Instantiation instantiation) { System.out.println( "Weaving " + instantiation.getSource().getName() + " into " + base.getName()); StructuralViewWeaver structuralViewWeaver = StructuralViewWeaver.getInstance(); for (COREModelReuse modelReuse : instantiation.getSource().getModelReuses()) { COREModelReuse copy = EcoreUtil.copy(modelReuse); base.getModelReuses().add(copy); } // CHECKSTYLE:IGNORE ParameterAssignment FOR 2 LINES: Needed, because the operation returns the // result, // however it returns base. base = structuralViewWeaver.weave(base, instantiation); WeavingInformation currentWeavingInformation = structuralViewWeaver.getWeavingInformation(); // Update the model reuses. ReferenceUpdater.getInstance().update(base.getModelReuses(), currentWeavingInformation); createTrace(base, instantiation.getSource(), currentWeavingInformation); // Merge weaving information, to be able to look at woven elements later. this.weavingInformation.merge(currentWeavingInformation); messageViewWeaver.copyMessageViews(base, instantiation.getSource(), currentWeavingInformation); StateViewWeaverUtils.copyStateViews(base, instantiation.getSource(), currentWeavingInformation); base.getInstantiations().remove(instantiation); }
private List<EObject> getSelfContainedModelElementTree(ExecutionEvent event) { List<EObject> result = new ArrayList<EObject>(); ISelection selection = HandlerUtil.getCurrentSelection(event); IStructuredSelection strucSel = null; EObject copyModelElement = null; if (selection != null && selection instanceof IStructuredSelection) { strucSel = (IStructuredSelection) selection; Object firstElement = strucSel.getFirstElement(); if (firstElement instanceof EObject) { // TODO: ChainSaw - check whether specific clone functionality of ModelUtil is needed here copyModelElement = EcoreUtil.copy((EObject) firstElement); // copyModelElement = ModelUtil.clone((EObject) firstElement); // only export the rootnode makes xml with references, otherwise (see (commented) line two) // the children // will be "real" nested as containments of the node (is not necessary) result.add(copyModelElement); // result.addAll(copyModelElement.getAllContainedModelElements()); } else { // do nothing System.out.println("NOT A MODELELEMENT"); } } return result; }
private void addResultToList( org.emftext.sdk.concretesyntax.resource.cs.ICsReferenceMapping<ReferenceType> mapping, org.eclipse.emf.ecore.EObject proxy, org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> list) { org.eclipse.emf.ecore.EObject target = null; int proxyPosition = list.indexOf(proxy); if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<?>) { target = ((org.emftext.sdk.concretesyntax.resource.cs.ICsElementMapping<ReferenceType>) mapping) .getTargetElement(); } else if (mapping instanceof org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<?>) { target = org.eclipse.emf.ecore.util.EcoreUtil.copy(proxy); org.eclipse.emf.common.util.URI uri = ((org.emftext.sdk.concretesyntax.resource.cs.ICsURIMapping<ReferenceType>) mapping) .getTargetIdentifier(); ((org.eclipse.emf.ecore.InternalEObject) target).eSetProxyURI(uri); } else { assert false; } try { // if target is an another proxy and list is "unique" add() will try to resolve // the new proxy to check for uniqueness. There seems to be no way to avoid that. // Until now this does not cause any problems. if (proxyPosition + 1 == list.size()) { list.add(target); } else { list.add(proxyPosition + 1, target); } } catch (Exception e1) { e1.printStackTrace(); } }
private EObject copyEObject(final EObject eObject) { // return ModelerCore.getModelEditor().copy(sourceRoot); // For some reason the ModelEditor.copy operation is not producing // a deep copy of some root entities so use EcoreUtil.copy. We can // use EcoreUtil.copy since the command result is not undoable. return EcoreUtil.copy(eObject); }
public static boolean processAddition( final MTrimBar trimBar, MTrimContribution contribution, List<MTrimElement> contributions, HashSet<String> existingToolbarIds) { int idx = getIndex(trimBar, contribution.getPositionInParent()); if (idx == -1) { return false; } for (MTrimElement item : contribution.getChildren()) { if (item instanceof MToolBar && existingToolbarIds.contains(item.getElementId())) { // skip this, it's already there continue; } MTrimElement copy = (MTrimElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addTrimContribution " + copy, trimBar.getWidget(), trimBar); // $NON-NLS-1$ } trimBar.getChildren().add(idx++, copy); contributions.add(copy); if (copy instanceof MToolBar && copy.getElementId() != null) { existingToolbarIds.add(copy.getElementId()); } } return true; }
/** {@inheritDoc} */ @Override public void paste(IPasteContext context) { // already verified, that pasting is allowed just directly in the diagram PictogramElement[] pes = context.getPictogramElements(); Diagram diagram = (Diagram) pes[0]; // get the PictogramElements from the clipboard and the linked business object. Object[] objects = getFromClipboard(); for (Object object : objects) { PictogramElement pictogramElement = (PictogramElement) object; rootCon boRef = (rootCon) getBusinessObjectForPictogramElement(pictogramElement); rootCon bo = EcoreUtil.copy(boRef); addBusinessObjectToContainer(bo, pictogramElement); // create a new AddContext for the creation of a new shape. AddContext ac = new AddContext(new AddContext(), bo); ac.setLocation(0, 0); // for simplicity paste at (0, 0) ac.setTargetContainer(diagram); // paste on diagram // copy all properties from the shape (e.g. ALIAS etc.) for (Property prop : pictogramElement.getProperties()) { ac.putProperty(prop.getKey(), prop.getValue()); } getFeatureProvider().addIfPossible(ac); } }
@Override public MUIElement cloneElement(MUIElement element, MSnippetContainer snippetContainer) { EObject eObj = (EObject) element; MUIElement clone = (MUIElement) EcoreUtil.copy(eObj); // null out all the references List<MPlaceholder> phList = findElements(clone, null, MPlaceholder.class, null); for (MPlaceholder ph : phList) { // Skip placeholders in the sharedArea int location = getElementLocation(ph); if ((location & IN_SHARED_AREA) != 0) { continue; } ph.setRef(null); } if (snippetContainer != null) { MUIElement snippet = findSnippet(snippetContainer, element.getElementId()); if (snippet != null) { snippetContainer.getSnippets().remove(snippet); } snippetContainer.getSnippets().add(clone); } // Cache the original element in the clone's transientData clone.getTransientData().put(CLONED_FROM_KEY, element); return clone; }
public static boolean processAddition( final MMenu menuModel, final ArrayList<MMenuElement> menuContributionsToRemove, MMenuContribution menuContribution, final HashSet<String> existingMenuIds, HashSet<String> existingSeparatorNames) { int idx = getIndex(menuModel, menuContribution.getPositionInParent()); if (idx == -1) { return false; } for (MMenuElement item : menuContribution.getChildren()) { if (item instanceof MMenu && existingMenuIds.contains(item.getElementId())) { // skip this, it's already there continue; } else if (item instanceof MMenuSeparator && existingSeparatorNames.contains(item.getElementId())) { // skip this, it's already there continue; } MMenuElement copy = (MMenuElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addMenuContribution " + copy, menuModel.getWidget(), menuModel); // $NON-NLS-1$ } menuContributionsToRemove.add(copy); menuModel.getChildren().add(idx++, copy); if (copy instanceof MMenu && copy.getElementId() != null) { existingMenuIds.add(copy.getElementId()); } else if (copy instanceof MMenuSeparator && copy.getElementId() != null) { existingSeparatorNames.add(copy.getElementId()); } } return true; }
@Override public MUIElement cloneSnippet( MSnippetContainer snippetContainer, String snippetId, MWindow refWin) { if (snippetContainer == null || snippetId == null || snippetId.length() == 0) { return null; } MApplicationElement elementToClone = null; for (MApplicationElement snippet : snippetContainer.getSnippets()) { if (snippetId.equals(snippet.getElementId())) { elementToClone = snippet; break; } } if (elementToClone == null) { return null; } EObject eObj = (EObject) elementToClone; MUIElement element = (MUIElement) EcoreUtil.copy(eObj); MUIElement appElement = refWin == null ? null : refWin.getParent(); if (appElement instanceof MApplication) { handleNullRefPlaceHolders(element, refWin, true); } return element; }
/** * Adjust the returned label so that it matches the exact value at the requested cycle instead of * the value at x. We do this by using the difference between x and the current cycle to adjust * the label. nextValueAtX is modified by this function * * @param currentValue The current value * @param nextValueAtX The next value at position x * @param x Current position * @param cycle Current cycle */ void adjustValuesToCycle( IntegrationLabelValue currentValue, IntegrationLabelValue nextValueAtX, double x, int cycle) { IntegrationLabelValue result = (IntegrationLabelValue) EcoreUtil.copy(currentValue); nextValueAtX.sub(currentValue); // difference between new value and old now in nextValueAtX nextValueAtX.scale(1.0 / (x - cycle + 1)); nextValueAtX.set(result.add(nextValueAtX)); }
@Before public void setUp() throws Exception { if (pool == null) { final NewDiagramCommandHandler newDiagram = new NewDiagramCommandHandler(); final DiagramFileStore diagramFileStore = newDiagram.execute(null); pool = (AbstractProcess) EcoreUtil.copy(diagramFileStore.getContent()).getElements().get(0); final Configuration conf = ConfigurationFactory.eINSTANCE.createConfiguration(); conf.setName(CONF_NAME); pool.getConfigurations().add(conf); final Parameter p1 = ParameterFactory.eINSTANCE.createParameter(); p1.setName("dbUrl"); p1.setTypeClassname(String.class.getName()); pool.getParameters().add(p1); final Parameter p2 = ParameterFactory.eINSTANCE.createParameter(); p2.setName("password"); p2.setTypeClassname(String.class.getName()); pool.getParameters().add(p2); final Parameter p3 = ParameterFactory.eINSTANCE.createParameter(); p3.setName("port"); p3.setTypeClassname(Integer.class.getName()); pool.getParameters().add(p3); pool.getFormMapping().setType(FormMappingType.LEGACY); for (final Task t : ModelHelper.getAllElementOfTypeIn(pool, Task.class)) { t.getFormMapping().setType(FormMappingType.LEGACY); } new ConfigurationSynchronizer(pool, pool.getConfigurations().get(0)).synchronize(); } }
@Override protected List<DiffElement> detectDifferences(EObject left, EObject right) throws InterruptedException { Map<String, Object> options = Collections.emptyMap(); // We need here to detect and merge "local" changes. We'll use the "right" as ancestor Resource rightRes = right.eResource(); Resource ancestorRes = null; if (rightRes != null) { try { ancestorRes = rightRes.getClass().newInstance(); ancestorRes.setURI(rightRes.getURI()); } catch (InstantiationException e) { fail("Couldn't copy '" + rightRes.getURI() + "' resource"); } catch (IllegalAccessException e) { fail("Couldn't copy '" + rightRes.getURI() + "' resource"); } } EObject ancestor = EcoreUtil.copy(right); if (ancestorRes != null) { ancestorRes.getContents().add(ancestor); } MatchModel match = MatchService.doMatch(left, right, ancestor, options); DiffModel diff = DiffService.doDiff(match, true); EList<DiffElement> differences = diff.getDifferences(); return differences; }
private void createSetter(Property property, Field field) { ClassMethod setterMethod = MembersFactory.eINSTANCE.createClassMethod(); setterMethod.setName("set" + PropjavaStringUtil.capitalize(property.getName())); setterMethod.setTypeReference(TypesFactory.eINSTANCE.createVoid()); OrdinaryParameter parameter = ParametersFactory.eINSTANCE.createOrdinaryParameter(); parameter.setName("newValue"); TypeReference typeReference = field.getTypeReference(); TypeReference tReferenceCopy = (TypeReference) EcoreUtil.copy(typeReference); parameter.setTypeReference(tReferenceCopy); setterMethod.getParameters().add(parameter); AssignmentExpression assignment = ExpressionsFactory.eINSTANCE.createAssignmentExpression(); assignment.setAssignmentOperator(OperatorsFactory.eINSTANCE.createAssignment()); IdentifierReference parameterRef = ReferencesFactory.eINSTANCE.createIdentifierReference(); parameterRef.setTarget(parameter); assignment.setValue(parameterRef); IdentifierReference fieldRef = ReferencesFactory.eINSTANCE.createIdentifierReference(); fieldRef.setTarget(field); assignment.setChild(fieldRef); ExpressionStatement assignmentStatement = StatementsFactory.eINSTANCE.createExpressionStatement(); assignmentStatement.setExpression(assignment); setterMethod.getStatements().add(assignmentStatement); ((MemberContainer) property.eContainer()).getMembers().add(setterMethod); }
public Node retrieve(String host, String port) { INodeConnectionProvider ncp = injector.getInstance(INodeConnectionProvider.class); INodeConnection connection = ncp.createConnection(host, port); INodeAdapter nodeAdapter = connection.getAdapter(INodeAdapter.class); Node result = nodeAdapter.pullNode(); connection.close(); return EcoreUtil.copy(result); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public void switchToNextValue(STEMTime currentTime) { for (final Iterator<DynamicLabel> graphLabelIter = getDynamicLabels().iterator(); graphLabelIter.hasNext(); ) { final DynamicLabel dynamicLabel = graphLabelIter.next(); dynamicLabel.switchToNextValue(); } // for dynamic labels setTime((STEMTime) EcoreUtil.copy(currentTime)); } // switchToNextValue
@Override public void textChange(TextChangeEvent event) { setDirty(true); if (event.getComponent() != translated || currentItem == null) return; de.jutzig.jabylon.properties.Property copy = EcoreUtil.copy(currentItem.getTargetProperty()); copy.setValue(event.getText()); applyValidation(copy); }
/** * Only work with xmlmap. * * @param element * @return */ public static Object getObjectValueXMLTree(final IElement element) { if (element instanceof INode) { INode node = (INode) element; if (node.getExternalNode() != null) { return EcoreUtil.copy(node.getExternalNode().getExternalEmfData()); } } return null; }
/** * @param feature * @param target */ private void storeSingleValue(EAttribute feature, Object target) { // store current value if (feature.isChangeable()) { if (target instanceof EObject) { currentValue = EcoreUtil.copy((EObject) target); } } else { currentValue = target; } }
@Override public OperationDefinition handle( FeatureCallExpression featureCallExpression, Type contextType, ArrayList<Type> argTypes) throws AnalysisInterruptException { // get the manager StandardLibraryOperationDefinitionContainer manager = OperationDefinitionManager.getInstance().getStandardLibraryOperationDefinitionContainer(); // get the result OperationDefinition result = manager.getOperation( ((MethodCallExpression) featureCallExpression).getMethod().getName(), argTypes); if (result != null) { OperationDefinitionManager.getInstance().registerHandledOperationDefinition(result); Expression target = featureCallExpression.getTarget(); if (target == null) { LogBook.getInstance() .addError(featureCallExpression, IMessage_TypeResolution.OPERATION_REQUIRES_TARGET); SetType returnType = EolFactory.eINSTANCE.createSetType(); AnyType contentType = EolFactory.eINSTANCE.createAnyType(); returnType.setContentType(contentType); result.setReturnType(returnType); return result; } AnyType targetType = (AnyType) EcoreUtil.copy(target.getResolvedType()); if (targetType == null) { LogBook.getInstance() .addError(target, IMessage_TypeResolution.EXPRESSION_DOES_NOT_HAVE_A_TYPE); SetType returnType = EolFactory.eINSTANCE.createSetType(); AnyType contentType = EolFactory.eINSTANCE.createAnyType(); returnType.setContentType(contentType); result.setReturnType(returnType); return result; } SetType returnType = EolFactory.eINSTANCE.createSetType(); AnyType contentType = EolFactory.eINSTANCE.createAnyType(); if (TypeUtil.getInstance().isInstanceofAnyType(targetType)) { contentType.getDynamicTypes().addAll(targetType.getDynamicTypes()); } else { contentType.getDynamicTypes().add(targetType); } returnType.setContentType(contentType); result.setReturnType(returnType); return result; } return result; }