diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/java/JavaInputConverter.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/java/JavaInputConverter.java index 1fea808ff3..7b8fc29a6f 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/java/JavaInputConverter.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/generator/java/JavaInputConverter.java @@ -62,7 +62,11 @@ public static List convertInput(List javaElements, InputInterpre // Take first input type as precondition for the input is that all input types are part of the // same project try { - IType rootType = ((ICompilationUnit) elem).getTypes()[0]; + IType[] types = ((ICompilationUnit) elem).getTypes(); + if (types.length < 1) { + throw new GeneratorCreationException("The input does not declare a class"); + } + IType rootType = types[0]; try { ClassLoader projectClassLoader = ClassLoaderUtil.getProjectClassLoader(rootType.getJavaProject()); diff --git a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java index a751e655ab..81a23c073d 100644 --- a/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java +++ b/cobigen-eclipse/cobigen-eclipse/src/com/devonfw/cobigen/eclipse/workbenchcontrol/handler/GenerateJob.java @@ -77,10 +77,11 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte monitor.beginTask("Searching valid triggers...", 1); if (!generator.isValidInput(monitor)) { LOG.info("No matching Trigger. Exiting generate command."); - MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "No matching Trigger!", - "Your current selection is not valid as input for any generation purpose. " - + "Please find the specification of valid inputs in the context configuration ('" - + ResourceConstants.CONFIG_PROJECT_NAME + "/context.xml')."); + PlatformUIUtil.getWorkbench().getDisplay().syncExec( + () -> MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "No matching Trigger!", + "Your current selection is not valid as input for any generation purpose. " + + "Please find the specification of valid inputs in the context configuration ('" + + ResourceConstants.CONFIG_PROJECT_NAME + "/context.xml').")); return; } monitor.worked(1);