Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Freeze into Develop #1005

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ private List<ConDeploymentDest> getSubappInterfaceconnections(final Deque<SubApp
final ArrayList<ConDeploymentDest> retVal = new ArrayList<>();
if (destination.isIsInput()) {
// we are entering a subapplication
final String newPrefix = prefix + destination.getFBNetworkElement().getName() + "."; //$NON-NLS-1$

final String newPrefix = (prefix.isEmpty() ? // if the prefix is empty we need to add mapping info
getMappedParentName(destination.getFBNetworkElement()) : prefix)
+ destination.getFBNetworkElement().getName() + "."; //$NON-NLS-1$
subAppHierarchy.addLast((SubApp) destination.getFBNetworkElement());
final IInterfaceElement internalElement = getSubAppInteralElement(destination);
if (null != internalElement) {
Expand All @@ -271,8 +274,8 @@ private List<ConDeploymentDest> getSubappInterfaceconnections(final Deque<SubApp
subAppHierarchy.removeLast();
} else {
// we are leaving a subapp
final String newPrefix = removeLastEntry(prefix);
final SubApp currentSubApp = subAppHierarchy.removeLast();
final String newPrefix = subAppHierarchy.isEmpty() ? "" : removeLastEntry(prefix, currentSubApp.getName()); //$NON-NLS-1$
final IInterfaceElement internalElement = currentSubApp.getInterfaceElement(destination.getName());
for (final Connection con : internalElement.getOutputConnections()) {
retVal.addAll(getConnectionEndPoint(subAppHierarchy, newPrefix, con.getDestination()));
Expand Down Expand Up @@ -301,10 +304,10 @@ private static IInterfaceElement getSubAppInteralElement(final IInterfaceElement
return null;
}

private static String removeLastEntry(final String prefix) {
final int index = prefix.lastIndexOf('.', prefix.length() - 2);
if (-1 != index) {
return prefix.substring(0, index + 1);
private static String removeLastEntry(final String prefix, final String lastEntryName) {
final int newEnd = prefix.length() - lastEntryName.length() - 1;
if (newEnd > 0) {
return prefix.substring(0, newEnd);
}
return ""; //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public VariableEditorConfiguration(final IRowDataProvider<? extends Variable<?>>

@Override
public void configureRegistry(final IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new VariableCellEditor(dataProvider),
DisplayMode.EDIT, VARIABLE_VALUE_CELL);
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
new VariableCellEditor(dataProvider, true), DisplayMode.EDIT, VARIABLE_VALUE_CELL);
configRegistry.registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR,
new VariableDataValidator(dataProvider), DisplayMode.EDIT, VARIABLE_VALUE_CELL);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2024 Primetals Technologies Austria GmbH
* Copyright (c) 2024, 2025 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 All @@ -22,7 +22,6 @@
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibraryManager;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibraryTags;
import org.eclipse.fordiac.ide.ui.FordiacLogHelper;

Expand All @@ -45,7 +44,8 @@ public void resourceChanged(final IResourceChangeEvent event) {
private final IResourceDeltaVisitor visitor = delta -> {
switch (delta.getResource().getType()) {
case IResource.PROJECT:
return delta.getKind() != IResourceDelta.REMOVED; // ignore deleted projects
// ignore closed or deleted projects
return !(isProjectClosed(delta) || delta.getKind() == IResourceDelta.REMOVED);
case IResource.FILE:
// check manifest files
// information on previous linked status is not available on delete
Expand All @@ -56,7 +56,7 @@ public void resourceChanged(final IResourceChangeEvent event) {
|| ((file.isLinked() || delta.getKind() == IResourceDelta.REMOVED)
&& (delta.getKind() & MASK) != 0))) {
final IProject project = file.getProject();
LibraryManager.INSTANCE.startResolveJob(project, TypeLibraryManager.INSTANCE.getTypeLibrary(project));
LibraryManager.INSTANCE.startResolveJob(project);

}
return false;
Expand All @@ -73,6 +73,12 @@ public void resourceChanged(final IResourceChangeEvent event) {
return true;
};

private static boolean isProjectClosed(final IResourceDelta delta) {
return (delta.getKind() != IResourceDelta.CHANGED
&& (delta.getFlags() & IResourceDelta.OPEN) == IResourceDelta.OPEN
&& !delta.getResource().isAccessible());
}

private static boolean isTypeLibraryFolder(final IContainer container) {
return container instanceof IFolder && container.getParent() instanceof IProject
&& (TypeLibraryTags.STANDARD_LIB_FOLDER_NAME.equals(container.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public void importLibrary(final IProject project, final TypeLibrary typeLibrary,
addLibraryChangeListener();
// dependency resolution
if (resolve && imported) {
startResolveJob(project, typeLibrary);
startResolveJob(project);
}
}

Expand Down Expand Up @@ -599,28 +599,26 @@ public Map<String, List<LibraryRecord>> getExtractedLibraries() {
* <p>
* Will download/import libraries as needed through background jobs
*
* @param project selected project
* @param typeLibrary {@link TypeLibrary} to use
* @param project selected project
*/
public void checkManifestFile(final IProject project, final TypeLibrary typeLibrary) {
public void checkManifestFile(final IProject project) {
final Manifest manifest = ManifestHelper.getContainerManifest(project);
if (manifest == null || !ManifestHelper.isProject(manifest)) {
return;
}

ManifestHelper.sortAndSaveManifest(manifest);

startResolveJob(project, typeLibrary);
startResolveJob(project);
}

/**
* Start background job that resolves transitive library dependencies of
* {@link IProject}
*
* @param project selected project
* @param typeLibrary {@link TypeLibrary} to use
* @param project selected project
*/
public void startResolveJob(final IProject project, final TypeLibrary typeLibrary) {
public void startResolveJob(final IProject project) {
if (resolvingProjects.contains(project)) {
return;
}
Expand All @@ -630,7 +628,10 @@ public void startResolveJob(final IProject project, final TypeLibrary typeLibrar

@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
resolveDependencies(project, typeLibrary);
if (project.isAccessible()) {
// only resolve if we have an accessible project
resolveDependencies(project, TypeLibraryManager.INSTANCE.getTypeLibrary(project));
}
return Status.OK_STATUS;
}

Expand Down Expand Up @@ -752,8 +753,8 @@ public void resolveDependencies(final IProject project, final TypeLibrary typeLi

checkLibChanges();

// remove when no longer needed
moveLinksToVirtualFolders(project, typeLibrary);
// TODO this is for migrating old projects: remove when no longer needed
moveLinksToVirtualFolders(project);

if (projectManifest.getDependencies() == null) {
return;
Expand Down Expand Up @@ -963,7 +964,7 @@ private ResolveNode resolveDependency(final String symbolicName, final VersionRa
* @param project selected project
* @param typeLibrary {@link TypeLibrary} to use
*/
private void moveLinksToVirtualFolders(final IProject project, final TypeLibrary typeLibrary) {
private void moveLinksToVirtualFolders(final IProject project) {
if (project.getFolder(TypeLibraryTags.STANDARD_LIB_FOLDER_NAME).exists()) {
return;
}
Expand Down Expand Up @@ -1103,7 +1104,7 @@ void stopEventBroker() {
private final EventHandler handler = event -> {
final Object data = event.getProperty(IEventBroker.DATA);
if (data instanceof final TypeLibrary typeLibrary) {
checkManifestFile(typeLibrary.getProject(), typeLibrary);
checkManifestFile(typeLibrary.getProject());
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2024 TU Wien ACIN, Profactor GmbH, fortiss GmbH,
* Copyright (c) 2012, 2025 TU Wien ACIN, Profactor GmbH, fortiss GmbH,
* Johannes Kepler University Linz,
* Primetals Technologies Austria GmbH,
* Martin Erich Jobst
Expand All @@ -20,7 +20,6 @@
*******************************************************************************/
package org.eclipse.fordiac.ide.systemmanagement.changelistener;

import java.text.MessageFormat;
import java.util.Collection;
import java.util.HashSet;
import java.util.Scanner;
Expand Down Expand Up @@ -147,12 +146,9 @@ private boolean handleResourceChanged(final IResourceDelta delta) {
}
break;
case IResource.PROJECT:
if (testFlags(delta, IResourceDelta.OPEN)) {
if (delta.getResource().isAccessible()) {
handleProjectAdd(delta);
} else {
handleProjectRemove(delta);
}
if (testFlags(delta, IResourceDelta.OPEN) && !delta.getResource().isAccessible()) {
// this is the odd way of Eclipse Platform telling us a project was closed
handleProjectRemove(delta);
return false;
}
break;
Expand Down Expand Up @@ -220,17 +216,10 @@ private boolean handleResourceCopy(final IResourceDelta delta) {
return false;
}

return switch (delta.getResource().getType()) {
case IResource.FILE -> {
if (delta.getResource().getType() == IResource.FILE) {
handleFileCopy(delta);
yield true;
}
case IResource.PROJECT -> {
handleProjectAdd(delta);
yield false;
}
default -> true;
};
return true;
}

private void handleFileDelete(final IResourceDelta delta) {
Expand Down Expand Up @@ -270,9 +259,8 @@ private void handleFileCopy(final IResourceDelta delta) {
final TypeEntry entry = typeLib.createTypeEntry(file);
if (null != entry && containedTypeNameIsDifferent(file)) {
// we only need to update the type entry if the file content is different from
// the file name
// this happens when a type is copied into a new project or when a project is
// opened or imported
// the file name this happens when a type is copied into a new project or when a
// project is opened or imported
updateTypeEntry(file, entry);
return;
}
Expand All @@ -284,9 +272,8 @@ private void handleFileCopy(final IResourceDelta delta) {
}
} else if (!file.equals(typeEntryForFile.getFile())) {
// After a file has been copied and the copied file is not the same as the
// founded type entry
// the file and the resulting type must be renamed with a unique name put it in
// the rename list
// founded type entry the file and the resulting type must be renamed with a
// unique name put it in the rename list
filesToRename.add(new FileToRenameEntry(file, typeEntryForFile));
}
}
Expand Down Expand Up @@ -510,31 +497,6 @@ public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreExcepti
job.schedule();
}

private void handleProjectAdd(final IResourceDelta delta) {
final IProject project = delta.getResource().getProject();
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);

final WorkspaceJob job = new WorkspaceJob(MessageFormat
.format(Messages.FordiacResourceChangeListener_UpdateTypeLibForNewProject, project.getName())) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
try {
// ensure dirty workspaces are cleaned before any type library is loaded
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (final CoreException e) {
FordiacLogHelper.logError(e.getMessage(), e);
}
ResourcesPlugin.getWorkspace().addResourceChangeListener(FordiacResourceChangeListener.this);
return Status.OK_STATUS;
}
};
job.setUser(false);
job.setSystem(true);
job.setPriority(Job.INTERACTIVE); // give this job the highest possible priority
job.setRule(project);
job.schedule();
}

private static void handleProjectRemove(final IResourceDelta delta) {
final IProject project = delta.getResource().getProject();
closeAllProjectRelatedEditors(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void testCheckManifest() throws Exception {
ManifestHelper.addDependency(manifest, ManifestHelper.createRequired(TEST01, "[1.0.0-2.0.0)")); //$NON-NLS-1$
ManifestHelper.saveManifest(manifest);

LibraryManager.INSTANCE.checkManifestFile(project, TypeLibraryManager.INSTANCE.getTypeLibrary(project));
LibraryManager.INSTANCE.checkManifestFile(project);
Job.getJobManager().join(LibraryManager.FAMILY_FORDIAC_LIBRARY, null);

manifest = ManifestHelper.getContainerManifest(project);
Expand Down
Loading