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;
}
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);
}
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());
}
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);
}
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));
}
Aggregations