Skip to content
Snippets Groups Projects
Commit 0963f278 authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

work on newcore, most likely trash

parent 532a4693
No related branches found
No related tags found
No related merge requests found
Showing
with 84 additions and 467 deletions
...@@ -16,12 +16,9 @@ import org.eclipse.swt.widgets.Display; ...@@ -16,12 +16,9 @@ import org.eclipse.swt.widgets.Display;
import de.bmotionstudio.gef.editor.animation.StaticListenerRegistry; import de.bmotionstudio.gef.editor.animation.StaticListenerRegistry;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.Visualization; import de.bmotionstudio.gef.editor.model.Visualization;
import de.prob.animator.domainobjects.ClassicalBEvalElement;
import de.prob.core.Animator; import de.prob.core.Animator;
import de.prob.core.IAnimationListener; import de.prob.core.IAnimationListener;
import de.prob.core.command.EvaluationGetValuesCommand;
import de.prob.core.command.EvaluationInsertFormulaCommand;
import de.prob.core.command.EvaluationInsertFormulaCommand.FormulaType;
import de.prob.core.domainobjects.EvaluationElement;
import de.prob.core.domainobjects.Operation; import de.prob.core.domainobjects.Operation;
import de.prob.core.domainobjects.State; import de.prob.core.domainobjects.State;
import de.prob.exceptions.ProBException; import de.prob.exceptions.ProBException;
...@@ -33,7 +30,7 @@ public class Animation implements IAnimationListener { ...@@ -33,7 +30,7 @@ public class Animation implements IAnimationListener {
private final Map<String, Operation> currentStateOperations; private final Map<String, Operation> currentStateOperations;
private final Map<String, EvaluationElement> cachedEvalElements = new HashMap<String, EvaluationElement>(); private final Map<String, ClassicalBEvalElement> cachedEvalElements = new HashMap<String, ClassicalBEvalElement>();
private State currentState; private State currentState;
...@@ -82,12 +79,12 @@ public class Animation implements IAnimationListener { ...@@ -82,12 +79,12 @@ public class Animation implements IAnimationListener {
* @param currentState * @param currentState
*/ */
private void updateCachedExpressions(State currentState) { private void updateCachedExpressions(State currentState) {
try { // try {
EvaluationGetValuesCommand.getValuesForExpressionsCached( //// EvaluationGetValuesCommand.getValuesForExpressionsCached(
currentState, cachedEvalElements.values()); //// currentState, cachedEvalElements.values());
} catch (ProBException e) { // } catch (ProBException e) {
// TODO Log this // // TODO Log this
} // }
} }
private void collectAllBControls(List<BControl> allBControls, private void collectAllBControls(List<BControl> allBControls,
......
...@@ -12,8 +12,20 @@ import org.eclipse.swt.events.SelectionAdapter; ...@@ -12,8 +12,20 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.*; import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import de.bmotionstudio.gef.editor.BMotionStudioImage; import de.bmotionstudio.gef.editor.BMotionStudioImage;
import de.bmotionstudio.gef.editor.EditorImageRegistry; import de.bmotionstudio.gef.editor.EditorImageRegistry;
......
...@@ -12,7 +12,18 @@ import org.eclipse.core.runtime.Assert; ...@@ -12,7 +12,18 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellEditorValidator; import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*; import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
......
...@@ -16,7 +16,13 @@ import org.eclipse.swt.graphics.Color; ...@@ -16,7 +16,13 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Slider;
public class SliderCellEditor extends CellEditor { public class SliderCellEditor extends CellEditor {
......
...@@ -13,10 +13,7 @@ import de.be4.classicalb.core.parser.exceptions.BException; ...@@ -13,10 +13,7 @@ import de.be4.classicalb.core.parser.exceptions.BException;
import de.bmotionstudio.gef.editor.Animation; import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants; import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
import de.prob.core.command.EvaluationGetValuesCommand;
import de.prob.core.command.GetOperationByPredicateCommand; import de.prob.core.command.GetOperationByPredicateCommand;
import de.prob.core.domainobjects.EvaluationElement;
import de.prob.core.domainobjects.EvaluationStateElement;
import de.prob.core.domainobjects.Operation; import de.prob.core.domainobjects.Operation;
import de.prob.core.domainobjects.State; import de.prob.core.domainobjects.State;
import de.prob.exceptions.ProBException; import de.prob.exceptions.ProBException;
......
...@@ -3,11 +3,6 @@ Bundle-ManifestVersion: 2 ...@@ -3,11 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: ProB Animator Core Bundle-Name: ProB Animator Core
Bundle-SymbolicName: de.prob.core;singleton:=true Bundle-SymbolicName: de.prob.core;singleton:=true
Bundle-Version: 9.2.2.qualifier Bundle-Version: 9.2.2.qualifier
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.rodinp.core;bundle-version="[1.3.1,1.7.0)",
org.eventb.core;bundle-version="[2.1.0,2.6.0)",
org.eventb.emf.core;bundle-version="2.2.4",
org.eventb.emf.persistence;bundle-version="2.4.0"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Eclipse-BundleShape: dir Eclipse-BundleShape: dir
Bundle-Vendor: HHU Düsseldorf STUPS Group Bundle-Vendor: HHU Düsseldorf STUPS Group
......
...@@ -4,22 +4,5 @@ ...@@ -4,22 +4,5 @@
<extension-point id="de.prob.core.lifecycle" name="Lifecycle Events" schema="schema/de.prob.core.lifecycle.exsd"/> <extension-point id="de.prob.core.lifecycle" name="Lifecycle Events" schema="schema/de.prob.core.lifecycle.exsd"/>
<extension-point id="de.prob.core.computation" name="Computation Events" schema="schema/de.prob.core.computation.exsd"/> <extension-point id="de.prob.core.computation" name="Computation Events" schema="schema/de.prob.core.computation.exsd"/>
<extension-point id="de.prob.core.animation" name="Animation Events" schema="schema/de.prob.core.animation.exsd"/> <extension-point id="de.prob.core.animation" name="Animation Events" schema="schema/de.prob.core.animation.exsd"/>
<extension
point="de.prob.core.animation">
<listener
class="de.prob.core.StaticListenerRegistry">
</listener>
</extension>
<extension
point="de.prob.core.computation">
<listener
class="de.prob.core.StaticListenerRegistry">
</listener>
</extension>
<extension
point="de.prob.core.lifecycle">
<listener
class="de.prob.core.StaticListenerRegistry">
</listener>
</extension>
</plugin> </plugin>
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.prob.cli;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import de.prob.cli.clipatterns.CliPattern;
import de.prob.cli.clipatterns.InterruptRefPattern;
import de.prob.cli.clipatterns.PortPattern;
import de.prob.core.internal.Activator;
import de.prob.logging.Logger;
public final class CliStarter {
private static final String[] JARS = new String[] { "BParser.jar",
"ParserAspects.jar", "aspectjrt.jar", "prolog.jar" };
private Process prologProcess;
private String debuggingKey;
private int port = -1;
private Long userInterruptReference = null;
private OutputLoggerThread stdLogger;
private OutputLoggerThread errLogger;
public CliStarter() throws CliException {
this(null);
}
public CliStarter(final File file) throws CliException {
startProlog(file);
}
public int getPort() {
return port;
}
public void shutdown() {
try {
prologProcess.destroy();
} catch (RuntimeException e) {
final String message = "XXXXX Error while stopping cli process: "
+ e.getLocalizedMessage();
Logger.notifyUser(message, e);
} finally {
stdLogger.shutdown();
errLogger.shutdown();
}
}
public String getDebuggingKey() {
return debuggingKey;
}
private void startProlog(final File file) throws CliException {
prologProcess = null;
debuggingKey = null;
final String os = Platform.getOS();
final String arch = Platform.getOSArch();
final File applicationPath = getCliPath();
final String fullcp = createFullClasspath(os, applicationPath);
final OsSpecificInfo osInfo = getOsInfo(os,arch);
final String osPath = applicationPath + File.separator + osInfo.subdir;
final String executable = osPath + File.separator + osInfo.cliName;
Logger.info("Starting ProB CLI for " + os + " ... Path is "
+ executable);
List<String> command = new ArrayList<String>();
if (osInfo.helperCmd != null) {
command.add(osInfo.helperCmd);
}
command.add(executable);
// command.add("-ll");
command.add("-sf");
command.add("-parsercp");
command.add(fullcp);
if (file != null) {
command.add(file.getAbsolutePath());
}
createDebuggingKey();
final ProcessBuilder pb = new ProcessBuilder();
pb.command(command);
pb.environment().put("PROB_DEBUGGING_KEY", debuggingKey);
pb.environment().put("TRAILSTKSIZE", "1M");
pb.environment().put("PROLOGINCSIZE", "50M");
pb.environment().put("PROB_HOME", osPath);
try {
prologProcess = pb.start();
} catch (IOException e) {
final String message = "Problem while starting up ProB CLI. Tried to execute:"
+ executable;
Logger.notifyUser(message, e);
throw new CliException(message, e, true);
}
Assert.isNotNull(prologProcess);
final BufferedReader input = new BufferedReader(new InputStreamReader(
prologProcess.getInputStream()));
final BufferedReader output = new BufferedReader(new InputStreamReader(
prologProcess.getErrorStream()));
startErrorLogger(output);
extractCliInformation(input);
// log output from Prolog
startOutputLogger(input);
final Process p = prologProcess;
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
p.destroy();
}
}));
}
private OsSpecificInfo getOsInfo(final String os, String architecture) throws CliException {
if (os.equals(Platform.OS_MACOSX)) {
return new OsSpecificInfo("macos", "probcli.sh",
"sh", "send_user_interrupt");
}
if (os.equals(Platform.OS_WIN32)) {
return new OsSpecificInfo("windows",
"probcli.exe", null, "send_user_interrupt.exe");
}
if (os.equals(Platform.OS_LINUX)) {
String linux = "linux";
if (architecture.equals(Platform.ARCH_X86_64)) {
linux = "linux64";
}
return new OsSpecificInfo(linux, "probcli.sh",
"sh", "send_user_interrupt");
}
final CliException cliException = new CliException(
"ProB does not support the plattform: " + os);
cliException.notifyUserOnce();
throw cliException;
}
@SuppressWarnings("unchecked")
private void extractCliInformation(final BufferedReader input)
throws CliException {
final PortPattern portPattern = new PortPattern();
final InterruptRefPattern intPattern = new InterruptRefPattern();
analyseStdout(input, Arrays.asList(portPattern, intPattern));
port = portPattern.getValue();
userInterruptReference = intPattern.getValue();
}
private static String createFullClasspath(final String os, final File path)
throws CliException {
final File base = new File(path.getParentFile().getParentFile(),
"de.prob.common");
final File common = new File(base, "common");
final File lib = new File(common, "lib");
final StringBuilder sb = new StringBuilder();
boolean isFirst = true;
for (final String jar : JARS) {
final File entry = new File(lib, jar);
if (!isFirst) {
sb.append(File.pathSeparator);
}
sb.append(entry.getPath());
isFirst = false;
}
return sb.toString();
}
private void startOutputLogger(final BufferedReader input) {
stdLogger = new OutputLoggerThread("(Output " + port + ")", input);
stdLogger.start();
}
private void startErrorLogger(final BufferedReader output) {
errLogger = new OutputLoggerThread("(Error " + port + ")", output);
errLogger.start();
}
private void createDebuggingKey() {
Random random;
try {
random = SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
random = new Random();
}
debuggingKey = Long.toHexString(random.nextLong());
}
private void analyseStdout(final BufferedReader input,
Collection<? extends CliPattern<?>> patterns) throws CliException {
patterns = new ArrayList<CliPattern<?>>(patterns);
try {
String line;
boolean endReached = false;
while (!endReached && (line = input.readLine()) != null) { // NOPMD
applyPatterns(patterns, line);
endReached = patterns.isEmpty()
|| line.contains("starting command loop");
}
} catch (IOException e) {
final String message = "Problem while starting ProB. Cannot read from input stream.";
Logger.notifyUser(message, e);
throw new CliException(message, e, true);
}
for (CliPattern<?> p : patterns) {
p.notFound();
}
}
private void applyPatterns(
final Collection<? extends CliPattern<?>> patterns,
final String line) {
for (Iterator<? extends CliPattern<?>> it = patterns.iterator(); it
.hasNext();) {
final CliPattern<?> p = it.next();
if (p.matchesLine(line)) {
it.remove();
}
}
}
private File getCliPath() throws CliException {
final Path path = new Path("prob");
final URL fileURL = FileLocator.find(
Activator.getDefault().getBundle(), path, null);
if (fileURL==null) {
throw new CliException("Unable to find directory with prob executables.");
}
URL resolved;
try {
resolved = FileLocator.resolve(fileURL);
} catch (IOException e2) {
throw new CliException("Input/output error when trying t find '"
+ fileURL + "'");
}
URI uri;
try {
uri = resolved.toURI();
} catch (URISyntaxException e) {
try {
uri = new URI("file", null, resolved.getPath(), null);
} catch (URISyntaxException e1) {
throw new CliException("Unable to construct file '"
+ resolved.getPath() + "'");
}
}
return new File(uri);
}
private static class OutputLoggerThread extends Thread {
private final BufferedReader in;
private final String prefix;
private volatile boolean shutingDown = false;
public OutputLoggerThread(final String name, final BufferedReader in) {
super();
prefix = "[" + name + "] ";
this.in = in;
}
@Override
public void run() {
try {
while (!shutingDown) {
final String line = in.readLine();
if (line == null) {
break;
}
// Logger.log(IStatus.INFO, IStatus.OK, prefix + line,
// null);
System.err.println(prefix + line);
}
} catch (IOException e) {
if (!"Stream closed".equals(e.getMessage())) {
final String message = "OutputLogger died with error";
Logger.log(IStatus.INFO, Logger.DEBUG, message, e);
}
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
public void shutdown() {
shutingDown = true;
if (isAlive()) {
interrupt();
}
}
}
public void sendUserInterruptReference() {
if (userInterruptReference != null) {
try {
final OsSpecificInfo osInfo = getOsInfo(Platform.getOS(),
Platform.getOSArch());
final String command = getCliPath() + File.separator
+ osInfo.subdir + File.separator
+ osInfo.userInterruptCmd;
Runtime.getRuntime().exec(
new String[] { command,
userInterruptReference.toString() });
} catch (CliException e) {
Logger.info("getting the os specific info failed with exception: "
+ e.getLocalizedMessage());
} catch (IOException e) {
Logger.info("calling the send_user_interrupt command failed: "
+ e.getLocalizedMessage());
}
}
}
private static class OsSpecificInfo {
final String subdir;
final String cliName;
final String helperCmd;
final String userInterruptCmd;
public OsSpecificInfo(final String subdir, final String cliName,
final String helperCmd, final String userInterruptCmd) {
this.subdir = subdir;
this.cliName = cliName;
this.helperCmd = helperCmd;
this.userInterruptCmd = userInterruptCmd;
}
}
}
...@@ -33,6 +33,7 @@ import de.prob.core.IAnimationListener; ...@@ -33,6 +33,7 @@ import de.prob.core.IAnimationListener;
import de.prob.core.IComputationListener; import de.prob.core.IComputationListener;
import de.prob.core.ILifecycleListener; import de.prob.core.ILifecycleListener;
import de.prob.core.LimitedLogger; import de.prob.core.LimitedLogger;
import de.prob.core.StaticListenerRegistry;
import de.prob.core.domainobjects.Operation; import de.prob.core.domainobjects.Operation;
import de.prob.core.domainobjects.State; import de.prob.core.domainobjects.State;
import de.prob.logging.Logger; import de.prob.logging.Logger;
......
...@@ -86,18 +86,6 @@ ...@@ -86,18 +86,6 @@
restorable="true"> restorable="true">
</view> </view>
</extension> </extension>
<extension
point="de.prob.core.animation">
<listener
class="de.prob.ui.StaticListenerRegistry">
</listener>
</extension>
<extension
point="de.prob.core.lifecycle">
<listener
class="de.prob.ui.StaticListenerRegistry">
</listener>
</extension>
<extension <extension
......
...@@ -15,14 +15,13 @@ import de.prob.core.ILifecycleListener; ...@@ -15,14 +15,13 @@ import de.prob.core.ILifecycleListener;
import de.prob.core.ListenerRegistry; import de.prob.core.ListenerRegistry;
import de.prob.core.domainobjects.Operation; import de.prob.core.domainobjects.Operation;
import de.prob.core.domainobjects.State; import de.prob.core.domainobjects.State;
import de.prob.core.internal.Activator;
public class StaticListenerRegistry implements ILifecycleListener, public class StaticListenerRegistry implements ILifecycleListener,
IComputationListener, IAnimationListener{ IComputationListener, IAnimationListener{
public StaticListenerRegistry() { public StaticListenerRegistry() {
History h = new History(null);
h.registerAnimationListener(this);
} }
private static final ListenerRegistry registry = new ListenerRegistry(); private static final ListenerRegistry registry = new ListenerRegistry();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment