Search in sources :

Example 1 with IArchimateModel

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

the class TreeViewpointFilterProvider method getTextColor.

/**
 * If the element is disallowed in a Viewpoint grey it out
 * @param element
 * @return Color or null
 */
Color getTextColor(Object element) {
    if (isActive() && fActiveDiagramModel != null && element instanceof IArchimateConcept) {
        String id = fActiveDiagramModel.getViewpoint();
        IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
        if (viewpoint != null) {
            // From same model as active diagram
            IArchimateModel model = ((IArchimateConcept) element).getArchimateModel();
            if (model == fActiveDiagramModel.getArchimateModel()) {
                if (element instanceof IArchimateRelationship) {
                    IArchimateConcept source = ((IArchimateRelationship) element).getSource();
                    IArchimateConcept target = ((IArchimateRelationship) element).getTarget();
                    if (!viewpoint.isAllowedConcept(source.eClass()) || !viewpoint.isAllowedConcept(target.eClass())) {
                        return ColorFactory.get(128, 128, 128);
                    }
                } else if (element instanceof IArchimateElement) {
                    if (!viewpoint.isAllowedConcept(((IArchimateElement) element).eClass())) {
                        return ColorFactory.get(128, 128, 128);
                    }
                }
            }
        }
    }
    return null;
}
Also used : IArchimateConcept(com.archimatetool.model.IArchimateConcept) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateModel(com.archimatetool.model.IArchimateModel)

Example 2 with IArchimateModel

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

the class JasperReportsProvider method run.

@Override
public void run(CommandLine commandLine) throws Exception {
    if (!hasCorrectOptions(commandLine)) {
        return;
    }
    IArchimateModel model = CommandLineState.getModel();
    if (model == null) {
        throw new IOException(Messages.JasperReportsProvider_1);
    }
    // Folder
    String path = commandLine.getOptionValue(OPTION_JASPER_CREATE_REPORT);
    if (!StringUtils.isSet(path)) {
        logError(Messages.JasperReportsProvider_2);
        return;
    }
    File folderOutput = new File(path);
    folderOutput.mkdirs();
    if (!folderOutput.exists()) {
        logError(NLS.bind(Messages.JasperReportsProvider_3, folderOutput.getPath()));
        return;
    }
    // Filename
    String filename = commandLine.getOptionValue(OPTION_JASPER_FILENAME);
    if (!StringUtils.isSet(filename)) {
        logError(Messages.JasperReportsProvider_4);
        return;
    }
    // Template file
    // $NON-NLS-1$
    File templateFile = new File(JasperReportsPlugin.INSTANCE.getJasperReportsFolder(), "Customizable Report/main.jrxml");
    String template = commandLine.getOptionValue(OPTION_JASPER_TEMPLATE);
    if (StringUtils.isSet(template)) {
        templateFile = new File(template);
        if (!templateFile.exists()) {
            logError(NLS.bind(Messages.JasperReportsProvider_5, templateFile.getPath()));
            return;
        }
    }
    // Title
    String title = commandLine.getOptionValue(OPTION_JASPER_TITLE);
    if (!StringUtils.isSet(title)) {
        logError(Messages.JasperReportsProvider_6);
        return;
    }
    // Locale
    Locale locale = null;
    String loc = commandLine.getOptionValue(OPTION_JASPER_LOCALE);
    if (StringUtils.isSet(loc)) {
        locale = Locale.forLanguageTag(loc.replace('_', '-'));
    }
    // Export options
    int exportOptions = JasperReportsExporter.EXPORT_PDF;
    String format = commandLine.getOptionValue(OPTION_JASPER_FORMAT).toLowerCase();
    // $NON-NLS-1$
    exportOptions |= format.contains("pdf") ? JasperReportsExporter.EXPORT_PDF : 0;
    // $NON-NLS-1$
    exportOptions |= format.contains("html") ? JasperReportsExporter.EXPORT_HTML : 0;
    // $NON-NLS-1$
    exportOptions |= format.contains("rtf") ? JasperReportsExporter.EXPORT_RTF : 0;
    // $NON-NLS-1$
    exportOptions |= format.contains("ppt") ? JasperReportsExporter.EXPORT_PPT : 0;
    // $NON-NLS-1$
    exportOptions |= format.contains("odt") ? JasperReportsExporter.EXPORT_ODT : 0;
    // $NON-NLS-1$
    exportOptions |= format.contains("docx") ? JasperReportsExporter.EXPORT_DOCX : 0;
    logMessage(NLS.bind(Messages.JasperReportsProvider_7, model.getName(), folderOutput.getPath()));
    JasperReportsExporter exporter = new JasperReportsExporter(model, folderOutput, filename, templateFile, title, locale, exportOptions);
    exporter.export(new NullProgressMonitor() {

        @Override
        public void subTask(String name) {
            logMessage(name);
        }
    });
    logMessage(Messages.JasperReportsProvider_8);
}
Also used : Locale(java.util.Locale) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) JasperReportsExporter(com.archimatetool.jasperreports.JasperReportsExporter) IOException(java.io.IOException) IArchimateModel(com.archimatetool.model.IArchimateModel) File(java.io.File)

Example 3 with IArchimateModel

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

the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept_NoRelations.

@Test
public void testGetAllRelationshipsForConcept_NoRelations() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element1).getElements().add(element1);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
    model.getDefaultFolderForObject(element2).getElements().add(element2);
    assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element1).isEmpty());
    assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element2).isEmpty());
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 4 with IArchimateModel

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

the class ArchimateModelUtilsTests method testGetObjectByID.

@Test
public void testGetObjectByID() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    EObject element = ArchimateModelUtils.getObjectByID(model, null);
    assertNull(element);
    IArchimateElement newElement1 = IArchimateFactory.eINSTANCE.createApplicationFunction();
    model.getDefaultFolderForObject(newElement1).getElements().add(newElement1);
    IArchimateElement newElement2 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(newElement2).getElements().add(newElement2);
    element = ArchimateModelUtils.getObjectByID(model, newElement1.getId());
    assertSame(newElement1, element);
    element = ArchimateModelUtils.getObjectByID(model, newElement2.getId());
    assertSame(newElement2, element);
}
Also used : EObject(org.eclipse.emf.ecore.EObject) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Example 5 with IArchimateModel

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

the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept_NotNull.

@Test
public void testGetAllRelationshipsForConcept_NotNull() {
    IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
    model.setDefaults();
    IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
    model.getDefaultFolderForObject(element1).getElements().add(element1);
    IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
    model.getDefaultFolderForObject(element2).getElements().add(element2);
    assertNotNull(ArchimateModelUtils.getAllRelationshipsForConcept(element1));
    assertNotNull(ArchimateModelUtils.getAllRelationshipsForConcept(element2));
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateModel(com.archimatetool.model.IArchimateModel) Test(org.junit.Test)

Aggregations

IArchimateModel (com.archimatetool.model.IArchimateModel)124 Test (org.junit.Test)51 File (java.io.File)35 IOException (java.io.IOException)22 IArchimateElement (com.archimatetool.model.IArchimateElement)14 EObject (org.eclipse.emf.ecore.EObject)14 IArchiveManager (com.archimatetool.editor.model.IArchiveManager)13 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)13 IDiagramModel (com.archimatetool.model.IDiagramModel)12 CommandStack (org.eclipse.gef.commands.CommandStack)11 IFolder (com.archimatetool.model.IFolder)10 ArrayList (java.util.ArrayList)10 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)9 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)9 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)7 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)6 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)6 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)5 IIdentifier (com.archimatetool.model.IIdentifier)5 GraficoModelLoader (org.archicontribs.modelrepository.grafico.GraficoModelLoader)5