Skip to content

Commit

Permalink
Merge pull request eclipse-4diac#92 from eclipse-4diac/freeze
Browse files Browse the repository at this point in the history
Merge Freeze back to Develop
  • Loading branch information
azoitl authored Apr 26, 2024
2 parents 0f9f2c1 + df6e0f1 commit c6ec115
Show file tree
Hide file tree
Showing 28 changed files with 678 additions and 122 deletions.
3 changes: 2 additions & 1 deletion plugins/org.eclipse.fordiac.ide.ant/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.fordiac.ide.export.forte_ng,
org.eclipse.fordiac.ide.export,
org.eclipse.fordiac.ide.typemanagement,
org.eclipse.fordiac.ide.export.xmi
org.eclipse.fordiac.ide.export.xmi,
org.eclipse.fordiac.ide.library.model
Bundle-Vendor: Eclipse 4diac
Bundle-ActivationPolicy: lazy
16 changes: 16 additions & 0 deletions plugins/org.eclipse.fordiac.ide.ant/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@
name="fordiac.saveBlock">
</antTask>
</extension>
<extension
point="org.eclipse.ant.core.antTasks">
<antTask
class="org.eclipse.fordiac.ide.ant.ant.ExportProjectLibrary"
library="ant_tasks/ant-ant.jar"
name="fordiac.exportProjectLibrary">
</antTask>
</extension>
<extension
point="org.eclipse.ant.core.antTasks">
<antTask
class="org.eclipse.fordiac.ide.ant.ant.ExportProjectLibraries"
library="ant_tasks/ant-ant.jar"
name="fordiac.exportProjectLibraries">
</antTask>
</extension>
<extension
point="org.eclipse.ant.core.extraClasspathEntries">
<extraClasspathEntry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Aigner
* - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.fordiac.ide.ant.ant;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.fordiac.ide.library.model.library.Manifest;
import org.eclipse.fordiac.ide.library.model.util.ManifestHelper;

public class ExportProjectLibraries extends Task {
private static final String ANT_EXPORT_TASK_DIRECTORY_NAME = "exported_FBs"; //$NON-NLS-1$

private String projectName;
private String exportDirectory = ANT_EXPORT_TASK_DIRECTORY_NAME;
private boolean exportCMakeList = false;
private boolean preserveDirectoryStructure = false;

public void setProjectName(final String value) {
projectName = value;
}

public void setExportDirectory(final String value) {
exportDirectory = value;
}

public void setExportCMakeList(final boolean value) {
exportCMakeList = value;
}

public void setPreserveDirectoryStructure(final boolean preserveDirectoryStructure) {
this.preserveDirectoryStructure = preserveDirectoryStructure;
}

@Override
public void execute() throws BuildException {
if (projectName == null) {
throw new BuildException("Project name not specified!"); //$NON-NLS-1$
}
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject fordiacProject = workspace.getRoot().getProject(projectName);

final Manifest manifest = ManifestHelper.getContainerManifest(fordiacProject);
if (manifest == null) {
throw new BuildException("Project named '" + projectName + "' lacks a manifest file"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (manifest.getExports() == null) {
throw new BuildException("No exports present in manifest file"); //$NON-NLS-1$
}
if (manifest.getExports().getLibrary().isEmpty()) {
throw new BuildException("No libraries defined in manifest file"); //$NON-NLS-1$
}

manifest.getExports().getLibrary().forEach(lib -> {
final ExportProjectLibrary libexport = new ExportProjectLibrary();
libexport.setProjectName(projectName);
libexport.setExportDirectory(exportDirectory);
libexport.setExportCMakeList(exportCMakeList);
libexport.setPreserveDirectoryStructure(preserveDirectoryStructure);
libexport.setSymbolicName(lib.getSymbolicName());

log("Exporting library: " + lib.getSymbolicName()); //$NON-NLS-1$
libexport.execute();
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*******************************************************************************
* Copyright (c) 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
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Aigner
* - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.fordiac.ide.ant.ant;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.apache.tools.ant.BuildException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.fordiac.ide.library.model.library.Library;
import org.eclipse.fordiac.ide.library.model.library.Manifest;
import org.eclipse.fordiac.ide.library.model.util.ManifestHelper;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibrary;
import org.eclipse.fordiac.ide.model.typelibrary.TypeLibraryManager;

public class ExportProjectLibrary extends AbstractExportFBs {
private static String starPattern = "(_[a-zA-Z0-9]|[a-zA-Z])(_?[a-zA-Z0-9])*"; //$NON-NLS-1$
private static String doubleStarPattern = starPattern + "(::" + starPattern + ")*"; //$NON-NLS-1$ //$NON-NLS-2$
private static Pattern replacePattern = Pattern.compile("\\*\\*|\\*"); //$NON-NLS-1$

private String symbolicName;
private List<Pattern> includePatterns;
private List<Pattern> excludePatterns;
private TypeLibrary typelib;

public void setSymbolicName(final String symbolicName) {
this.symbolicName = symbolicName;
}

@Override
protected File getDirectory() {
return new File(getFordiacProject().getLocationURI());
}

@Override
protected String getSingleFBName() {
return null;
}

@Override
protected List<String> getExcludeSubfolder() {
return new ArrayList<>();
}

@Override
protected void checkFordiacProject() {
super.checkFordiacProject();
final Manifest manifest = ManifestHelper.getContainerManifest(getFordiacProject());
if (manifest == null) {
throw new BuildException("Project named '" + getProjectNameString() + "' lacks a manifest file"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (manifest.getExports() == null) {
throw new BuildException("No exports present in manifest file"); //$NON-NLS-1$
}
final Library library = manifest.getExports().getLibrary().stream()
.filter(lib -> lib.getSymbolicName().equals(symbolicName)).findFirst().orElse(null);
if (library == null) {
throw new BuildException("Library export named '" + symbolicName + "' not present in manifest file"); //$NON-NLS-1$ //$NON-NLS-2$
}
setExportDirectory(exportDirectory + File.separator + symbolicName);

includePatterns = new ArrayList<>();
excludePatterns = new ArrayList<>();
typelib = TypeLibraryManager.INSTANCE.getTypeLibrary(getFordiacProject());

library.getIncludes().getLibraryElement().forEach(elem -> {
includePatterns.add(createPattern(elem.getValue()));
});

library.getExcludes().getLibraryElement().forEach(elem -> {
excludePatterns.add(createPattern(elem.getValue()));
});
}

@Override
protected List<File> getFBsFiles(final List<File> files, final File dir, final String singleFBName,
final List<String> excludeSubfolder) {

if (!dir.isDirectory() && isFilteredFiletype(dir)) {
final IPath location = Path.fromOSString(dir.getAbsolutePath());
final IFile ifile = workspace.getRoot().getFileForLocation(location);
final String typename = typelib.getTypeEntry(ifile).getFullTypeName();
if (includePatterns.stream().anyMatch(p -> p.matcher(typename).matches())
&& excludePatterns.stream().noneMatch(p -> p.matcher(typename).matches())) {
files.add(dir);
}
return files;
}
if (dir.listFiles() != null) {
for (final File file : dir.listFiles()) {
getFBsFiles(files, file, singleFBName, excludeSubfolder);
}
}

return files;
}

private static Pattern createPattern(final String raw) {
final String p = replacePattern.matcher(raw).replaceAll(match -> {
if (match.end() - match.start() > 1) {
return doubleStarPattern;
}
return starPattern;
});
return Pattern.compile(p);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ private static boolean isEpxandedSubapp(final IInterfaceElement ie) {
@Override
public boolean canExecute() {
// equal types
if (!source.getClass().equals(target.getClass())) {
if (!source.getClass().isAssignableFrom(target.getClass())
&& !target.getClass().isAssignableFrom(source.getClass())) {
ErrorMessenger.popUpErrorMessage(Messages.LinkConstraints_ConnectingIncompatibleInterfaceTypes);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public boolean canExecute() {
// own checks

// equal types for source and dest
if (!source.getClass().equals(destination.getClass())) {
if (!source.getClass().isAssignableFrom(destination.getClass())
&& !destination.getClass().isAssignableFrom(source.getClass())) {
ErrorMessenger.popUpErrorMessage(Messages.LinkConstraints_ConnectingIncompatibleInterfaceTypes);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Primetals Technologies Austria GmbH
* Copyright (c) 2023, 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 All @@ -12,23 +12,32 @@
*******************************************************************************/
package org.eclipse.fordiac.ide.application.dnd;

import org.eclipse.fordiac.ide.gef.editparts.InterfaceEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.dnd.SimpleObjectTransfer;

final class ConnSourceTransfer extends SimpleObjectTransfer {

public static final String CONNECTIONS_LIST = "Connections"; //$NON-NLS-1$

private static final ConnSourceTransfer INSTANCE = new ConnSourceTransfer();
private static final String TYPE_NAME = "ConnSourceTransver";//$NON-NLS-1$
private static final int TYPEID = registerType(TYPE_NAME);


public static ConnSourceTransfer getInstance() {
return INSTANCE;
}

@Override
public InterfaceEditPart getObject() {
return (InterfaceEditPart) super.getObject();
public Request getObject() {
return (Request) super.getObject();
}

@Override
public void setObject(final Object obj) {
if (obj != null && !(obj instanceof Request)) {
throw new IllegalArgumentException("ConnSourceTransfer requires a request as object!"); //$NON-NLS-1$
}
super.setObject(obj);
}

@Override
Expand Down
Loading

0 comments on commit c6ec115

Please sign in to comment.