diff --git a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/UnfoldedSubappContentEditPart.java b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/UnfoldedSubappContentEditPart.java index b1012707be..1ac8d51d42 100644 --- a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/UnfoldedSubappContentEditPart.java +++ b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/editparts/UnfoldedSubappContentEditPart.java @@ -17,12 +17,18 @@ package org.eclipse.fordiac.ide.application.editparts; +import org.eclipse.draw2d.Figure; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.XYLayout; +import org.eclipse.draw2d.geometry.Insets; import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.util.EContentAdapter; import org.eclipse.fordiac.ide.application.commands.ResizeGroupOrSubappCommand; import org.eclipse.fordiac.ide.application.policies.SubAppContentLayoutEditPolicy; +import org.eclipse.fordiac.ide.model.CoordinateConverter; import org.eclipse.fordiac.ide.model.commands.create.AbstractCreateFBNetworkElementCommand; import org.eclipse.fordiac.ide.model.libraryElement.LibraryElementPackage; import org.eclipse.fordiac.ide.model.libraryElement.SubApp; @@ -80,6 +86,40 @@ protected Command getElementCreateCommand(final TypeEntry value, final Point ref }); } + @Override + protected IFigure createFigure() { + final IFigure figure = new Figure() { + Insets offsetInset = new Insets(); + + @Override + public void setBounds(final Rectangle rect) { + final Rectangle copy = rect.getCopy(); + final Rectangle clientArea = getParent().getClientArea(); + final int maxAvailableHeight = clientArea.height - (rect.y - clientArea.y); + // expand content to the available subapp size + copy.height = Math.max(rect.height, maxAvailableHeight); + + final int lineHeight = (int) CoordinateConverter.INSTANCE.getLineHeight(); + // ensure that the content is aligned on the grid in x direction. We have to do + // that here to compensate for different interface bar widths and also to + // compensate changing interface bar widths. + final int offset = lineHeight - copy.x % lineHeight; + offsetInset.left = offset; + offsetInset.right = offset; + super.setBounds(copy); + } + + @Override + public Insets getInsets() { + return offsetInset; + } + }; + + figure.setOpaque(true); + figure.setLayoutManager(new XYLayout()); + return figure; + } + @Override public SubApp getContainerElement() { return (SubApp) getModel().eContainer(); diff --git a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/figures/SubAppForFbNetworkFigure.java b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/figures/SubAppForFbNetworkFigure.java index 2693fa7cc8..54a81bc103 100644 --- a/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/figures/SubAppForFbNetworkFigure.java +++ b/plugins/org.eclipse.fordiac.ide.application/src/org/eclipse/fordiac/ide/application/figures/SubAppForFbNetworkFigure.java @@ -195,20 +195,7 @@ private void createExpandedMainFigure() { } private void createContentContainer() { - expandedContentArea = new Figure() { - @Override - public void setBounds(final Rectangle rect) { - final Rectangle copy = rect.getCopy(); - final int lineHeight = (int) CoordinateConverter.INSTANCE.getLineHeight(); - // ensure that the content is aligned on the grid in x direction. We have to do - // that here to compensate for different interface bar widths and also to - // compensate changing interface bar widths. - final int offset = lineHeight - copy.x % lineHeight; - copy.x += offset; - copy.width -= offset; - super.setBounds(copy); - } - }; + expandedContentArea = new Figure(); final GridLayout expContentLayout = new GridLayout(); expContentLayout.marginHeight = 0; expContentLayout.marginWidth = 0; diff --git a/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/plugin.xml b/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/plugin.xml index c5dcbe7aa7..aa5f8a2e85 100644 --- a/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/plugin.xml +++ b/plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/plugin.xml @@ -33,6 +33,9 @@ point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + + @@ -42,6 +45,21 @@ point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + + + + + + + + + + + + + + + + + newVariable(final String name, final INamedElement typ } public static Variable newVariable(final String name, final Value value) { - return newVariable(name, value.getType(), value); + return switch (value.getType()) { + case final DataType dataType when GenericTypes.isAnyType(dataType) -> throw new UnsupportedOperationException( + MessageFormat.format(Messages.VariableOperations_UnsupportedType, name, value.getType().getName())); + case null -> throw new NullPointerException(Messages.VariableOperations_TypeMustNotBeNull); + default -> newVariable(name, value.getType(), value); + }; } public static Variable newVariable(final ITypedElement element) throws EvaluatorException { diff --git a/plugins/org.eclipse.fordiac.ide.model.ui/src/org/eclipse/fordiac/ide/model/ui/editors/GraphicalViewerNavigationLocationData.java b/plugins/org.eclipse.fordiac.ide.model.ui/src/org/eclipse/fordiac/ide/model/ui/editors/GraphicalViewerNavigationLocationData.java index 5fe72a3690..7a75842477 100644 --- a/plugins/org.eclipse.fordiac.ide.model.ui/src/org/eclipse/fordiac/ide/model/ui/editors/GraphicalViewerNavigationLocationData.java +++ b/plugins/org.eclipse.fordiac.ide.model.ui/src/org/eclipse/fordiac/ide/model/ui/editors/GraphicalViewerNavigationLocationData.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Primetals Technologies Austria GmbH + * Copyright (c) 2021, 2024 Primetals Technologies Austria GmbH * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -31,16 +31,18 @@ public GraphicalViewerNavigationLocationData(final GraphicalViewer viewer) { } public void restoreGraphicalViewerData(final EditPartViewer viewer) { - if (viewer.getRootEditPart() instanceof ScalableFreeformRootEditPart) { - ((ScalableFreeformRootEditPart) viewer.getRootEditPart()).getZoomManager().setZoom(zoom); + if (viewer.getRootEditPart() instanceof final ScalableFreeformRootEditPart rootEP) { + rootEP.getZoomManager().setZoom(zoom); } - if (viewer.getControl() instanceof FigureCanvas) { - final FigureCanvas canvas = (FigureCanvas) viewer.getControl(); - // we have to wait to set the scroll position until the editor is drawn and the canvas is setup - if (!canvas.isDisposed()) { - Display.getDefault().asyncExec(() -> canvas.scrollTo(location.x, location.y)); - } + // we have to wait to set the scroll position until the editor is drawn and the + // canvas is setup + if ((viewer.getControl() instanceof final FigureCanvas canvas) && !canvas.isDisposed()) { + Display.getDefault().asyncExec(() -> { + if (!canvas.isDisposed()) { + canvas.scrollTo(location.x, location.y); + } + }); } } @@ -63,15 +65,14 @@ public boolean equals(final Object obj) { } private static double getCurrentZoom(final GraphicalViewer viewer) { - if (viewer.getRootEditPart() instanceof ScalableFreeformRootEditPart) { - return ((ScalableFreeformRootEditPart) viewer.getRootEditPart()).getZoomManager().getZoom(); + if (viewer.getRootEditPart() instanceof final ScalableFreeformRootEditPart rootEP) { + return rootEP.getZoomManager().getZoom(); } return 1.0; } private static Point getViewerLocation(final GraphicalViewer viewer) { - if (viewer.getControl() instanceof FigureCanvas) { - final FigureCanvas canvas = (FigureCanvas) viewer.getControl(); + if (viewer.getControl() instanceof final FigureCanvas canvas) { return canvas.getViewport().getViewLocation(); } return new Point(0, 0); diff --git a/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/dataimport/CommonElementImporter.java b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/dataimport/CommonElementImporter.java index 3c3abbb02d..e9b0052cbc 100644 --- a/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/dataimport/CommonElementImporter.java +++ b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/dataimport/CommonElementImporter.java @@ -435,7 +435,9 @@ protected void parseGenericAttributeNode(final ConfigurableObject confObject) } } else { // AttributeDeclarations - final AttributeTypeEntry entry = ImportHelper.resolveImport(attribute.getName(), confObject, + // use element for resolving import since confObject may not have been added to + // enclosing type yet + final AttributeTypeEntry entry = ImportHelper.resolveImport(attribute.getName(), getElement(), name -> getTypeLibrary().getAttributeTypeEntry(name), name -> null); final AttributeTypeEntry attributeTypeEntry = addDependency(entry); if (attributeTypeEntry != null && attributeTypeEntry.getType() != null) { diff --git a/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/libraryElement/impl/TypedElementAnnotations.java b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/libraryElement/impl/TypedElementAnnotations.java index 9146ab2efc..54d8ffb54c 100644 --- a/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/libraryElement/impl/TypedElementAnnotations.java +++ b/plugins/org.eclipse.fordiac.ide.model/src/org/eclipse/fordiac/ide/model/libraryElement/impl/TypedElementAnnotations.java @@ -43,7 +43,7 @@ public static boolean validateType(final ITypedElement element, final Diagnostic && libraryElement.getTypeEntry() instanceof ErrorTypeEntry) { if (diagnostics != null) { diagnostics.add(createTypeValidationDiagnostic( - MessageFormat.format(Messages.TypedElementAnnotations_TypeNotFound, element.getTypeName()), + MessageFormat.format(Messages.TypedElementAnnotations_TypeNotFound, getFullTypeName(element)), element)); } return false; diff --git a/plugins/org.eclipse.fordiac.ide.structuredtextcore/src/org/eclipse/fordiac/ide/structuredtextcore/resource/STCoreResourceDescriptionStrategy.java b/plugins/org.eclipse.fordiac.ide.structuredtextcore/src/org/eclipse/fordiac/ide/structuredtextcore/resource/STCoreResourceDescriptionStrategy.java index b40cd80607..3721d9933a 100644 --- a/plugins/org.eclipse.fordiac.ide.structuredtextcore/src/org/eclipse/fordiac/ide/structuredtextcore/resource/STCoreResourceDescriptionStrategy.java +++ b/plugins/org.eclipse.fordiac.ide.structuredtextcore/src/org/eclipse/fordiac/ide/structuredtextcore/resource/STCoreResourceDescriptionStrategy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Martin Erich Jobst + * Copyright (c) 2023, 2024 Martin Erich Jobst * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -17,6 +17,8 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -44,7 +46,7 @@ import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy; import org.eclipse.xtext.util.IAcceptor; -import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ForwardingMap; /** * Resource description strategy for ST core and derivatives. @@ -82,9 +84,7 @@ public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor< try { final QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject); if (qualifiedName != null) { - final ImmutableMap.Builder builder = ImmutableMap.builder(); - fillUserData(eObject, builder); - acceptor.accept(EObjectDescription.create(qualifiedName, eObject, builder.build())); + acceptor.accept(EObjectDescription.create(qualifiedName, eObject, createLazyUserData(eObject))); } } catch (final Exception e) { LOG.error(e.getMessage(), e); @@ -92,21 +92,37 @@ public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor< return true; } + protected Map createLazyUserData(final EObject eObject) { + return new ForwardingMap<>() { + private Map delegate; + + @Override + protected Map delegate() { + if (delegate == null) { + final Map userData = new HashMap<>(); + fillUserData(eObject, userData); + delegate = Map.copyOf(userData); + } + return delegate; + } + }; + } + @SuppressWarnings("static-method") // subclasses may override - protected void fillUserData(final EObject eObject, final ImmutableMap.Builder builder) { + protected void fillUserData(final EObject eObject, final Map userData) { final EObject container = eObject.eContainer(); if (container != null) { - builder.put(CONTAINER_ECLASS_NAME, container.eClass().getName()); + userData.put(CONTAINER_ECLASS_NAME, container.eClass().getName()); } if (eObject instanceof final ICallable callable) { - builder.put(SIGNATURE_HASH, computeSignatureHash(callable)); - builder.put(DISPLAY_STRING, getCallableDisplayString(callable)); + userData.put(SIGNATURE_HASH, computeSignatureHash(callable)); + userData.put(DISPLAY_STRING, getCallableDisplayString(callable)); final STCoreRegionString regionString = getCallableParameterProposal(callable); - builder.put(PARAMETER_PROPOSAL, regionString.toString()); - builder.put(PARAMETER_PROPOSAL_REGIONS, regionString.getRegions().toString()); + userData.put(PARAMETER_PROPOSAL, regionString.toString()); + userData.put(PARAMETER_PROPOSAL_REGIONS, regionString.getRegions().toString()); } else if (eObject instanceof final ITypedElement typedElement && typedElement.getType() != null) { - builder.put(TYPE_URI, EcoreUtil.getURI(typedElement.getType()).toString()); - builder.put(DISPLAY_STRING, getTypedElementDisplayString(typedElement)); + userData.put(TYPE_URI, EcoreUtil.getURI(typedElement.getType()).toString()); + userData.put(DISPLAY_STRING, getTypedElementDisplayString(typedElement)); } } diff --git a/plugins/org.eclipse.fordiac.ide.subapptypeeditor/plugin.xml b/plugins/org.eclipse.fordiac.ide.subapptypeeditor/plugin.xml index 6eb0b438c5..f7b01f59e0 100644 --- a/plugins/org.eclipse.fordiac.ide.subapptypeeditor/plugin.xml +++ b/plugins/org.eclipse.fordiac.ide.subapptypeeditor/plugin.xml @@ -69,16 +69,6 @@ id="org.eclipse.fordiac.ide.application.propertyInterfaceTab" label="Instance"> - - - - - - - - - - - - - -