Commit 9456ad3c authored by Hernan Ponce de Leon's avatar Hernan Ponce de Leon
Browse files

Merge remote-tracking branch 'origin/master' into 3465-IStatementTerm_toZ3

parents 9d3a2981 cccdb14e
AF3z3Activator.java 5fb8c96356e6f28a327f2fd5d39894ada1ae72f5 YELLOW
AF3z3Activator.java b12e80465a3b7ce446c81e5857ecf4f4dfe9e96c GREEN
Z3Type.java 73e319ae206d2fd456ec9430c01b5ff7fc7282d0 GREEN
Z3javaAPIWrapper.java 8e36ee136c0a903ae1da7ac786e6cb9a3d3ac1a3 GREEN
......@@ -34,43 +34,17 @@ public class AF3z3Activator extends Plugin {
super.start(context);
plugin = this;
String path, prefix = "";
boolean is64bit = isOs64BitArch();
String path = isOs64BitArch() ? "/lib/x64/" : "/lib/x32/";
String prefix = "";
if(isWindowsPlatform()) {
prefix = "lib";
}
if(is64bit) {
path = "/lib/x64/";
} else {
path = "/lib/x32/";
}
if(!is64bit && prefix.equals("lib")) {
// Load necessary windows 32 bit libraries
String lib1, lib2, lib3, lib4;
lib1 = "Microsoft.Z3";
lib2 = "msvcr110";
lib3 = "msvcp110";
lib4 = "vcomp110";
loadPluginLocalLibrary(getBundle(), path, lib1, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib2, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib3, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib4, "libz3");
}
if(is64bit && prefix.equals("lib")) {
// load necessary windows 32 bit libraries
String lib1, lib2, lib3, lib4;
lib1 = "Microsoft.Z3";
lib2 = "msvcr110";
lib3 = "msvcp110";
lib4 = "vcomp110";
loadPluginLocalLibrary(getBundle(), path, lib1, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib2, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib3, "libz3");
loadPluginLocalLibrary(getBundle(), path, lib4, "libz3");
// Load additional libraries needed on Windows
loadPluginLocalLibrary(getBundle(), path, "Microsoft.Z3", "libz3");
loadPluginLocalLibrary(getBundle(), path, "msvcr110", "libz3");
loadPluginLocalLibrary(getBundle(), path, "msvcp110", "libz3");
loadPluginLocalLibrary(getBundle(), path, "vcomp110", "libz3");
}
loadPluginLocalLibrary(getBundle(), path, prefix + "z3", "libz3");
......
AllocationModelElementFactory.java 1790fc35d560cdf74ac1900c0d289e58900a0c32 GREEN
AllocationUtils.java f3f674b8ba72ea838cacca1fac14ae2dbfcd0652 GREEN
AllocationUtils.java b99e40e70bc2eca1db7cbb146166a8f29723aa01 GREEN
......@@ -371,8 +371,8 @@ public class AllocationUtils {
* Retrieves the {@link AllocationTable} specialization of the given {@code allocationTableType}
* that references the given {@code sourceView} and {@code targetView} (at most one of these
* references may be {@code null} in which case it is ignored). In case such
* {@link AllocationTable} specialization does not exit yet, it is created (with the given
* {@code name}).
* {@link AllocationTable} specialization does not exit yet, and the provided {@code name} is
* non-{@code null}, it is created.
*
* @param allocationTableType
* Desired {@link AllocationTable} type.
......@@ -383,9 +383,11 @@ public class AllocationUtils {
* Target model that must be referenced by the returned {@link AllocationTable}
* (ignored when {@code null}).
* @param name
* Name of allocationTable specialization in case it has to be created.
* Name of {@link AllocationTable} specialization in case it has to be created. If it
* is {@code null}, no {@link AllocationTable} is created.
* @return {@link AllocationTable} specialization of the given {@code allocationTableType} that
* references the given {@code sourceView} and {@code targetView}.
* references the given {@code sourceView} and {@code targetView}, or {@code null} (in
* case the table did not exist and no {@code name} has been provided.
*/
public static <T extends AllocationTable & INamedElement> T getOrCreateAllocationTable(
Class<T> allocationTableType, IProjectRootElement sourceView,
......@@ -403,6 +405,10 @@ public class AllocationUtils {
}
}
if(name == null) {
return null;
}
// Create and initialize new one
AllocationTableCollection atc = createAllocationTableCollection("Allocations");
FileProject fileProject = getFileProject(modelRef);
......
......@@ -268,7 +268,10 @@
<extension
point="org.fortiss.tooling.kernel.ui.contextMenuContribution">
<contextMenuContribution
contributor="org.fortiss.af3.component.ui.editor.PackSelectionToComponent">
contributor="org.fortiss.af3.component.ui.editor.PackSelectionToComponentMenu">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.component.ui.editor.UnpackSelectionToComponentsMenu">
</contextMenuContribution>
<contextMenuContribution
contributor="org.fortiss.af3.component.ui.simulator.SimulatorEasyStartMenu">
......
......@@ -3,6 +3,7 @@ CodeSpecificationEditorBinding.java aeff3d23f484b3adeac6dfa01bb52ddcb8daba94 GRE
ComponentArchitectureEditorBinding.java c7756ac19f55df928c6b9b0ece1982c47e8f0e1c GREEN
ComponentStructureEditor.java 2eb198630fa961f42568b0bd272d19db5e6630aa GREEN
ComponentStructureEditorBinding.java 5801ef5d8882d026acc6f4ac7ecb4daba3452299 GREEN
LayoutComponentCommand.java 89f12c354b832adce29322b7f7ccd85b975fbf83 RED
PackComponentCommand.java 30a8b76cf748d7142c45696c414e4610f62ee592 GREEN
PackSelectionToComponent.java 0323bc6f85088869b093bd6c415b17b8f0fe722b GREEN
PackSelectionToComponentMenu.java 187ac87f2afdac3b4d67e4a88a7286510e88a82e GREEN
PackUnpackComponentMenuBase.java 4dd4e9f2489e8d6772c7b590f6f47a33c903e310 GREEN
PackUnpackComponents.java 3fa1b1b7eb6bf863bfff7b9116ccabe14b15aba3 GREEN
UnpackSelectionToComponentsMenu.java 5a9ddced6f128942d31424e9f5a6ae01b405221f GREEN
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor;
import static java.util.Collections.max;
import static java.util.Collections.min;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE;
import static org.fortiss.tooling.base.model.layout.EOrientation.EAST;
import static org.fortiss.tooling.base.model.layout.EOrientation.WEST;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodePosition;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.moveNode;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorLayoutData;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
/**
* Takes a component and its referenced components and arranges them properly
* in the diagram. At the moment it is used after the packing of 2 components to
* properly display the new component in the diagram
*
* TODO (AB, 13) There are plenty of magic constants used throughout this code.
*
* @author aravantinos
*/
public class LayoutComponentCommand implements Runnable {
/** component to be positioned */
private Component component;
/** referenced components */
private List<Component> refs;
/** Constructor */
public LayoutComponentCommand(Component component, List<Component> refCompnents) {
this.component = component;
this.refs = refCompnents;
}
/** {@inheritDoc} */
@Override
public void run() {
ArrayList<Integer> xDimensions = new ArrayList<Integer>();
ArrayList<Integer> yDimensions = new ArrayList<Integer>();
ArrayList<Integer> xPositions = new ArrayList<Integer>();
ArrayList<Integer> yPositions = new ArrayList<Integer>();
for(Component comp : refs) {
xPositions.add(getNodePosition(comp).getX());
yPositions.add(getNodePosition(comp).getY());
xDimensions.add(getNodeSize(comp).getWidth() + getNodePosition(comp).getX());
yDimensions.add(getNodeSize(comp).getHeight() + getNodePosition(comp).getX());
}
int minPosX = min(xPositions);
int minPosY = min(yPositions);
int maxX = max(xDimensions);
int maxY = max(yDimensions);
setNodeSize(component, maxX - minPosX, maxY - minPosY);
setNodePosition(component, minPosX, minPosY);
int index = 0;
for(InputPort input : component.getInputPorts()) {
setStickyConnectorLayoutData(input, WEST, DEFAULT_GRID_SIZE * (index * 5 + 1));
index++;
}
int indexOut = 0;
for(OutputPort output : component.getOutputPorts()) {
setStickyConnectorLayoutData(output, EAST, DEFAULT_GRID_SIZE * (indexOut * 5 + 1));
indexOut++;
}
ArrayList<InputPort> inPorts = new ArrayList<InputPort>();
ArrayList<OutputPort> outPorts = new ArrayList<OutputPort>();
for(Component com : refs) {
for(int i = 0; i < com.getInputPorts().size(); i++) {
inPorts.add(com.getInputPorts().get(i));
}
for(int i = 0; i < com.getOutputPorts().size(); i++) {
outPorts.add(com.getOutputPorts().get(i));
}
}
int indexedIn = 0;
for(InputPort input : inPorts) {
for(int i = 0; i < input.getIncomingChannels().size(); i++) {
moveNode(input.getIncomingChannels().get(i).getSource(), 50, 100 + indexedIn);
indexedIn += 50;
}
}
int indexedOut = 0;
for(OutputPort output : outPorts) {
for(int i = 0; i < output.getOutgoingChannels().size(); i++) {
moveNode(output.getOutgoingChannels().get(i).getTarget(), 0, 50 + indexedOut);
indexedOut += 50;
}
}
}
}
/*-------------------------------------------------------------------------+
| Copyright 2013 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createChannelAndAttach;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createInputPortAndAttach;
import static org.fortiss.af3.component.utils.ComponentModelElementFactory.createOutputPortAndAttach;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.component.utils.ComponentModelElementFactory;
import org.fortiss.tooling.kernel.utils.UniqueIDUtils;
/**
* Takes a given selection of components and packs them to a new component
* adapting all connections / dependencies to the newly created comp.
* Command is called by : PackSelectionToComponent
*
* @author aravantinos
*/
public class PackComponentCommand implements Runnable {
/** selected components */
private List<Component> components;
/** Component for checking */
private Component newComp;
/** Constructor */
public PackComponentCommand(List<Component> components) {
this.components = components;
}
/** {@inheritDoc} */
@Override
public void run() {
// get(0) because we take the first component on purpose.
// The first component exists because this command can only be run on a command.
Component refComp = components.get(0);
for(Component component : components) {
if(component.getParentComponent() != refComp.getParentComponent() &&
component.getCausalitySpecification() != refComp.getCausalitySpecification()) {
org.conqat.ide.commons.ui.dialog.MessageUtils
.showErrorAsync("Unsupported Operation",
"The selected components are on different levels or their causal specification differs.");
return;
}
}
Component parentComp = refComp.getParentComponent();
boolean causalityValue = refComp.getCausalitySpecification().isStronglyCausal();
newComp =
ComponentModelElementFactory.createComponentAndAttach(parentComp, "New Component",
causalityValue);
UniqueIDUtils.prepareUniqueID(newComp, parentComp);
parentComp.getContainedElements().add(newComp);
for(Component component : components) {
newComp.getContainedElements().add(component);
for(InputPort inputPort : component.getInputPorts()) {
ArrayList<Channel> externChannels = new ArrayList<Channel>();
for(Channel channel : inputPort.getIncomingChannels()) {
if(!components.contains(channel.getSource().getComponent())) {
externChannels.add(channel);
}
}
if(externChannels.isEmpty()) {
for(Channel channel : inputPort.getIncomingChannels()) {
newComp.getConnections().add(channel);
}
} else {
InputPort input =
createInputPortAndAttach(newComp, inputPort.getName(),
copy(inputPort.getVariableType()),
copy(inputPort.getInitialValue()));
for(Channel channel : inputPort.getIncomingChannels()) {
if(externChannels.contains(channel)) {
createChannelAndAttach(parentComp, channel.getName(),
channel.getSource(), input);
newComp.getConnections().add(channel);
channel.setSource(input);
} else {
newComp.getConnections().add(channel);
}
}
}
}
for(OutputPort outputPort : component.getOutputPorts()) {
ArrayList<Channel> externChannels = new ArrayList<Channel>();
for(Channel channel : outputPort.getOutgoingChannels()) {
if(!components.contains(channel.getTarget().getComponent())) {
externChannels.add(channel);
}
}
if(externChannels.isEmpty()) {
for(Channel channel : outputPort.getOutgoingChannels()) {
newComp.getConnections().add(channel);
}
} else {
OutputPort output =
createOutputPortAndAttach(newComp, outputPort.getName(),
copy(outputPort.getVariableType()),
copy(outputPort.getInitialValue()));
output.setOwner(newComp);
output.setId(outputPort.getId());
for(Channel channel : outputPort.getOutgoingChannels()) {
if(externChannels.contains(channel)) {
createChannelAndAttach(parentComp, channel.getName(), output,
channel.getTarget());
newComp.getConnections().add(channel);
channel.setTarget(output);
} else {
newComp.getConnections().add(channel);
}
}
}
}
}
}
/** @return new component */
public Component getCreatedComponent() {
return newComp;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showErrorAsync;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import java.util.List;
import org.eclipse.jface.action.Action;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.ui.AF3ComponentUIActivator;
import org.fortiss.tooling.base.ui.layout.auto.IAutoLayouter;
import org.fortiss.tooling.base.ui.layout.auto.KielerAutoLayouter;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.base.MultiEObjectActionBase;
/**
* {@link IContextMenuContributor} to pack selection to {@link Component}.
*
* @author Andreiasw1, reaboi
*/
public class PackSelectionToComponentMenu extends PackUnpackComponentMenuBase {
/** {@inheritDoc} */
@Override
protected Action createAction(List<Component> components) {
return new PackComponentAction(components);
}
/** The action. */
private class PackComponentAction extends MultiEObjectActionBase<List<Component>> {
/** Constructor. */
public PackComponentAction(List<Component> selectedElement) {
super("Pack component", AF3ComponentUIActivator.getImageDescriptor("icons/pack16.png"));
setTarget(selectedElement);
}
/** {@inheritDoc} */
@Override
public void run() {
// The list of selected components is guaranteed to be non-empty() by
// PackSelectionToComponents::getContributedItems()
runAsCommand(
getTarget().get(0),
() -> {
Component newComponent = PackUnpackComponents.pack(getTarget());
if(newComponent == null) {
showErrorAsync("Unsupported Operation",
"The selected components are on different levels or their causal specification differs.");
return;
}
IAutoLayouter layouter = new KielerAutoLayouter();
layouter.performAutoLayout(newComponent);
layouter.performAutoLayout(newComponent.getParentComponent());
});
}
}
}
......@@ -16,51 +16,36 @@
package org.fortiss.af3.component.ui.editor;
import static java.util.Collections.singletonList;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showWarningAsync;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.getNodeBounds;
import static org.eclipse.emf.common.util.ECollections.singletonEList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.tooling.base.ui.ToolingBaseUIActivator;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuMultiSelectionContributor;
import org.fortiss.tooling.kernel.ui.extension.base.MultiEObjectActionBase;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
/**
* {@link IContextMenuContributor} for pack components
* {@link IContextMenuContributor} base class to pack / unpack {@link Component}s.
*
* @author Andreiasw1
* @author barner
*/
public class PackSelectionToComponent implements IContextMenuMultiSelectionContributor {
public abstract class PackUnpackComponentMenuBase implements IContextMenuMultiSelectionContributor {
/** {@inheritDoc} */
@Override
public List<IContributionItem> getContributedItems(EObject selection,
ContextMenuContextProvider contextProvider) {
if(selection instanceof Component) {
// Do not allow repacking of the top-level component (associated with the
// ComponentArcitecture); only an issue with single selection, multi not affected.
ComponentArchitecture compArch =
getParentElement(selection, ComponentArchitecture.class, false);
if(compArch != null && compArch.getTopComponent() != (Component)selection) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(new PackComponentAction(
singletonList((Component)selection))));
return contributionItems;
}
}
return null;
return getContributedItems(singletonEList(selection), contextProvider);
}
/** {@inheritDoc} */
......@@ -68,60 +53,26 @@ public class PackSelectionToComponent implements IContextMenuMultiSelectionContr
public List<IContributionItem> getContributedItems(List<EObject> selection,
ContextMenuContextProvider contextProvider) {
EList<Component> components = pickInstanceOf(Component.class, selection);
if(components != null && !components.isEmpty() && components.size() == selection.size()) {
List<IContributionItem> contributionItems = new ArrayList<IContributionItem>();
contributionItems.add(new ActionContributionItem(new PackComponentAction(components)));
return contributionItems;
if(components == null || components.isEmpty() || components.size() != selection.size()) {
return null;
}
for(Component component : components) {
ComponentArchitecture compArch =
getParentElement(component, ComponentArchitecture.class, false);
if(compArch == null || compArch.getTopComponent() == component) {
return null;
}
}
return null;