Skip to content
Snippets Groups Projects
Commit c6576143 authored by Michael Leuschel's avatar Michael Leuschel
Browse files

add option to start ProB2-UI Standalone

in addition to ProB Tcl/Tk classic
parent 43a21841
Branches
Tags
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<page <page
class="de.prob.ui.eventb.ClassicPreferences" class="de.prob.ui.eventb.ClassicPreferences"
id="de.prob.ui.probclassic" id="de.prob.ui.probclassic"
name="ProB Classic" name="ProB Standalone"
category="probpreferences"> category="probpreferences">
</page> </page>
</extension> </extension>
...@@ -1096,17 +1096,17 @@ ...@@ -1096,17 +1096,17 @@
commandId="de.prob.ui.navigator.context" commandId="de.prob.ui.navigator.context"
icon="icons/new_prob_mini.png" icon="icons/new_prob_mini.png"
id="more_commands" id="more_commands"
label="ProB Classic ..."> label="ProB Standalone ...">
<command <command
commandId="de.prob.ui.newcore.export" commandId="de.prob.ui.newcore.export"
icon="icons/prob_mini_logo.gif" icon="icons/prob_mini_logo.gif"
label="Export for use in ProB classic" label="Export for use in ProB Standalone"
style="push"> style="push">
</command> </command>
<command <command
commandId="de.prob.ui.classic.open" commandId="de.prob.ui.classic.open"
icon="icons/prob_mini_logo.gif" icon="icons/prob_mini_logo.gif"
label="Open in ProB classic" label="Open in ProB Standalone"
style="push"> style="push">
</command> </command>
<visibleWhen> <visibleWhen>
......
...@@ -78,7 +78,7 @@ public class ClassicPreferences extends PreferencePage implements ...@@ -78,7 +78,7 @@ public class ClassicPreferences extends PreferencePage implements
pageComponent.setLayout(layout); pageComponent.setLayout(layout);
Label label = new Label(pageComponent, SWT.NONE); Label label = new Label(pageComponent, SWT.NONE);
label.setText("Location of ProB classic:"); label.setText("Location of ProB Standalone:");
text = new Text(pageComponent, SWT.NONE); text = new Text(pageComponent, SWT.NONE);
String location = prefNode.get("location", ""); String location = prefNode.get("location", "");
// text.setLayoutData(new RowData(100, SWT.DEFAULT)); // text.setLayoutData(new RowData(100, SWT.DEFAULT));
...@@ -89,7 +89,7 @@ public class ClassicPreferences extends PreferencePage implements ...@@ -89,7 +89,7 @@ public class ClassicPreferences extends PreferencePage implements
browseButton.addSelectionListener(new PushButton(pageComponent.getShell(), text)); browseButton.addSelectionListener(new PushButton(pageComponent.getShell(), text));
Label versionRemark = new Label(pageComponent, SWT.WRAP); Label versionRemark = new Label(pageComponent, SWT.WRAP);
versionRemark.setText( versionRemark.setText(
"Note: This needs a version of ProB Tcl/Tk that is newer than 1.3.0.\nYou can obtain a copy of ProB Tcl/Tk from http://www.stups.uni-duesseldorf.de/ProB\n"); // precisely "Note: This needs a version of ProB2-UI (jar file) that is at least 1.0.1 or a version of ProB Tcl/Tk that is at least 1.3.1.\nYou can obtain both from http://www.stups.uni-duesseldorf.de/ProB\n"); // precisely
// 1.3.0-beta6 // 1.3.0-beta6
GridData gridData2 = new GridData(); GridData gridData2 = new GridData();
......
...@@ -24,19 +24,31 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { ...@@ -24,19 +24,31 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler {
private ISelection fSelection; private ISelection fSelection;
private static final String PROB_CLASSIC_NAME = "ProB Tcl/Tk";
private static final String PROB_STANDALONE_NAME = "ProB Standalone";
private static final String PROB2_NAME = "ProB2-UI";
public Object execute(final ExecutionEvent event) throws ExecutionException { public Object execute(final ExecutionEvent event) throws ExecutionException {
fSelection = HandlerUtil.getCurrentSelection(event); fSelection = HandlerUtil.getCurrentSelection(event);
final String location = getBinaryLocation(); final String prob_location = getBinaryLocation();
if (location == null) { if (prob_location == null) {
Logger.notifyUserWithoutBugreport("You need to specify a location for the ProB Tcl/Tk version. See Preferences -> ProB Classic."); Logger.notifyUserWithoutBugreport("You need to specify a location for" + PROB_STANDALONE_NAME +". See Preferences -> ProB Standalone.");
} else { } else {
final IEventBRoot root = getSelection(); final IEventBRoot root = getSelection();
if (root != null) { if (root != null) {
if(prob_location.endsWith(".jar")) {
// TO DO: we can open directly the .bum or .buc files with ProB2; we need to get it from root
final File temp = createTempFile();
final String tmp = temp.getAbsolutePath();
ExportNewCoreHandler.exportToClassic(tmp, root);
runProB2(prob_location, tmp);
} else {
final File temp = createTempFile(); final File temp = createTempFile();
final String tmp = temp.getAbsolutePath(); final String tmp = temp.getAbsolutePath();
ExportNewCoreHandler.exportToClassic(tmp, root); ExportNewCoreHandler.exportToClassic(tmp, root);
runProBClassic(location, tmp); runProBClassic(prob_location, tmp);
}
} }
} }
return null; return null;
...@@ -56,7 +68,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { ...@@ -56,7 +68,7 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler {
if (line == null) { if (line == null) {
break; break;
} }
System.out.println("ProB Classic: " + line); System.out.println(PROB_STANDALONE_NAME + ": " + line);
} }
} catch (IOException e) { } catch (IOException e) {
} finally { } finally {
...@@ -79,7 +91,34 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler { ...@@ -79,7 +91,34 @@ public class OpenClassicHandler extends AbstractHandler implements IHandler {
new Thread(new ClassicConsole(output)).start(); new Thread(new ClassicConsole(output)).start();
} catch (IOException e) { } catch (IOException e) {
Logger.notifyUserWithoutBugreport("You need to specify a correct location for the ProB Tcl/Tk version. See Preferences -> ProB Classic.\nProB Tcl/Tk location: "+ probBinary + Logger.notifyUserWithoutBugreport("You need to specify a correct location for "
+ PROB_CLASSIC_NAME + ". See Preferences -> ProB Standalone.\n"
+ PROB_CLASSIC_NAME + " location: "+ probBinary +
"\nModel file: " + modelFile +
"\nError message: "+ e.getLocalizedMessage());
}
}
private void runProB2(final String probBinary, final String modelFile) {
// call prob2-ui jar file
// from command-line it is: java -jar prob2-ui-1.0.1-SNAPSHOT-all.jar --machine-file FILE
Process process = null;
try {
final String command = "java -jar " + probBinary + " --machine-file " + modelFile;
process = Runtime.getRuntime().exec(command);
final BufferedReader output = new BufferedReader(
new InputStreamReader(process.getInputStream()));
new Thread(new ClassicConsole(output)).start();
// TODO: maybe use
//ProcessBuilder pb = new ProcessBuilder("/path/to/java", "-jar", probBinary, "--machine-file",modelFile);
// pb.directory(new File("preferred/working/directory"));
// Process p = pb.start();
} catch (IOException e) {
Logger.notifyUserWithoutBugreport("You need to specify a correct location for "
+ PROB2_NAME + ". See Preferences -> ProB Standalone.\n"
+ PROB2_NAME + " location: "+ probBinary +
"\nModel file: " + modelFile + "\nModel file: " + modelFile +
"\nError message: "+ e.getLocalizedMessage()); "\nError message: "+ e.getLocalizedMessage());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment