@Check public void checkUniqueResultColumnAliases(SelectList list) { EList<ColumnSource> cols = list.getResultColumns(); for (int i = 0; i < cols.size(); i++) { ColumnSource subject = cols.get(i); int matches = 0; for (int j = 0; j < cols.size(); j++) { ColumnSource target = cols.get(j); if (subject.getName() != null && target.getName() != null && subject.getName().equalsIgnoreCase(target.getName())) { matches++; } if (matches > 1) { error( "Duplicate alias not allowed", target, SqliteModelPackage.Literals.COLUMN_SOURCE__NAME, -1); return; } } } }
public TextRegion getImportRegion(XtextResource xtextResource) { XPackage xPackage = getXPackage(xtextResource); if (xPackage != null) { List<INode> xPackageNodes = NodeModelUtils.findNodesForFeature(xPackage, XcorePackage.Literals.XNAMED_ELEMENT__NAME); int begin; int size = xPackageNodes.size(); if (size == 0) { begin = 0; } else { INode lastNode = xPackageNodes.get(size - 1); begin = lastNode.getOffset() + lastNode.getLength(); } int end; EList<XAnnotationDirective> annotationDirectives = xPackage.getAnnotationDirectives(); if (!annotationDirectives.isEmpty()) { ICompositeNode node = NodeModelUtils.getNode(annotationDirectives.get(0)); end = node.getTotalOffset(); } else { EList<XClassifier> classifiers = xPackage.getClassifiers(); if (!classifiers.isEmpty()) { ICompositeNode node = NodeModelUtils.getNode(classifiers.get(0)); end = node.getTotalOffset(); } else { end = xtextResource.getParseResult().getRootNode().getTotalEndOffset(); } } return new TextRegion(begin, end - begin); } else { return null; } }
@Test(timeout = 1000) public void checkParserResult() throws Exception { final String text = this.getTextFromFile("res/Test0002_SimpleDefine.cmd"); final Model Model_0_Var = this.parseHelper.parse(text); this.valHelper.assertNoErrors(Model_0_Var); Assert.assertNotNull(Model_0_Var); final EList<? extends EObject> Lines_0_list = Model_0_Var.getLines(); Assert.assertNotNull(Lines_0_list); Assert.assertEquals(1, Lines_0_list.size()); // 0 final CmdLine CmdLine_1_Var = (CmdLine) Lines_0_list.get(0); Assert.assertNotNull(CmdLine_1_Var); Assert.assertEquals("foobar.o", CmdLine_1_Var.getStart()); final EList<? extends EObject> Arguments_1_list = CmdLine_1_Var.getArguments(); Assert.assertNotNull(Arguments_1_list); Assert.assertEquals(1, Arguments_1_list.size()); // 1 final Argument Argument_2_Var = (Argument) Arguments_1_list.get(0); Assert.assertNotNull(Argument_2_Var); // 2 final SimpleMacro SimpleMacro_3_Var = (SimpleMacro) Argument_2_Var.getMacro(); Assert.assertNotNull(SimpleMacro_3_Var); Assert.assertEquals("__FOO__BAR__", SimpleMacro_3_Var.getName()); }
@Test(timeout = 1000) public void checkParserResult() throws Exception { final String text = this.getTextFromFile("res/Test0030_ObjectLikeMacro.c"); final Preprocess Preprocess_0_Var = this.parseHelper.parse(text); this.valHelper.assertNoErrors(Preprocess_0_Var); Assert.assertNotNull(Preprocess_0_Var); // 0 final GroupOpt GroupOpt_1_Var = (GroupOpt) Preprocess_0_Var.getGroup(); Assert.assertNotNull(GroupOpt_1_Var); final EList<? extends EObject> Lines_1_list = GroupOpt_1_Var.getLines(); Assert.assertNotNull(Lines_1_list); Assert.assertEquals(3, Lines_1_list.size()); // 1 final Code Code_2_Var = (Code) Lines_1_list.get(0); Assert.assertNotNull(Code_2_Var); Assert.assertEquals("int foo1 = BAR;", Code_2_Var.getCode()); // 2 final PreprocessorDirectives PreprocessorDirectives_3_Var = (PreprocessorDirectives) Lines_1_list.get(1); Assert.assertNotNull(PreprocessorDirectives_3_Var); // 3 final DefineObjectMacro DefineObjectMacro_4_Var = (DefineObjectMacro) PreprocessorDirectives_3_Var.getDirective(); Assert.assertNotNull(DefineObjectMacro_4_Var); Assert.assertEquals("BAR", DefineObjectMacro_4_Var.getIdent()); Assert.assertEquals("0", DefineObjectMacro_4_Var.getString()); // 4 final Code Code_5_Var = (Code) Lines_1_list.get(2); Assert.assertNotNull(Code_5_Var); Assert.assertEquals("int foo2 = BAR;", Code_5_Var.getCode()); }
@Check public void checkUseArguments(final SpeciesReference reference) { EList<Feature> _arguments = reference.getArguments(); final int argSize = _arguments.size(); Species _species = reference.getSpecies(); EList<Feature> _parameters = _species.getParameters(); final int paramSize = _parameters.size(); if ((argSize == paramSize)) { int i = 0; final ComponentPart part = reference.getPart(); while ((i < argSize)) { { Species _species_1 = reference.getSpecies(); EList<Feature> _parameters_1 = _species_1.getParameters(); Feature _get = _parameters_1.get(i); final LightweightTypeReference typeFrom = this._speADLUtils.resolveType(_get, part); EList<Feature> _arguments_1 = reference.getArguments(); Feature _get_1 = _arguments_1.get(i); final LightweightTypeReference typeTo = this._speADLUtils.getTypeRef(_get_1); boolean _isAssignableFrom = typeFrom.isAssignableFrom(typeTo); boolean _not = (!_isAssignableFrom); if (_not) { this.error( ((("Incompatible types: " + typeFrom) + " is not the same or a supertype of ") + typeTo), SpeadlPackage.Literals.SPECIES_REFERENCE__ARGUMENTS, i); } i = (i + 1); } } } }
public static boolean setStringDataFilter(Analysis analysis, String datafilterString) { EList<Domain> dataFilters = analysis.getParameters().getDataFilter(); // update existing filters if (!dataFilters.isEmpty()) { Domain domain = dataFilters.get(0); EList<RangeRestriction> ranges = domain.getRanges(); RangeRestriction rangeRestriction = (ranges.isEmpty()) ? DomainHelper.addRangeRestriction(domain) : ranges.get(0); BooleanExpressionNode expressions = rangeRestriction.getExpressions(); if (expressions == null) { expressions = BooleanExpressionHelper.createBooleanExpressionNode(datafilterString); rangeRestriction.setExpressions(expressions); } else { Expression expression = expressions.getExpression(); if (expression == null) { expression = BooleanExpressionHelper.createTdExpression( BooleanExpressionHelper.DEFAULT_LANGUAGE, datafilterString); expressions.setExpression(expression); } else { expression.setBody(datafilterString); } } return false; } // else return dataFilters.add(createDomain(analysis, datafilterString)); }
private void initTreeNavigatorNodes() { List<String> selectedNames = new ArrayList<String>(); EList<SalesforceModuleUnit> modules = temConnection.getModules(); // EList<SalesforceModuleUnit> modules = getConnection().getModules(); for (int i = 0; i < modules.size(); i++) { if (modules.get(i).getModuleName().equals(moduleName)) { for (int j = 0; j < modules.get(i).getTables().size(); j++) { selectedNames.add(modules.get(i).getTables().get(j).getLabel()); } break; } } tableNavigator.removeAll(); TableItem subItem = null; String lastSelectName = null; if (selectedNames != null && selectedNames.size() >= 1) { for (int i = 0; i < selectedNames.size(); i++) { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(selectedNames.get(i)); lastSelectName = selectedNames.get(i); } metadataNameText.setText(subItem.getText()); tableNavigator.setSelection(subItem); metadataTable = getTableByLabel(lastSelectName); } else { subItem = new TableItem(tableNavigator, SWT.NULL); subItem.setText(moduleName); } metadataEditor.setMetadataTable(metadataTable); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case BusinessLogicPackage.RESERVATIONS___UPDATE_RESERVATION_DETAILS__RESERVATION: updateReservationDetails((Reservation) arguments.get(0)); return null; case BusinessLogicPackage.RESERVATIONS___MAKE__ELIST_PAYMENTDETAILS_BOOLEAN_STRING_BOOLEAN: return make( (EList<RoomBooking>) arguments.get(0), (PaymentDetails) arguments.get(1), (Boolean) arguments.get(2), (String) arguments.get(3), (Boolean) arguments.get(4)); case BusinessLogicPackage.RESERVATIONS___CANCEL__RESERVATION: cancel((Reservation) arguments.get(0)); return null; case BusinessLogicPackage.RESERVATIONS___GET_RESERVATION__INT: return getReservation((Integer) arguments.get(0)); case BusinessLogicPackage.RESERVATIONS___CHECK_IN_ALL_GUESTS__RESERVATION: CheckInAllGuests((Reservation) arguments.get(0)); return null; case BusinessLogicPackage.RESERVATIONS___CHECK_OUT_ALL_GUESTS__RESERVATION: CheckOutAllGuests((Reservation) arguments.get(0)); return null; } return super.eInvoke(operationID, arguments); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case Sequence_diagramPackage.MESSAGE___IS_DISTINGUISHABLE_FROM__NAMEDELEMENT_NAMESPACE: return isDistinguishableFrom((NamedElement) arguments.get(0), (Namespace) arguments.get(1)); } return super.eInvoke(operationID, arguments); }
public void testRemoveEqualValues() { E e = refFactory.createE(); String s0 = "0"; String s1 = "1"; String s2 = "2"; String s3 = new String(s1); EList<String> labels = e.getLabels(); labels.add(s0); labels.add(s1); labels.add(s3); labels.add(s2); labels.add(s1); Collection<String> collection = new ArrayList<String>(); collection.add(s1); collection.add(s1); collection.add(s1); Command remove = RemoveCommand.create(editingDomain, e, refPackage.getE_Labels(), collection); assertEquals(5, labels.size()); assertSame(s0, labels.get(0)); assertSame(s1, labels.get(1)); assertSame(s3, labels.get(2)); assertSame(s2, labels.get(3)); assertSame(s1, labels.get(4)); assertNotSame(s1, labels.get(2)); assertTrue(remove.canExecute()); CommandStack stack = editingDomain.getCommandStack(); stack.execute(remove); assertEquals(2, labels.size()); assertSame(s0, labels.get(0)); assertSame(s2, labels.get(1)); assertTrue(stack.canUndo()); stack.undo(); assertEquals(5, labels.size()); assertSame(s0, labels.get(0)); assertSame(s1, labels.get(1)); assertSame(s3, labels.get(2)); assertSame(s2, labels.get(3)); assertSame(s1, labels.get(4)); assertNotSame(s1, labels.get(2)); assertTrue(stack.canRedo()); stack.redo(); assertEquals(2, labels.size()); assertSame(s0, labels.get(0)); assertSame(s2, labels.get(1)); assertTrue(stack.canUndo()); }
@Test public void testDuplicateDiagramModel_AddsConnectionsToConnections() { ArchimateTestModel tm = new ArchimateTestModel(); IArchimateModel model = tm.createNewModel(); IDiagramModel dm = model.getDefaultDiagramModel(); IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor(); IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(element1); dm.getChildren().add(dmo1); IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole(); IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(element2); dm.getChildren().add(dmo2); IArchimateElement element3 = IArchimateFactory.eINSTANCE.createBusinessActor(); IDiagramModelArchimateObject dmo3 = tm.createDiagramModelArchimateObjectAndAddToModel(element3); dm.getChildren().add(dmo3); IArchimateRelationship relation1 = IArchimateFactory.eINSTANCE.createAssignmentRelationship(); relation1.setSource(element1); relation1.setTarget(element2); IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation1); dmc1.connect(dmo1, dmo2); IArchimateRelationship relation2 = IArchimateFactory.eINSTANCE.createAssociationRelationship(); relation2.setSource(element3); relation2.setTarget(relation1); IDiagramModelArchimateConnection dmc2 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation2); dmc2.connect(dmo3, dmc1); DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] {dm}); handler.duplicate(); IDiagramModel dmCopy = model.getDiagramModels().get(1); EList<IDiagramModelObject> children = dmCopy.getChildren(); assertEquals(3, children.size()); IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0); IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1); IDiagramModelArchimateObject dmo3Copy = (IDiagramModelArchimateObject) children.get(2); assertSame(element1, dmo1Copy.getArchimateConcept()); assertSame(element2, dmo2Copy.getArchimateConcept()); assertSame(element3, dmo3Copy.getArchimateConcept()); IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) dmo1Copy.getSourceConnections().get(0); assertSame(relation1, dmc1Copy.getArchimateConcept()); assertSame(dmo2Copy, dmc1Copy.getTarget()); // Connection to Connection assertSame(dmc1Copy, dmo3Copy.getSourceConnections().get(0).getTarget()); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case MutPackage.ENTRETIEN_PROFESSIONNEL___HAS_VALID_SYNTHESE__DIAGNOSTICCHAIN_MAP: return hasValidSynthese( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); } return super.eInvoke(operationID, arguments); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case DGPackage.DEFINITION___ID_CANNOT_BE_EMPTY__DIAGNOSTICCHAIN_MAP: return idCannotBeEmpty( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); } return super.eInvoke(operationID, arguments); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case CommonPackage.CONTENT_ELEMENT___REGEX__STRING: return regex((String) arguments.get(0)); case CommonPackage.CONTENT_ELEMENT___SIBLINGS__STRING: return siblings((String) arguments.get(0)); } return super.eInvoke(operationID, arguments); }
private static void checkObject( EObject expected, EObject actual, Set<EStructuralFeature> excludeFeatures, Set<EObject> visited) { if (expected == null) { assertThat(actual, is(nullValue())); return; } if (visited.contains(expected)) return; visited.add(expected); assertThat( "Actual instance for type '" + expected.eClass().getName() + "' must not be null", actual, is(notNullValue())); for (EAttribute attribute : expected.eClass().getEAllAttributes()) { if (!excludeFeatures.contains(attribute)) assertThat( "Attribute '" + attribute.getName() + "' on class '" + expected.eClass().getName() + "' did not match", actual.eGet(attribute), is(expected.eGet(attribute))); } for (EReference reference : expected.eClass().getEAllReferences()) { if (excludeFeatures.contains(reference)) continue; if (reference.isMany()) { @SuppressWarnings("unchecked") EList<EObject> expectedObjects = (EList<EObject>) expected.eGet(reference); @SuppressWarnings("unchecked") EList<EObject> actualObjects = (EList<EObject>) actual.eGet(reference); assertThat( "Reference size for '" + reference.getName() + "' does not match", actualObjects.size(), is(expectedObjects.size())); for (int i = 0; i < expectedObjects.size(); i++) checkObject(expectedObjects.get(i), actualObjects.get(i), excludeFeatures, visited); } else checkObject( (EObject) expected.eGet(reference), (EObject) actual.eGet(reference), excludeFeatures, visited); } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings({"rawtypes", "unchecked"}) public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case QVTOperationalPackage.MAPPING_BODY___ACCEPT__QVTOPERATIONALVISITOR: return accept((QVTOperationalVisitor) arguments.get(0)); case QVTOperationalPackage.MAPPING_BODY___ACCEPT__VISITOR: return accept((Visitor) arguments.get(0)); } return super.eInvoke(operationID, arguments); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case BoxingPackage.CHARACTER_BOX___GET__CONTEXT: return get((Context) arguments.get(0)); case BoxingPackage.CHARACTER_BOX___SET__OBJECT_CONTEXT: set((Character) arguments.get(0), (Context) arguments.get(1)); return null; } return super.eInvoke(operationID, arguments); }
/** * Compare current classpath with given one to see if any different. Note that the argument * classpath contains its binary output. * * @param newMindpath EList<MindPathEntry>] * @param otherMindpath EList<MindPathEntry> * @return boolean true if equals */ public static boolean areMindpathsEqual( EList<MindPathEntry> newMindpath, EList<MindPathEntry> otherMindpath) { if (otherMindpath == null || otherMindpath.size() == 0) return false; int length = otherMindpath.size(); if (length != newMindpath.size()) return false; // compare classpath entries for (int i = 0; i < length; i++) { if (!MindPathEntryCustomImpl.equals(otherMindpath.get(i), newMindpath.get(i))) return false; } return true; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case UmlPackage.EXTENSION_END___MULTIPLICITY__DIAGNOSTICCHAIN_MAP: return multiplicity( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); case UmlPackage.EXTENSION_END___AGGREGATION__DIAGNOSTICCHAIN_MAP: return aggregation( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); } return super.eInvoke(operationID, arguments); }
public void rebuildInputTable( InputTable inputTable, IMetadataTable metadataTable, PigMapData mapData) { if (metadataTable != null && metadataTable.getListColumns() != null) { List<IMetadataColumn> listColumns = metadataTable.getListColumns(); EList<TableNode> nodes = inputTable.getNodes(); for (int i = 0; i < listColumns.size(); i++) { IMetadataColumn column = listColumns.get(i); TableNode found = null; int j = 0; for (; j < nodes.size(); j++) { TableNode node = nodes.get(j); if (node.getName() != null && node.getName().equals(column.getLabel())) { found = node; break; } } if (found != null) { // set in case talend type changed in metadata found.setType(column.getTalendType()); if (i != j) { // do switch to keep the same sequence TableNode temp = nodes.get(j); nodes.remove(j); nodes.add(i, temp); } } else { found = PigmapFactory.eINSTANCE.createTableNode(); found.setName(column.getLabel()); found.setType(column.getTalendType()); found.setNullable(column.isNullable()); nodes.add(i, found); } } if (nodes.size() > listColumns.size()) { List unUsed = new ArrayList(); for (int i = listColumns.size(); i < nodes.size(); i++) { PigMapUtil.detachNodeConnections(nodes.get(i), mapData); unUsed.add(nodes.get(i)); } nodes.removeAll(unUsed); } } // re-build the connections in case any unnecessary connections are created because of previous // bugs and can't // be deleted if (inputTable.isLookup()) { rebuildInputNodesConnections(inputTable.getNodes(), mapData); } }
public Reservation make( EList<RoomBooking> selectedRooms, PaymentDetails paymentDetails, boolean payNow, String discountCode, boolean madeByCustomer) { Reservation reservation = new ReservationImpl(selectedRooms); reservation.setDiscountCode(discountCode); reservation.setPaymentdetails(paymentDetails); reservation.setPreliminaryCheckIn(selectedRooms.get(0).getCheckInDate()); reservation.setPreliminaryCheckOut(selectedRooms.get(0).getCheckOutDate()); reservation.setReservationId(nextReservationID++); return reservationsrepository.addNew(reservation); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case EnvironmentPackage.LOOKUP_ENVIRONMENT___ADD_ELEMENTS__COLLECTION: return addElements((Collection) arguments.get(0)); case EnvironmentPackage.LOOKUP_ENVIRONMENT___ADD_ELEMENT__NAMEDELEMENT: return addElement((NamedElement) arguments.get(0)); case EnvironmentPackage.LOOKUP_ENVIRONMENT___HAS_FINAL_RESULT: return hasFinalResult(); case EnvironmentPackage.LOOKUP_ENVIRONMENT___GET_EXECUTOR: return getExecutor(); } return super.eInvoke(operationID, arguments); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override @SuppressWarnings("unchecked") public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { switch (operationID) { case BpmnprofPackage .MESSAGE_FLOW_ASSOCIATION___MESSAGE_FLOW_ASSOCIATIONINNER_MESSAGE_FLOW_REF__DIAGNOSTICCHAIN_MAP: return MessageFlowAssociationinnerMessageFlowRef( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); case BpmnprofPackage .MESSAGE_FLOW_ASSOCIATION___MESSAGE_FLOW_ASSOCIATIONOUTER_MESSAGE_FLOW_REF__DIAGNOSTICCHAIN_MAP: return MessageFlowAssociationouterMessageFlowRef( (DiagnosticChain) arguments.get(0), (Map<Object, Object>) arguments.get(1)); } return super.eInvoke(operationID, arguments); }
@Test public void testDuplicateDiagramModel() { ArchimateTestModel tm = new ArchimateTestModel(); IArchimateModel model = tm.createNewModel(); IDiagramModel dm = model.getDefaultDiagramModel(); IArchimateElement actor = IArchimateFactory.eINSTANCE.createBusinessActor(); IDiagramModelArchimateObject dmo1 = tm.createDiagramModelArchimateObjectAndAddToModel(actor); dmo1.setName("dm"); dm.getChildren().add(dmo1); IArchimateElement role = IArchimateFactory.eINSTANCE.createBusinessRole(); IDiagramModelArchimateObject dmo2 = tm.createDiagramModelArchimateObjectAndAddToModel(role); dm.getChildren().add(dmo2); IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssignmentRelationship(); relation.setSource(actor); relation.setTarget(role); IDiagramModelArchimateConnection dmc1 = tm.createDiagramModelArchimateConnectionAndAddToModel(relation); dmc1.connect(dmo1, dmo2); DuplicateCommandHandler handler = new DuplicateCommandHandler(new Object[] {dm}); handler.duplicate(); assertEquals(2, model.getDiagramModels().size()); IDiagramModel dmCopy = model.getDiagramModels().get(1); assertNotSame(dm, dmCopy); assertEquals(dm.getName() + " (copy)", dmCopy.getName()); EList<IDiagramModelObject> children = dmCopy.getChildren(); assertEquals(2, children.size()); IDiagramModelArchimateObject dmo1Copy = (IDiagramModelArchimateObject) children.get(0); IDiagramModelArchimateObject dmo2Copy = (IDiagramModelArchimateObject) children.get(1); assertNotSame(dmo1, dmo1Copy); assertNotSame(dmo2, dmo2Copy); assertSame(actor, dmo1Copy.getArchimateConcept()); assertSame(role, dmo2Copy.getArchimateConcept()); EList<IDiagramModelConnection> connections = dmo1Copy.getSourceConnections(); assertEquals(1, connections.size()); IDiagramModelArchimateConnection dmc1Copy = (IDiagramModelArchimateConnection) connections.get(0); assertNotSame(dmc1, dmc1Copy); assertSame(relation, dmc1Copy.getArchimateConcept()); }
public boolean canLayout(ILayoutContext context) { // return true, if pictogram element is linked to an EClass PictogramElement pe = context.getPictogramElement(); if (!(pe instanceof ContainerShape)) return false; EList<EObject> businessObjects = pe.getLink().getBusinessObjects(); return businessObjects.size() == 1 && businessObjects.get(0) instanceof EClass; }
/** * This returns the label text for the adapted class. * <!-- begin-user-doc * --> * <!-- end-user-doc --> * * @generated NOT * @param object the object to be described * @return the description of the given object */ @Override public String getText(Object object) { if (object instanceof CreateDeleteOperation) { CreateDeleteOperation op = (CreateDeleteOperation) object; EObject modelElement = op.getModelElement(); int childrenCount = ModelUtil.getAllContainedModelElements(modelElement, false).size(); String description; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(modelElement.eClass().getName()); stringBuilder.append(getModelElementName(op.getModelElementId())); String elementClassAndName = stringBuilder.toString(); if (op.isDelete()) { description = "Deleted " + elementClassAndName; } else { description = "Created " + elementClassAndName; } if (childrenCount > 0) { description += " including " + childrenCount + " sibling(s)"; } EList<ReferenceOperation> subOperations = op.getSubOperations(); int subOperationCount = subOperations.size(); if (op.isDelete() && subOperationCount > 0) { ReferenceOperation referenceOperation = subOperations.get(subOperationCount - 1); if (referenceOperation.getContainmentType().equals(ContainmentType.CONTAINMENT)) { description += " from its parent " + getModelElementClassAndName(referenceOperation.getModelElementId()); } } return description; } return super.getText(object); }
/** * Retrieves the target from an entry. TODO: validation of preconditions for entry targets e.g * every region needs an entry with appropriate target */ public State target(final Entry entry) { State _xifexpression = null; EList<Transition> _outgoingTransitions = entry == null ? (EList<Transition>) null : entry.getOutgoingTransitions(); boolean _notEquals = (!Objects.equal(_outgoingTransitions, null)); if (_notEquals) { State _xifexpression_1 = null; EList<Transition> _outgoingTransitions_1 = entry.getOutgoingTransitions(); int _size = _outgoingTransitions_1.size(); boolean _greaterThan = (_size > 0); if (_greaterThan) { State _xblockexpression = null; { EList<Transition> _outgoingTransitions_2 = entry.getOutgoingTransitions(); Transition _get = _outgoingTransitions_2.get(0); final Vertex target = _get.getTarget(); State _xifexpression_2 = null; if ((target instanceof State)) { _xifexpression_2 = ((State) target); } _xblockexpression = (_xifexpression_2); } _xifexpression_1 = _xblockexpression; } _xifexpression = _xifexpression_1; } return _xifexpression; }
@Override public int category(Object element) { if (element instanceof RepositoryNode) { RepositoryNode node = (RepositoryNode) element; if (ERepositoryObjectType.METADATA_CON_COLUMN.equals( node.getProperties(EProperties.CONTENT_TYPE))) { RepositoryNode parent = node.getParent().getParent(); if (parent != null && ERepositoryObjectType.METADATA_CON_TABLE.equals( parent.getProperties(EProperties.CONTENT_TYPE)) && parent.getObject() instanceof MetadataTableRepositoryObject) { MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) parent.getObject(); MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) ((RepositoryNode) element).getObject(); MetadataColumn tColumn = columnObject.getTdColumn(); EList<MetadataColumn> columns = tableObject.getTable().getColumns(); for (int i = 0; i < columns.size(); i++) { MetadataColumn column = columns.get(i); if (column.getName() != null && column.getName().equals(tColumn.getName())) { return i; } } } } } return super.category(element); }
void createDefinitionsIfMissing() { EList<EObject> contents = resource.getContents(); if (contents.isEmpty() || !(contents.get(0) instanceof DocumentRoot)) { TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource); if (domain != null) { final DocumentRoot docRoot = FACTORY.createDocumentRoot(); final Definitions definitions = FACTORY.createDefinitions(); // definitions.setId(EcoreUtil.generateUUID()); ModelUtil.setID(definitions, resource); Collaboration collaboration = FACTORY.createCollaboration(); // collaboration.setId(EcoreUtil.generateUUID()); ModelUtil.setID(collaboration, resource); Participant participant = FACTORY.createParticipant(); // participant.setId(EcoreUtil.generateUUID()); ModelUtil.setID(participant, resource); participant.setName("Internal"); collaboration.getParticipants().add(participant); definitions.getRootElements().add(collaboration); domain .getCommandStack() .execute( new RecordingCommand(domain) { @Override protected void doExecute() { docRoot.setDefinitions(definitions); resource.getContents().add(docRoot); } }); return; } } }
public org.eclipse.core.runtime.IStatus build( org.emftext.language.efactory.resource.efactory.mopp.EfactoryResource resource, org.eclipse.core.runtime.IProgressMonitor monitor) { if (resource.getErrors().size() == 0) { EList<EObject> contents = resource.getContents(); if (contents.size() > 0) { EObject rootObject = contents.get(0); if (rootObject instanceof Factory) { Factory factory = (Factory) rootObject; Builder builder = new Builder(); Map<EObject, String> problems = new LinkedHashMap<EObject, String>(); List<EObject> roots = builder.build(factory, problems); URI xmiURI = resource.getURI().trimFileExtension().appendFileExtension("xmi"); Resource xmiResource = new ResourceSetImpl().createResource(xmiURI); xmiResource.getContents().addAll(roots); try { Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); xmiResource.save(options); } catch (IOException e) { e.printStackTrace(); } for (Entry<EObject, String> problem : problems.entrySet()) { resource.addError( problem.getValue(), EfactoryEProblemType.BUILDER_ERROR, problem.getKey()); } } } } return org.eclipse.core.runtime.Status.OK_STATUS; }