Commit 0963f278 authored by Jens Bendisposto's avatar Jens Bendisposto
Browse files

work on newcore, most likely trash

parent 532a4693
......@@ -6,9 +6,9 @@
package de.bmotionstudio.gef.editor;
import java.util.HashMap;
import org.eclipse.jface.action.Action;
import java.util.HashMap;
import org.eclipse.jface.action.Action;
public class AbstractInstallActions {
......
......@@ -16,12 +16,9 @@ import org.eclipse.swt.widgets.Display;
import de.bmotionstudio.gef.editor.animation.StaticListenerRegistry;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.model.Visualization;
import de.prob.animator.domainobjects.ClassicalBEvalElement;
import de.prob.core.Animator;
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.State;
import de.prob.exceptions.ProBException;
......@@ -33,7 +30,7 @@ public class Animation implements IAnimationListener {
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;
......@@ -82,12 +79,12 @@ public class Animation implements IAnimationListener {
* @param currentState
*/
private void updateCachedExpressions(State currentState) {
try {
EvaluationGetValuesCommand.getValuesForExpressionsCached(
currentState, cachedEvalElements.values());
} catch (ProBException e) {
// TODO Log this
}
// try {
//// EvaluationGetValuesCommand.getValuesForExpressionsCached(
//// currentState, cachedEvalElements.values());
// } catch (ProBException e) {
// // TODO Log this
// }
}
private void collectAllBControls(List<BControl> allBControls,
......
......@@ -6,10 +6,10 @@
package de.bmotionstudio.gef.editor;
import java.util.HashMap;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.part.WorkbenchPart;
import java.util.HashMap;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.part.WorkbenchPart;
public interface IInstallActions {
......
......@@ -6,9 +6,9 @@
package de.bmotionstudio.gef.editor;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.IActionBars;
public interface IInstallMenu {
......
......@@ -6,8 +6,8 @@
package de.bmotionstudio.gef.editor.command;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;
public abstract class AbstractLayoutCommand extends Command {
......
......@@ -12,8 +12,20 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.FillLayout;
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.EditorImageRegistry;
......
......@@ -6,11 +6,11 @@
package de.bmotionstudio.gef.editor.property;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.swt.graphics.Image;
import de.bmotionstudio.gef.editor.BMotionStudioImage;
import de.bmotionstudio.gef.editor.EditorImageRegistry;
import de.bmotionstudio.gef.editor.EditorImageRegistry;
public class CheckboxCellEditorHelper {
......
......@@ -6,11 +6,11 @@
package de.bmotionstudio.gef.editor.property;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.jface.viewers.DialogCellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.PlatformUI;
public class FileDialogCellEditor extends DialogCellEditor {
......
......@@ -6,9 +6,9 @@
package de.bmotionstudio.gef.editor.property;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class FilePropertyDescriptor extends PropertyDescriptor {
......
......@@ -6,9 +6,9 @@
package de.bmotionstudio.gef.editor.property;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class ImagePropertyDescriptor extends PropertyDescriptor {
......
......@@ -12,7 +12,18 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellEditorValidator;
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.Control;
import org.eclipse.swt.widgets.Text;
......
......@@ -6,17 +6,23 @@
package de.bmotionstudio.gef.editor.property;
import java.text.MessageFormat;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
import java.text.MessageFormat;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
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 {
......
......@@ -6,9 +6,9 @@
package de.bmotionstudio.gef.editor.property;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class SliderPropertyDescriptor extends PropertyDescriptor {
......
......@@ -13,10 +13,7 @@ import de.be4.classicalb.core.parser.exceptions.BException;
import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.AttributeConstants;
import de.bmotionstudio.gef.editor.model.BControl;
import de.prob.core.command.EvaluationGetValuesCommand;
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.State;
import de.prob.exceptions.ProBException;
......
......@@ -3,11 +3,6 @@ Bundle-ManifestVersion: 2
Bundle-Name: ProB Animator Core
Bundle-SymbolicName: de.prob.core;singleton:=true
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
Eclipse-BundleShape: dir
Bundle-Vendor: HHU Düsseldorf STUPS Group
......
......@@ -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.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="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>
/**
* (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);
}