Skip to content

Commit

Permalink
Merge Freeze into Develop
Browse files Browse the repository at this point in the history
  • Loading branch information
azoitl authored Oct 15, 2024
2 parents 49bb054 + 919ee26 commit f4a6f5d
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 49 additions & 0 deletions plugins/org.eclipse.fordiac.ide.fbtypeeditor.network/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
<propertyContributor
contributorId="property.contributor.fb">
<propertyCategory
category="Config">
</propertyCategory>
<propertyCategory
category="FB-Network">
</propertyCategory>
Expand All @@ -42,6 +45,21 @@
point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs
contributorId="property.contributor.fb">
<propertyTab
category="Config"
id="org.eclipse.fordiac.ide.application.propertyStructManipulatorTab"
label="Struct Handling">
</propertyTab>
<propertyTab
category="Config"
id="org.eclipse.fordiac.ide.application.propertyDemultiplexerTab"
label="Struct Handling">
</propertyTab>
<propertyTab
category="Config"
id="org.eclipse.fordiac.ide.application.propertyConfigurableFBTab"
label="Config">
</propertyTab>
<propertyTab
category="FB-Network"
id="org.eclipse.fordiac.ide.fbnet.propertyInterfaceTab"
Expand All @@ -54,6 +72,7 @@
image="fordiacimage://ICON_FB_TYPE"
label="Type Info">
</propertyTab>

<propertyTab
category="FB-Network"
id="org.eclipse.fordiac.ide.fbnet.propertyInterfaceElementTab"
Expand All @@ -69,6 +88,12 @@
id="org.eclipse.fordiac.ide.fbnet.CreateConnection"
label="Create Connection">
</propertyTab>
<propertyTab
category="Interface"
id="org.eclipse.fordiac.ide.application.propertyStructInterfaceElementTab"
indented="false"
label="Struct Element">
</propertyTab>
<propertyTab
afterTab="org.eclipse.fordiac.ide.application.propertyInterfaceTab"
category="FB-Network"
Expand Down Expand Up @@ -99,6 +124,12 @@
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="property.contributor.fb">
<propertySection
class="org.eclipse.fordiac.ide.application.properties.ConfigurableMoveFBSection"
filter="org.eclipse.fordiac.ide.application.properties.ConfigurableMoveFBFilter"
id="org.eclipse.fordiac.ide.application.properties.ConfigurableFBSection"
tab="org.eclipse.fordiac.ide.application.propertyConfigurableFBTab">
</propertySection>
<propertySection
class="org.eclipse.fordiac.ide.application.properties.InstancePropertySection"
filter="org.eclipse.fordiac.ide.application.properties.InstanceSectionFilter"
Expand Down Expand Up @@ -138,6 +169,24 @@
id="org.eclipse.fordiac.ide.fbnet.properties.ConnectionSection"
tab="org.eclipse.fordiac.ide.fbnet.propertyConnectionTab">
</propertySection>
<propertySection
class="org.eclipse.fordiac.ide.application.properties.DemultiplexerSection"
id="org.eclipse.fordiac.ide.application.properties.DemultiplexerSection"
tab="org.eclipse.fordiac.ide.application.propertyDemultiplexerTab"
filter="org.eclipse.fordiac.ide.application.properties.DemultiplexerFilter">
</propertySection>
<propertySection
class="org.eclipse.fordiac.ide.application.properties.MultiplexerSection"
id="org.eclipse.fordiac.ide.application.properties.MultiplexerSection"
tab="org.eclipse.fordiac.ide.application.propertyStructManipulatorTab"
filter="org.eclipse.fordiac.ide.application.properties.MultiplexerFilter">
</propertySection>
<propertySection
class="org.eclipse.fordiac.ide.application.properties.InterfaceElementSection"
filter="org.eclipse.fordiac.ide.application.properties.StructInterfacePinFilter"
id="org.eclipse.fordiac.ide.application.properties.StructInterfaceElementSection"
tab="org.eclipse.fordiac.ide.application.propertyStructInterfaceElementTab">
</propertySection>
</propertySections>
</extension>
<extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ public static Variable<?> 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}
});
}

}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -82,31 +84,45 @@ public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor<
try {
final QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(eObject);
if (qualifiedName != null) {
final ImmutableMap.Builder<String, String> 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);
}
return true;
}

protected Map<String, String> createLazyUserData(final EObject eObject) {
return new ForwardingMap<>() {
private Map<String, String> delegate;

@Override
protected Map<String, String> delegate() {
if (delegate == null) {
final Map<String, String> 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<String, String> builder) {
protected void fillUserData(final EObject eObject, final Map<String, String> 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));
}
}

Expand Down
Loading

0 comments on commit f4a6f5d

Please sign in to comment.