Skip to content
Snippets Groups Projects
Commit 9fd701e3 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Update on jdialognote button and on sig/evt info in activity diag

parent d7f76b7f
No related branches found
No related tags found
No related merge requests found
...@@ -81,6 +81,14 @@ public class Action extends Command { ...@@ -81,6 +81,14 @@ public class Action extends Command {
return "a"; return "a";
} }
public String getUsage() {
return "action <subcommand> <options>";
}
public String getDescription() {
return "Can be used to trigger an action in TTool";
}
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
int index = command.indexOf(" "); int index = command.indexOf(" ");
...@@ -120,6 +128,7 @@ public class Action extends Command { ...@@ -120,6 +128,7 @@ public class Action extends Command {
Command start = new Command() { Command start = new Command() {
public String getCommand() { return START; } public String getCommand() { return START; }
public String getShortCommand() { return "s"; } public String getShortCommand() { return "s"; }
public String getDescription() { return "Starting the graphical interface of TTool"; }
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
if (interpreter.isTToolStarted()) { if (interpreter.isTToolStarted()) {
...@@ -154,6 +163,7 @@ public class Action extends Command { ...@@ -154,6 +163,7 @@ public class Action extends Command {
Command open = new Command() { Command open = new Command() {
public String getCommand() { return OPEN; } public String getCommand() { return OPEN; }
public String getShortCommand() { return "o"; } public String getShortCommand() { return "o"; }
public String getDescription() { return "Opening a model in TTool"; }
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
if (!interpreter.isTToolStarted()) { if (!interpreter.isTToolStarted()) {
...@@ -170,6 +180,7 @@ public class Action extends Command { ...@@ -170,6 +180,7 @@ public class Action extends Command {
Command quit = new Command() { Command quit = new Command() {
public String getCommand() { return QUIT; } public String getCommand() { return QUIT; }
public String getShortCommand() { return "q"; } public String getShortCommand() { return "q"; }
public String getDescription() { return "Closing the graphical interface of TTool"; }
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
if (!interpreter.isTToolStarted()) { if (!interpreter.isTToolStarted()) {
...@@ -180,10 +191,11 @@ public class Action extends Command { ...@@ -180,10 +191,11 @@ public class Action extends Command {
} }
}; };
// Quit // Check syntax
Command checkSyntax = new Command() { Command checkSyntax = new Command() {
public String getCommand() { return "checksyntax"; } public String getCommand() { return "checksyntax"; }
public String getShortCommand() { return "cs"; } public String getShortCommand() { return "cs"; }
public String getDescription() { return "Checking the syntax of an opened model"; }
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
if (!interpreter.isTToolStarted()) { if (!interpreter.isTToolStarted()) {
......
...@@ -68,20 +68,56 @@ public class Command implements CommandInterface { ...@@ -68,20 +68,56 @@ public class Command implements CommandInterface {
public String getShortCommand() { public String getShortCommand() {
return getCommand(); return getCommand();
} }
public String getExample() {
return "";
}
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
return null; return null;
} }
public void fillSubCommands() { public void fillSubCommands() {
} }
public String getUsage() { public String getUsage() {
return "No usage"; return "";
} }
public String getDescription() { public String getDescription() {
return "Not meant to be used"; return "";
}
public String getHelp(int level) {
String dec = getLevelString(level);
/*String h = "";
h+= getCommand() + " (" + getShortCommand() + "): " + getUsage() + "\n" + getDescription() + "\n";
for (Command c: subcommands) {
h+= "\t" + c.getHelp();
}*/
StringBuffer b = new StringBuffer(dec + "* " + getCommand() + " (" + getShortCommand() + "): " + getUsage() + "\n" + dec + getDescription() +
"\n");
if (getExample().length() > 0) {
b.append(dec + "Example: " + getExample() + "\n");
}
subcommands.forEach( (c) -> { b.append(c.getHelp(level + 1)); });
return b.toString();
}
public String getLevelString(int level) {
String ret = "";
while(level > 0) {
ret += "\t";
level --;
}
return ret;
} }
......
...@@ -54,6 +54,7 @@ public interface CommandInterface { ...@@ -54,6 +54,7 @@ public interface CommandInterface {
List<Command> getListOfSubCommands(); List<Command> getListOfSubCommands();
String getCommand(); String getCommand();
String getShortCommand(); String getShortCommand();
String getExample();
// return null in case of success, or a error string in case of failure. // return null in case of success, or a error string in case of failure.
String executeCommand(String command, Interpreter interpreter); String executeCommand(String command, Interpreter interpreter);
......
...@@ -210,4 +210,14 @@ public class Interpreter { ...@@ -210,4 +210,14 @@ public class Interpreter {
return show; return show;
} }
public String getHelp() {
StringBuffer buf = new StringBuffer("");
for(Command c:commands) {
buf.append(c.getHelp(0) + "\n");
}
return buf.toString();
}
} }
...@@ -77,8 +77,14 @@ public class Print extends Command { ...@@ -77,8 +77,14 @@ public class Print extends Command {
return "p"; return "p";
} }
public String getUsage() { return "print <subcommand>"; }
public String executeCommand(String command, Interpreter interpreter) { public String getDescription() {
return "Can be used to print elements of the diagram";
}
/*public String executeCommand(String command, Interpreter interpreter) {
int index = command.indexOf(" "); int index = command.indexOf(" ");
String nextCommand; String nextCommand;
String args; String args;
...@@ -98,13 +104,34 @@ public class Print extends Command { ...@@ -98,13 +104,34 @@ public class Print extends Command {
return Interpreter.UNKNOWN_NEXT_COMMAND + nextCommand; return Interpreter.UNKNOWN_NEXT_COMMAND + nextCommand;
} }*/
public void fillSubCommands() { public void fillSubCommands() {
Command tabs = new Command() {
public String getCommand() { return TABS; }
public String getShortCommand() { return "t"; }
public String getDescription() { return "Printing the name of the tabs in the order of the (graphical) model"; }
public String executeCommand(String command, Interpreter interpreter) {
if (interpreter.isTToolStarted()) {
return Interpreter.TTOOL_ALREADY_STARTED;
}
String tabs = "";
Vector<TURTLEPanel> panels = interpreter.mgui.getTabs();
for(TURTLEPanel pane: panels) {
tabs += interpreter.mgui.getTitleAt(pane) + " ";
}
System.out.println("Tabs: " + tabs);
return null;
}
};
subcommands.add(tabs);
} }
public String printTabs(Interpreter interpreter) { /*public String printTabs(Interpreter interpreter) {
if (!interpreter.isTToolStarted()) { if (!interpreter.isTToolStarted()) {
return Interpreter.TTOOL_NOT_STARTED; return Interpreter.TTOOL_NOT_STARTED;
} }
...@@ -119,5 +146,5 @@ public class Print extends Command { ...@@ -119,5 +146,5 @@ public class Print extends Command {
return null; return null;
} }*/
} }
...@@ -76,6 +76,18 @@ public class Set extends Command { ...@@ -76,6 +76,18 @@ public class Set extends Command {
return "s"; return "s";
} }
public String getUsage() {
return "set <variable name> <value>";
}
public String getDescription() {
return "Used to set a variable to a given value";
}
public String getExample() {
return "set model modeling/AVATAR/PressureController.xml";
}
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
int index = command.indexOf(" "); int index = command.indexOf(" ");
......
...@@ -76,6 +76,14 @@ public class Wait extends Command { ...@@ -76,6 +76,14 @@ public class Wait extends Command {
return "w"; return "w";
} }
public String getUsage() { return "wait <time in s>"; }
public String getDescription() { return "Making a pause in the execution of TTool"; }
public String getExample() {
return "wait 2";
}
public String executeCommand(String command, Interpreter interpreter) { public String executeCommand(String command, Interpreter interpreter) {
try { try {
......
...@@ -135,7 +135,7 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon ...@@ -135,7 +135,7 @@ public class AvatarADAcceptEventAction extends AvatarADBasicCanBeDisabledCompon
g.drawLine(x, y, x+linebreak, y+height/2); g.drawLine(x, y, x+linebreak, y+height/2);
g.drawLine(x, y+height, x+linebreak, y+height/2); g.drawLine(x, y+height, x+linebreak, y+height/2);
g.drawString("evt", x+(width-w) / 2, y); //g.drawString("evt", x+(width-w) / 2, y);
g.drawString(value, x + linebreak + textX1, y + (int)((textY*tdp.getZoom()))); g.drawString(value, x + linebreak + textX1, y + (int)((textY*tdp.getZoom())));
} }
......
...@@ -139,7 +139,7 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen ...@@ -139,7 +139,7 @@ public class AvatarADSendSignalAction extends AvatarADBasicCanBeDisabledComponen
g.drawLine(x+width-linebreak, y, x+width, y+height/2); g.drawLine(x+width-linebreak, y, x+width, y+height/2);
g.drawLine(x+width-linebreak, y+height, x+width, y+height/2); g.drawLine(x+width-linebreak, y+height, x+width, y+height/2);
g.drawString("sig", x+(width-w) / 2, y); //g.drawString("sig", x+(width-w) / 2, y);
g.drawString(value, x + (width - w) / 2 , y + (int)((textY*tdp.getZoom()))); g.drawString(value, x + (width - w) / 2 , y + (int)((textY*tdp.getZoom())));
} }
......
...@@ -104,8 +104,8 @@ public class JDialogNote extends JDialogBase implements ActionListener { ...@@ -104,8 +104,8 @@ public class JDialogNote extends JDialogBase implements ActionListener {
cancel.addActionListener(this); cancel.addActionListener(this);
JPanel jp = new JPanel(); JPanel jp = new JPanel();
jp.add(close);
jp.add(cancel); jp.add(cancel);
jp.add(close);
c.add(jp, BorderLayout.SOUTH); c.add(jp, BorderLayout.SOUTH);
} }
......
...@@ -67,8 +67,9 @@ public class TToolCLI implements InterpreterOutputInterface { ...@@ -67,8 +67,9 @@ public class TToolCLI implements InterpreterOutputInterface {
public static void printUsage() { public static void printUsage() {
System.out.println("ttool-cli: usage"); System.out.println("ttool-cli: usage");
System.out.println("ttool-cli <script file>"); System.out.println("ttool-cli <script file> OR ttool-cli -help");
System.out.println("options: -debug -show"); System.out.println("options: -debug -show");
} }
public static boolean checkArgs(String[] args) { public static boolean checkArgs(String[] args) {
...@@ -95,6 +96,16 @@ public class TToolCLI implements InterpreterOutputInterface { ...@@ -95,6 +96,16 @@ public class TToolCLI implements InterpreterOutputInterface {
return false; return false;
} }
public static boolean hasHelp(String[] args) {
for (String s : args) {
if (s.equals("-help")) {
return true;
}
}
return false;
}
public static String getInputFile(String[] args) { public static String getInputFile(String[] args) {
return args[args.length - 1]; return args[args.length - 1];
} }
...@@ -104,6 +115,7 @@ public class TToolCLI implements InterpreterOutputInterface { ...@@ -104,6 +115,7 @@ public class TToolCLI implements InterpreterOutputInterface {
public static void main(String[] args) { public static void main(String[] args) {
String[] tmp; String[] tmp;
printCopyright(); printCopyright();
if (!checkArgs(args)) { if (!checkArgs(args)) {
...@@ -122,19 +134,34 @@ public class TToolCLI implements InterpreterOutputInterface { ...@@ -122,19 +134,34 @@ public class TToolCLI implements InterpreterOutputInterface {
show = true; show = true;
} }
boolean help = false;
if (hasHelp(args)) {
help = true;
}
TToolCLI cli = new TToolCLI(); TToolCLI cli = new TToolCLI();
cli.print("Loading script:" + getInputFile(args)); String script = null;
// Load script file
File f = new File(getInputFile(args)); if (!help) {
if (!FileUtils.checkFileForOpen(f)) { cli.print("Loading script:" + getInputFile(args));
cli.printError("File " + f.getAbsolutePath() + " could not be opened."); // Load script file
cli.exit(-1); File f = new File(getInputFile(args));
if (!FileUtils.checkFileForOpen(f)) {
cli.printError("File " + f.getAbsolutePath() + " could not be opened.");
cli.exit(-1);
}
script = FileUtils.loadFileData(f);
} }
String script = FileUtils.loadFileData(f);
// Call Interpreter // Call Interpreter
Interpreter interpret = new Interpreter(script, (InterpreterOutputInterface)cli, show); Interpreter interpret = new Interpreter(script, (InterpreterOutputInterface)cli, show);
interpret.interpret(); if (help) {
String fullHelp = interpret.getHelp();
System.out.println(fullHelp);
} else {
interpret.interpret();
}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment