Search in sources :

Example 1 with VirtualSupersetType

use of org.tmdmaker.core.model.VirtualSupersetType in project tmdmaker by tmdmaker.

the class VirtualSupersetTypeEditPart method getCommand.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.gef.editparts.AbstractEditPart#getCommand(org.eclipse.gef.Request)
 */
@Override
public Command getCommand(Request request) {
    if (!REQ_OPEN.equals(request.getType()))
        return super.getCommand(request);
    VirtualSupersetType type = getModel();
    VirtualSuperset superset = type.getSuperset();
    Diagram diagram = superset.getDiagram();
    List<AbstractEntityModel> list = type.getSubsetList();
    VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getViewer().getControl().getShell(), diagram, superset, list);
    if (dialog.open() != Dialog.OK)
        return null;
    return new VirtualSupersetEditCommand(superset, dialog.getEditedValue(), dialog.getSelection(), dialog.getEditedAggregator().isApplyAttribute());
}
Also used : VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram)

Example 2 with VirtualSupersetType

use of org.tmdmaker.core.model.VirtualSupersetType in project tmdmaker by tmdmaker.

the class VirtualSupersetTypeEditPart method updateFigure.

/**
 * {@inheritDoc}
 *
 * @see org.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart#updateFigure(org.eclipse.draw2d.IFigure)
 */
@Override
protected void updateFigure(IFigure figure) {
    SubsetTypeFigure sf = (SubsetTypeFigure) figure;
    VirtualSupersetType model = getModel();
    sf.setVertical(model.isVertical());
    sf.setSameType(model.isApplyAttribute());
}
Also used : SubsetTypeFigure(org.tmdmaker.ui.editor.draw2d.figure.node.SubsetTypeFigure) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType)

Example 3 with VirtualSupersetType

use of org.tmdmaker.core.model.VirtualSupersetType in project tmdmaker by tmdmaker.

the class RelatedRelationshipTest method testVirtualSupersetHelper.

/**
 * Test method for {@link org.tmdmaker.core.model.RelatedRelationship}
 * .
 */
@Test
public void testVirtualSupersetHelper() {
    Diagram diagram = new Diagram();
    Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
    VirtualSupersetType type = new VirtualSupersetType();
    diagram.addChild(vsp);
    diagram.addChild(type);
    RelatedRelationship t2v = new RelatedRelationship(type, vsp);
    Entity2VirtualSupersetTypeRelationship m2t1 = new Entity2VirtualSupersetTypeRelationship(e1, type);
    Entity2VirtualSupersetTypeRelationship m2t2 = new Entity2VirtualSupersetTypeRelationship(e2, type);
    t2v.connect();
    m2t1.connect();
    m2t2.connect();
    assertEquals(true, t2v.isDeletable());
    assertEquals("スーパーセット", t2v.getSourceName());
    assertEquals("テスト1,テスト2", t2v.getTargetName());
    assertEquals("スーパーセット", m2t1.getSourceName());
    assertEquals("テスト1", m2t1.getTargetName());
}
Also used : Entity(org.tmdmaker.core.model.Entity) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) Entity2VirtualSupersetTypeRelationship(org.tmdmaker.core.model.Entity2VirtualSupersetTypeRelationship) RelatedRelationship(org.tmdmaker.core.model.RelatedRelationship) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Example 4 with VirtualSupersetType

use of org.tmdmaker.core.model.VirtualSupersetType in project tmdmaker by tmdmaker.

the class VirtualSupersetTest method testRemoveSubset.

@Test
public void testRemoveSubset() {
    Diagram diagram = new Diagram();
    Entity e1 = Entity.ofResource(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    Entity e2 = Entity.ofResource(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
    list.add(e1);
    list.add(e2);
    VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
    VirtualSubsetBuilder builder = vsp.virtualSubsets().builder();
    builder.subsetList(list).build();
    assertTrue(vsp.hasSubset());
    VirtualSupersetType type1 = vsp.getVirtualSupersetType();
    assertEquals(true, vsp.isDeletable());
    assertEquals(true, type1.isApplyAttribute());
    assertEquals(false, vsp.isEntityTypeEditable());
    assertEquals(true, vsp.hasSubset());
    assertEquals(2, vsp.getVirtualSubsetRelationshipList().size());
    builder.rollback();
    assertTrue(!vsp.hasSubset());
    VirtualSupersetType type2 = vsp.getVirtualSupersetType();
    if (!diagram.contains(type2)) {
        return;
    }
}
Also used : Entity(org.tmdmaker.core.model.Entity) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) VirtualSubsetBuilder(org.tmdmaker.core.model.virtual.VirtualSubsetBuilder) ArrayList(java.util.ArrayList) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Example 5 with VirtualSupersetType

use of org.tmdmaker.core.model.VirtualSupersetType in project tmdmaker by tmdmaker.

the class DiagramTest method testCreateVirtualSuperset.

@Test
public void testCreateVirtualSuperset() {
    Diagram diagram = new Diagram();
    Entity e1 = Entity.ofEvent(new Identifier("テスト1番号")).withDefaultAttribute();
    diagram.addChild(e1);
    Entity e2 = Entity.ofEvent(new Identifier("テスト2番号")).withDefaultAttribute();
    diagram.addChild(e2);
    List<AbstractEntityModel> list = new ArrayList<AbstractEntityModel>();
    list.add(e1);
    list.add(e2);
    VirtualSuperset vsp = VirtualSuperset.of(new ModelName("スーパーセット"));
    vsp.virtualSubsets().builder().subsetList(list).build();
    VirtualSupersetType2VirtualSupersetRelationship t2v = (VirtualSupersetType2VirtualSupersetRelationship) vsp.getModelTargetConnections().get(0);
    VirtualSupersetType type = vsp.getVirtualSupersetType();
    Entity2VirtualSupersetTypeRelationship m2t1 = (Entity2VirtualSupersetTypeRelationship) type.getModelTargetConnections().get(0);
    assertEquals(2, vsp.getVirtualSubsetList().size());
    assertEquals(true, t2v.isDeletable());
    assertEquals("スーパーセット", t2v.getSourceName());
    assertEquals("テスト1,テスト2", t2v.getTargetName());
    assertEquals("スーパーセット", m2t1.getSourceName());
    assertEquals("テスト1", m2t1.getTargetName());
}
Also used : Entity(org.tmdmaker.core.model.Entity) VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) Identifier(org.tmdmaker.core.model.Identifier) ModelName(org.tmdmaker.core.model.parts.ModelName) Entity2VirtualSupersetTypeRelationship(org.tmdmaker.core.model.Entity2VirtualSupersetTypeRelationship) VirtualSupersetType2VirtualSupersetRelationship(org.tmdmaker.core.model.VirtualSupersetType2VirtualSupersetRelationship) ArrayList(java.util.ArrayList) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram) Test(org.junit.Test)

Aggregations

VirtualSupersetType (org.tmdmaker.core.model.VirtualSupersetType)10 Diagram (org.tmdmaker.core.model.Diagram)7 VirtualSuperset (org.tmdmaker.core.model.VirtualSuperset)7 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)6 ModelName (org.tmdmaker.core.model.parts.ModelName)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 Entity (org.tmdmaker.core.model.Entity)5 Identifier (org.tmdmaker.core.model.Identifier)5 Entity2VirtualSupersetTypeRelationship (org.tmdmaker.core.model.Entity2VirtualSupersetTypeRelationship)3 RelatedRelationship (org.tmdmaker.core.model.RelatedRelationship)2 VirtualSupersetType2VirtualSupersetRelationship (org.tmdmaker.core.model.VirtualSupersetType2VirtualSupersetRelationship)2 VirtualSupersetCreateDialog (org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog)2 VirtualSupersetEditCommand (org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 Point (org.eclipse.swt.graphics.Point)1 AbstractConnectionModel (org.tmdmaker.core.model.AbstractConnectionModel)1 VirtualSubsetBuilder (org.tmdmaker.core.model.virtual.VirtualSubsetBuilder)1 SubsetTypeFigure (org.tmdmaker.ui.editor.draw2d.figure.node.SubsetTypeFigure)1 VirtualSupersetCreateCommand (org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetCreateCommand)1