@Test public void testMergePropositions_8() throws HmxException { final Proposition first = this.pericope.getPropositionAt(0); final Proposition second = this.pericope.getPropositionAt(1); final Proposition third = this.pericope.getPropositionAt(2); final Proposition fourth = this.pericope.getPropositionAt(3); final Proposition fifth = this.pericope.getPropositionAt(4); this.modelHandler.mergePropositions(fourth, second); this.modelHandler.mergePropositions(first, fifth); this.modelHandler.mergePropositions(fourth, fifth); Assert.assertEquals(3, this.pericope.getFlatText().size()); final Proposition merged = this.pericope.getPropositionAt(0); Assert.assertEquals(Arrays.asList(new ClauseItem(merged, "1 2"), new ClauseItem(merged, "3"), new ClauseItem(merged, "4"), new ClauseItem( merged, "5")), merged.getItems()); final Proposition mergedAfterArrow = merged.getPartAfterArrow(); Assert.assertNotNull(mergedAfterArrow); Assert.assertEquals(Arrays.asList(new ClauseItem(mergedAfterArrow, "7"), new ClauseItem(mergedAfterArrow, "8 9"), new ClauseItem( mergedAfterArrow, "10")), mergedAfterArrow.getItems()); Assert.assertEquals(1, mergedAfterArrow.getPriorChildren().size()); Assert.assertSame(third, mergedAfterArrow.getPriorChildren().get(0)); }
@Override public void mergePropositions(final Proposition prop1, final Proposition prop2) throws HmxException { if (prop1 == prop2) { return; } final Proposition propOne = prop1.getFirstPart(); final Proposition propTwo = prop2.getFirstPart(); final IPropositionParent parent = propOne.getParent(); if (parent != propTwo.getParent()) { if (!this.checkForConnection(propOne, propTwo) && !this.checkForConnection(propTwo, propOne)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } this.notifyListeners(this.getModel(), false); return; } final List<Proposition> containingList = parent.getContainingList(propOne); if (!CollectionUtil.containsInstance(containingList, propTwo)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } final Proposition firstPart; final Proposition secondPart; if (CollectionUtil.indexOfInstance(containingList, propOne) < CollectionUtil.indexOfInstance(containingList, propTwo)) { firstPart = propOne; secondPart = propTwo; } else { firstPart = propTwo; secondPart = propOne; } final Proposition firstAfterArrow = firstPart.getLastPart(); if (firstAfterArrow.isPriorOf(secondPart)) { this.mergeConnectedPropositionsIntoOne(firstAfterArrow, secondPart); secondPart.getParent().removeChildProposition(secondPart); } else { this.mergePropositionsWithEnclosedChildren(firstPart, secondPart); } this.notifyListeners(this.getModel(), false); }
ModelHandlerImpl extends AbstractModelHandler<Pericope> implements HmxModelHandler { @Override public void mergePropositions(final Proposition prop1, final Proposition prop2) throws HmxException { if (prop1 == prop2) { return; } final Proposition propOne = prop1.getFirstPart(); final Proposition propTwo = prop2.getFirstPart(); final IPropositionParent parent = propOne.getParent(); if (parent != propTwo.getParent()) { if (!this.checkForConnection(propOne, propTwo) && !this.checkForConnection(propTwo, propOne)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } this.notifyListeners(this.getModel(), false); return; } final List<Proposition> containingList = parent.getContainingList(propOne); if (!CollectionUtil.containsInstance(containingList, propTwo)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } final Proposition firstPart; final Proposition secondPart; if (CollectionUtil.indexOfInstance(containingList, propOne) < CollectionUtil.indexOfInstance(containingList, propTwo)) { firstPart = propOne; secondPart = propTwo; } else { firstPart = propTwo; secondPart = propOne; } final Proposition firstAfterArrow = firstPart.getLastPart(); if (firstAfterArrow.isPriorOf(secondPart)) { this.mergeConnectedPropositionsIntoOne(firstAfterArrow, secondPart); secondPart.getParent().removeChildProposition(secondPart); } else { this.mergePropositionsWithEnclosedChildren(firstPart, secondPart); } this.notifyListeners(this.getModel(), false); } }
ModelHandlerImpl extends AbstractModelHandler<Pericope> implements HmxModelHandler { @Override public void mergePropositions(final Proposition prop1, final Proposition prop2) throws HmxException { if (prop1 == prop2) { return; } final Proposition propOne = prop1.getFirstPart(); final Proposition propTwo = prop2.getFirstPart(); final IPropositionParent parent = propOne.getParent(); if (parent != propTwo.getParent()) { if (!this.checkForConnection(propOne, propTwo) && !this.checkForConnection(propTwo, propOne)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } this.notifyListeners(this.getModel(), false); return; } final List<Proposition> containingList = parent.getContainingList(propOne); if (!CollectionUtil.containsInstance(containingList, propTwo)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } final Proposition firstPart; final Proposition secondPart; if (CollectionUtil.indexOfInstance(containingList, propOne) < CollectionUtil.indexOfInstance(containingList, propTwo)) { firstPart = propOne; secondPart = propTwo; } else { firstPart = propTwo; secondPart = propOne; } final Proposition firstAfterArrow = firstPart.getLastPart(); if (firstAfterArrow.isPriorOf(secondPart)) { this.mergeConnectedPropositionsIntoOne(firstAfterArrow, secondPart); secondPart.getParent().removeChildProposition(secondPart); } else { this.mergePropositionsWithEnclosedChildren(firstPart, secondPart); } this.notifyListeners(this.getModel(), false); } ModelHandlerImpl(final Pericope model); }
ModelHandlerImpl extends AbstractModelHandler<Pericope> implements HmxModelHandler { @Override public void mergePropositions(final Proposition prop1, final Proposition prop2) throws HmxException { if (prop1 == prop2) { return; } final Proposition propOne = prop1.getFirstPart(); final Proposition propTwo = prop2.getFirstPart(); final IPropositionParent parent = propOne.getParent(); if (parent != propTwo.getParent()) { if (!this.checkForConnection(propOne, propTwo) && !this.checkForConnection(propTwo, propOne)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } this.notifyListeners(this.getModel(), false); return; } final List<Proposition> containingList = parent.getContainingList(propOne); if (!CollectionUtil.containsInstance(containingList, propTwo)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } final Proposition firstPart; final Proposition secondPart; if (CollectionUtil.indexOfInstance(containingList, propOne) < CollectionUtil.indexOfInstance(containingList, propTwo)) { firstPart = propOne; secondPart = propTwo; } else { firstPart = propTwo; secondPart = propOne; } final Proposition firstAfterArrow = firstPart.getLastPart(); if (firstAfterArrow.isPriorOf(secondPart)) { this.mergeConnectedPropositionsIntoOne(firstAfterArrow, secondPart); secondPart.getParent().removeChildProposition(secondPart); } else { this.mergePropositionsWithEnclosedChildren(firstPart, secondPart); } this.notifyListeners(this.getModel(), false); } ModelHandlerImpl(final Pericope model); @Override void resetModel(final Pericope model); @Override void setMetaData(final String title, final String author, final String comment, final String originTextFontFamily,
            final int originTextFontSize); @Override void indentPropositionUnderParent(final Proposition target, final Proposition parent, final SyntacticalFunction function); @Override void removeOneIndentation(final Proposition target); @Override boolean removeOneIndentationAffectsOthers(final Proposition target); @Override void mergePropositions(final Proposition prop1, final Proposition prop2); @Override void splitProposition(final Proposition target, final ClauseItem lastItemInFirstPart); @Override void resetStandaloneStateOfPartAfterArrow(final Proposition partAfterArrow); @Override void mergeClauseItemWithPrior(final ClauseItem itemTwo); @Override void mergeClauseItemWithFollower(final ClauseItem itemOne); @Override void splitClauseItem(final ClauseItem target, final String firstPart); @Override void setLabelText(final Proposition target, final String labelText); @Override void setSynTranslation(final Proposition target, final String synTranslation); @Override void setSemTranslation(final Proposition target, final String semTranslation); @Override void setComment(final ICommentable target, final String comment); @Override void setSyntacticalFunction(final ICanHaveSyntacticalFunction target, final SyntacticalFunction function); @Override void setClauseItemFontStyle(final ClauseItem target, final Style style); @Override void createRelation(final List<? extends AbstractConnectable> associates, final RelationTemplate template); @Override void rotateAssociateRoles(final Relation target); @Override void alterRelationType(final Relation target, final RelationTemplate template); @Override void removeRelation(final Relation target); @Override void addNewPropositions(final String originText, final boolean inFront); @Override void mergeWithOtherPericope(final Pericope otherPericope, final boolean inFront); @Override void removePropositions(final List<Proposition> targets); }
ModelHandlerImpl extends AbstractModelHandler<Pericope> implements HmxModelHandler { @Override public void mergePropositions(final Proposition prop1, final Proposition prop2) throws HmxException { if (prop1 == prop2) { return; } final Proposition propOne = prop1.getFirstPart(); final Proposition propTwo = prop2.getFirstPart(); final IPropositionParent parent = propOne.getParent(); if (parent != propTwo.getParent()) { if (!this.checkForConnection(propOne, propTwo) && !this.checkForConnection(propTwo, propOne)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } this.notifyListeners(this.getModel(), false); return; } final List<Proposition> containingList = parent.getContainingList(propOne); if (!CollectionUtil.containsInstance(containingList, propTwo)) { throw new HmxException(HmxMessage.ERROR_MERGE_PROPS); } final Proposition firstPart; final Proposition secondPart; if (CollectionUtil.indexOfInstance(containingList, propOne) < CollectionUtil.indexOfInstance(containingList, propTwo)) { firstPart = propOne; secondPart = propTwo; } else { firstPart = propTwo; secondPart = propOne; } final Proposition firstAfterArrow = firstPart.getLastPart(); if (firstAfterArrow.isPriorOf(secondPart)) { this.mergeConnectedPropositionsIntoOne(firstAfterArrow, secondPart); secondPart.getParent().removeChildProposition(secondPart); } else { this.mergePropositionsWithEnclosedChildren(firstPart, secondPart); } this.notifyListeners(this.getModel(), false); } ModelHandlerImpl(final Pericope model); @Override void resetModel(final Pericope model); @Override void setMetaData(final String title, final String author, final String comment, final String originTextFontFamily,
            final int originTextFontSize); @Override void indentPropositionUnderParent(final Proposition target, final Proposition parent, final SyntacticalFunction function); @Override void removeOneIndentation(final Proposition target); @Override boolean removeOneIndentationAffectsOthers(final Proposition target); @Override void mergePropositions(final Proposition prop1, final Proposition prop2); @Override void splitProposition(final Proposition target, final ClauseItem lastItemInFirstPart); @Override void resetStandaloneStateOfPartAfterArrow(final Proposition partAfterArrow); @Override void mergeClauseItemWithPrior(final ClauseItem itemTwo); @Override void mergeClauseItemWithFollower(final ClauseItem itemOne); @Override void splitClauseItem(final ClauseItem target, final String firstPart); @Override void setLabelText(final Proposition target, final String labelText); @Override void setSynTranslation(final Proposition target, final String synTranslation); @Override void setSemTranslation(final Proposition target, final String semTranslation); @Override void setComment(final ICommentable target, final String comment); @Override void setSyntacticalFunction(final ICanHaveSyntacticalFunction target, final SyntacticalFunction function); @Override void setClauseItemFontStyle(final ClauseItem target, final Style style); @Override void createRelation(final List<? extends AbstractConnectable> associates, final RelationTemplate template); @Override void rotateAssociateRoles(final Relation target); @Override void alterRelationType(final Relation target, final RelationTemplate template); @Override void removeRelation(final Relation target); @Override void addNewPropositions(final String originText, final boolean inFront); @Override void mergeWithOtherPericope(final Pericope otherPericope, final boolean inFront); @Override void removePropositions(final List<Proposition> targets);  }