Search in sources :

Example 6 with IDiagramModelNote

use of com.archimatetool.model.IDiagramModelNote in project archi by archimatetool.

the class ArchimateDiagramModelFactory method getNewObject.

public Object getNewObject() {
    if (fTemplate == null) {
        return null;
    }
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Connection created from Relationship Template
    if (object instanceof IArchimateRelationship) {
        return createDiagramModelArchimateConnection((IArchimateRelationship) object);
    } else // Archimate Diagram Object created from Archimate Element Template
    if (object instanceof IArchimateElement) {
        IArchimateElement element = (IArchimateElement) object;
        element.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        return createDiagramModelArchimateObject(element);
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
        ((IDiagramModelGroup) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Note
    if (object instanceof IDiagramModelNote) {
        ColorFactory.setDefaultColors((IDiagramModelObject) object);
        ((IDiagramModelNote) object).setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        ColorFactory.setDefaultColors((IDiagramModelConnection) object);
    }
    return object;
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote)

Example 7 with IDiagramModelNote

use of com.archimatetool.model.IDiagramModelNote in project archi by archimatetool.

the class PropertiesLabelProviderTests method testGetTextNote.

@Test
public void testGetTextNote() {
    // Text for diagram model
    IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
    String text = provider.getText(new StructuredSelection(note));
    assertEquals("Note", text);
    // Text for EditPart
    NoteEditPart editPart = new NoteEditPart();
    editPart.setModel(note);
    text = provider.getText(new StructuredSelection(editPart));
    assertEquals("Note", text);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart) IDiagramModelNote(com.archimatetool.model.IDiagramModelNote) Test(org.junit.Test)

Aggregations

IDiagramModelNote (com.archimatetool.model.IDiagramModelNote)7 Test (org.junit.Test)5 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)2 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)2 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)2 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)1 GroupEditPart (com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart)1 IArchimateConcept (com.archimatetool.model.IArchimateConcept)1 IArchimateElement (com.archimatetool.model.IArchimateElement)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)1 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 EClass (org.eclipse.emf.ecore.EClass)1 EditPart (org.eclipse.gef.EditPart)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1