Skip to content

Commit

Permalink
Merge pull request eclipse-4diac#445 from eclipse-4diac/freeze
Browse files Browse the repository at this point in the history
Merge Freeze into Develop
  • Loading branch information
azoitl authored Sep 3, 2024
2 parents b5cf144 + 59efae2 commit 10871fa
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IWorkbenchPartConstants;
import org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor;
import org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess;
import org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider;
Expand All @@ -52,6 +53,7 @@ public class STBreakpointConditionEditor {
private EmbeddedEditorModelAccess conditionEditorModelAccess;

private boolean dirty;
private boolean suppressPropertyChanges;

public Control createControl(final Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
Expand Down Expand Up @@ -86,8 +88,8 @@ protected void createConditionEditor(final Composite parent) {
conditionEditor.getDocument().addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(final DocumentEvent event) {
dirty = true;
firePropertyChange(PROP_CONDITION);
setDirty(true);
}

@Override
Expand Down Expand Up @@ -117,12 +119,17 @@ protected void updateConditionEditor() {
}

public void setInput(final STLineBreakpoint input) {
this.input = input;
conditional.setEnabled(input != null);
conditional.setSelection(input != null && input.isConditionEnabled());
conditionEditor.getViewer().setEditable(input != null && input.isConditionEnabled());
updateConditionEditor();
setDirty(false);
try {
suppressPropertyChanges = true;
this.input = input;
conditional.setEnabled(input != null);
conditional.setSelection(input != null && input.isConditionEnabled());
conditionEditor.getViewer().setEditable(input != null && input.isConditionEnabled());
updateConditionEditor();
setDirty(false);
} finally {
suppressPropertyChanges = false;
}
}

public void doSave() {
Expand All @@ -142,7 +149,10 @@ public boolean isDirty() {
}

public void setDirty(final boolean dirty) {
this.dirty = dirty;
if (dirty != this.dirty) {
this.dirty = dirty;
firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY);
}
}

public boolean setFocus() {
Expand All @@ -162,8 +172,10 @@ public void removePropertyListener(final IPropertyListener listener) {
}

protected void firePropertyChange(final int property) {
for (final IPropertyListener listener : listeners) {
listener.propertyChanged(this, property);
if (!suppressPropertyChanges) {
for (final IPropertyListener listener : listeners) {
listener.propertyChanged(this, property);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public Control createControl(final Composite parent) {

editor = new STBreakpointConditionEditor();
editor.addPropertyListener((source, propId) -> {
editor.doSave();
if (propId == STBreakpointConditionEditor.PROP_CONDITION_ENABLED) {
editor.doSave(); // autosave only for condition enabled changes
}
firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY);
});
editor.createControl(comp);
Expand All @@ -58,8 +60,9 @@ public Control createControl(final Composite parent) {

@Override
public void display(final IStructuredSelection selection) {
if (selection != null && selection.size() == 1 && selection.getFirstElement() instanceof STLineBreakpoint) {
editor.setInput((STLineBreakpoint) selection.getFirstElement());
if (selection != null && selection.size() == 1
&& selection.getFirstElement() instanceof final STLineBreakpoint lineBreakpoint) {
editor.setInput(lineBreakpoint);
} else {
editor.setInput(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ static Function<VarDeclaration, String> getVariableValueRetargetable(final VarDe
}

static boolean hasTypeInitialValue(final SubApp subApp, final VarDeclaration varDec) {
final Optional<VarDeclaration> dec = subApp.getType().getInterfaceList().getInputVars().stream()
.filter(v -> v.getName().contentEquals(varDec.getName())).findAny();
if (dec.isPresent()) {
return DeploymentHelper.hasInitalValue(dec.get());
if (subApp.isTyped()) {
final Optional<VarDeclaration> dec = subApp.getType().getInterfaceList().getInputVars().stream()
.filter(v -> v.getName().contentEquals(varDec.getName())).findAny();
if (dec.isPresent()) {
return DeploymentHelper.hasInitalValue(dec.get());
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.eclipse.fordiac.ide.model.datatype.helper.IecTypes.GenericTypes
import org.eclipse.fordiac.ide.model.datatype.helper.RetainHelper.RetainTag
import org.eclipse.fordiac.ide.model.libraryElement.AdapterDeclaration
import org.eclipse.fordiac.ide.model.libraryElement.BaseFBType
import org.eclipse.fordiac.ide.model.libraryElement.ConfigurableFB
import org.eclipse.fordiac.ide.model.libraryElement.Event
import org.eclipse.fordiac.ide.model.libraryElement.FB
import org.eclipse.fordiac.ide.model.libraryElement.FBType
Expand Down Expand Up @@ -589,10 +590,17 @@ abstract class ForteFBTemplate<T extends FBType> extends ForteLibraryElementTemp
def generateInternalFBInitializer(FB fb) {
if (fb.type.genericType)
'''«fb.generateName»(«fb.name.FORTEStringId», "«fb.type.generateTypeNamePlain»", *this)'''
'''«fb.generateName»(«fb.name.FORTEStringId», "«fb.generateInternalFBConfigString»", *this)'''
else
'''«fb.generateName»(«fb.name.FORTEStringId», *this)'''
}
def generateInternalFBConfigString(FB fb) {
switch(fb) {
ConfigurableFB: '''«fb.type.generateTypeNamePlain»_1«fb.dataType.generateTypeNamePlain»'''
default: fb.type.generateTypeNamePlain
}
}
override Set<INamedElement> getDependencies(Map<?, ?> options) {
(super.getDependencies(options) + (type.interfaceList.sockets + type.interfaceList.plugs).map[getType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.URI;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -75,8 +74,9 @@ static void setupBeforeClass() throws Exception {

final Bundle bundle = Platform.getBundle("org.eclipse.fordiac.ide.test.library"); //$NON-NLS-1$
for (final var archive : archives) {
final URL url = FileLocator.toFileURL(FileLocator.find(bundle, new Path(archive)));
final var uri = new URI(url.toString().replace(" ", "%20")); //$NON-NLS-1$//$NON-NLS-2$
final var url = FileLocator.toFileURL(FileLocator.find(bundle, new Path(archive)));
final var uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getFile(),
url.getQuery(), url.getRef());
LibraryManager.INSTANCE.extractLibrary(Paths.get(uri), null, false, false);
}

Expand Down

0 comments on commit 10871fa

Please sign in to comment.