From 4fabff7942caeab5dcd7bf601f8d947850606530 Mon Sep 17 00:00:00 2001 From: Johannes Dicks Date: Wed, 15 Jun 2016 00:40:22 +0200 Subject: [PATCH] #765 : if no default domain could be found and just a single domain is available, the available domain will be used --- .../yakindu/sct/domain/extension/DomainRegistry.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java b/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java index 9185da1c0f..ab18430b61 100644 --- a/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java +++ b/plugins/org.yakindu.sct.domain/src/org/yakindu/sct/domain/extension/DomainRegistry.java @@ -139,7 +139,10 @@ public boolean apply(IDomainDescriptor input) { }); } catch (NoSuchElementException e) { if (defaultDomainID.equals(id)) { - throw new IllegalArgumentException("No default domain found!"); + if (getDomainDescriptors().size() == 1) + return getDomainDescriptors().get(0); + else + throw new IllegalArgumentException("No default domain found!"); } System.err.println("Could not find domain descriptor for id " + id + " - > using default domain"); return getDomainDescriptor(defaultDomainID); @@ -153,7 +156,7 @@ public static IDomainDescriptor getDomainDescriptor(EObject object) { : BasePackage.Literals.DOMAIN_ELEMENT__DOMAIN_ID.getDefaultValueLiteral(); return getDomainDescriptor(domainID); } - + public static String determineDomainID(URI uri) { String result = BasePackage.Literals.DOMAIN_ELEMENT__DOMAIN_ID.getDefaultValueLiteral(); if (URIConverter.INSTANCE.exists(uri, null)) { @@ -171,6 +174,9 @@ public static String determineDomainID(URI uri) { resource.unload(); } } + // in special case a default domain is not available + if (getDomainDescriptors().size() == 1 && !result.equals(getDomainDescriptors().get(0).getDomainID())) + result = getDomainDescriptors().get(0).getDomainID(); return result; } }