Search in sources :

Example 46 with IArchimateElement

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

the class GenerateViewDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.GenerateViewDialog_1);
    // $NON-NLS-1$
    String message = "";
    for (Iterator<IArchimateElement> iter = fSelectedElements.iterator(); iter.hasNext(); ) {
        message += ArchiLabelProvider.INSTANCE.getLabel(iter.next());
        if (iter.hasNext()) {
            // $NON-NLS-1$
            message += ", ";
        } else {
            // $NON-NLS-1$
            message += ".";
        }
    }
    setMessage(message);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    layout.verticalSpacing = 20;
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label label = new Label(client, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_3);
    fComboViewer = new ComboViewer(new Combo(client, SWT.READ_ONLY | SWT.BORDER));
    fComboViewer.getCombo().setVisibleItemCount(12);
    fComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    for (IViewpoint viewpoint : ViewpointManager.INSTANCE.getAllViewpoints()) {
        boolean allowed = true;
        for (IArchimateElement element : fSelectedElements) {
            if (!viewpoint.isAllowedConcept(element.eClass())) {
                allowed = false;
                break;
            }
        }
        if (allowed && !fValidViewPoints.contains(viewpoint)) {
            fValidViewPoints.add(viewpoint);
        }
    }
    fComboViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return fValidViewPoints.toArray();
        }
    });
    fComboViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((IViewpoint) element).getName();
        }
    });
    // $NON-NLS-1$
    fComboViewer.setInput("");
    label = new Label(client, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_2);
    fNameText = new Text(client, SWT.BORDER);
    fNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // $NON-NLS-1$
    fNameText.setText(Messages.GenerateViewDialog_6 + " " + ArchiLabelProvider.INSTANCE.getLabel(fSelectedElements.get(0)));
    Group groupOptions = new Group(client, SWT.NONE);
    groupOptions.setText(Messages.GenerateViewDialog_4);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    groupOptions.setLayoutData(gd);
    groupOptions.setLayout(new GridLayout(2, false));
    label = new Label(groupOptions, SWT.NONE);
    label.setText(Messages.GenerateViewDialog_5);
    fAddAllConnectionsButton = new Button(groupOptions, SWT.CHECK);
    loadPreferences();
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) Text(org.eclipse.swt.widgets.Text) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IArchimateElement(com.archimatetool.model.IArchimateElement) ArchiLabelProvider(com.archimatetool.editor.ui.ArchiLabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 47 with IArchimateElement

use of com.archimatetool.model.IArchimateElement in project archi-modelrepository-plugin by archi-contribs.

the class GraficoModelImporter method resolveProxies.

/**
 * Iterate through all model objects, and resolve proxies on known classes
 */
private void resolveProxies() {
    for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
        EObject eObject = iter.next();
        if (eObject instanceof IArchimateRelationship) {
            // Resolve proxies for Relations
            IArchimateRelationship relation = (IArchimateRelationship) eObject;
            relation.setSource((IArchimateConcept) resolve(relation.getSource(), relation));
            relation.setTarget((IArchimateConcept) resolve(relation.getTarget(), relation));
        } else if (eObject instanceof IDiagramModelArchimateObject) {
            // Resolve proxies for Elements
            IDiagramModelArchimateObject element = (IDiagramModelArchimateObject) eObject;
            element.setArchimateElement((IArchimateElement) resolve(element.getArchimateElement(), element));
            // Update cross-references
            element.getArchimateElement().getReferencingDiagramObjects().add(element);
        } else if (eObject instanceof IDiagramModelArchimateConnection) {
            // Resolve proxies for Connections
            IDiagramModelArchimateConnection archiConnection = (IDiagramModelArchimateConnection) eObject;
            archiConnection.setArchimateRelationship((IArchimateRelationship) resolve(archiConnection.getArchimateRelationship(), archiConnection));
            // Update cross-reference
            archiConnection.getArchimateRelationship().getReferencingDiagramConnections().add(archiConnection);
        } else if (eObject instanceof IDiagramModelReference) {
            // Resolve proxies for Model References
            IDiagramModelReference element = (IDiagramModelReference) eObject;
            element.setReferencedModel((IDiagramModel) resolve(element.getReferencedModel(), element));
        }
    }
}
Also used : IDiagramModelReference(com.archimatetool.model.IDiagramModelReference) IDiagramModel(com.archimatetool.model.IDiagramModel) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 48 with IArchimateElement

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

the class DiagramFigureTypeSection method update.

@Override
protected void update() {
    IDiagramModelArchimateObject diagramObject = (IDiagramModelArchimateObject) getFirstSelectedObject();
    IArchimateElement element = diagramObject.getArchimateElement();
    Image image1 = FigureImagePreviewFactory.getFigurePreviewImageForClass(element.eClass());
    Image image2 = FigureImagePreviewFactory.getAlternateFigurePreviewImageForClass(element.eClass());
    figure1.setImage(image1);
    figure2.setImage(image2);
    figure1.getParent().layout();
    int type = diagramObject.getType();
    figure1.setSelected(type == 0);
    figure2.setSelected(type == 1);
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Image(org.eclipse.swt.graphics.Image)

Example 49 with IArchimateElement

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

the class ArchimateDiagramModelFactoryTests method testCreateDiagramModelArchimateObject.

@Test
public void testCreateDiagramModelArchimateObject() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessProcess();
    Preferences.STORE.setValue(IPreferenceConstants.DEFAULT_FIGURE_PREFIX + element.eClass().getName(), 1);
    Preferences.STORE.setValue(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR, true);
    Preferences.STORE.setValue(IPreferenceConstants.DEFAULT_FILL_COLOR_PREFIX + element.eClass().getName(), "#ededed");
    IDiagramModelArchimateObject dmo = ArchimateDiagramModelFactory.createDiagramModelArchimateObject(element);
    assertNotNull(dmo);
    assertEquals(element, dmo.getArchimateElement());
    assertEquals(1, dmo.getType());
    assertEquals("#ededed", dmo.getFillColor());
    Preferences.STORE.setToDefault(IPreferenceConstants.DEFAULT_FIGURE_PREFIX + element.eClass().getName());
    Preferences.STORE.setToDefault(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR);
    Preferences.STORE.setToDefault(IPreferenceConstants.DEFAULT_FILL_COLOR_PREFIX + element.eClass().getName());
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) Test(org.junit.Test)

Example 50 with IArchimateElement

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

the class CreateDiagramArchimateConnectionWithDialogCommandTests method testGetExistingRelationshipOfType.

@Test
public void testGetExistingRelationshipOfType() {
    ArchimateTestModel tm = new ArchimateTestModel();
    tm.createSimpleModel();
    IArchimateElement source = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    IArchimateElement target = (IArchimateElement) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getBusinessActor());
    IArchimateRelationship relation1 = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getAssignmentRelationship());
    IArchimateRelationship relation2 = (IArchimateRelationship) tm.createModelElementAndAddToModel(IArchimatePackage.eINSTANCE.getFlowRelationship());
    assertNull(cmd.getExistingRelationshipOfType(IArchimatePackage.eINSTANCE.getAssignmentRelationship(), source, target));
    relation1.setSource(source);
    relation1.setTarget(target);
    relation2.setSource(source);
    relation2.setTarget(target);
    assertEquals(relation1, cmd.getExistingRelationshipOfType(IArchimatePackage.eINSTANCE.getAssignmentRelationship(), source, target));
    assertEquals(relation2, cmd.getExistingRelationshipOfType(IArchimatePackage.eINSTANCE.getFlowRelationship(), source, target));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) ArchimateTestModel(com.archimatetool.testingtools.ArchimateTestModel) Test(org.junit.Test)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3