From 7a9f2b5be325778c946f0ff43845001892c44818 Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 4 Mar 2010 18:03:32 +0000 Subject: [PATCH] Minor ui fixes (create valve handler for context menu, syntax error fix in expression view) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14585 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/sysdyn/ui/equation/ShortcutTabs.java | 8 +++++--- .../ui/equation/expressions/ExpressionField.java | 3 +-- .../expressions/ExpressionFieldConfiguration.java | 4 ++++ .../sysdyn/ui/handlers/CreateValveHandler.java | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateValveHandler.java diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java index b8ed7fd3..8e69426f 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ShortcutTabs.java @@ -46,11 +46,13 @@ public class ShortcutTabs extends Composite { functions.setText("Functions"); functionTable = new Table (tabFolder, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); TableItem item = new TableItem(functionTable, SWT.NONE); - item.setText("min()"); + item.setText("min({ })"); item = new TableItem(functionTable, SWT.NONE); - item.setText("max()"); + item.setText("max({ })"); item = new TableItem(functionTable, SWT.NONE); - item.setText("abs()"); + item.setText("abs({ })"); + item = new TableItem(functionTable, SWT.NONE); + item.setText("if then else"); functions.setControl(functionTable); this.layout(); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java index bbbb0fa0..ca942341 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java @@ -107,8 +107,7 @@ public class ExpressionField extends Composite { public void setSyntaxError(Token token){ int start = 0; int offset = this._document.getLength(); - - if(this._document.getLength() > 0) { + if(token.image != null && this._document.getLength() > 0) { try { start = this._document.getLineOffset(token.beginLine - 1) + token.beginColumn - 1; offset = this._document.getLineOffset(token.endLine - 1) + token.endColumn - start; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java index ac3627e0..098a2622 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java @@ -165,5 +165,9 @@ public class ExpressionFieldConfiguration extends SourceViewerConfiguration { keywords.add("not"); keywords.add("break"); keywords.add("return"); + // functions + keywords.add("abs"); + keywords.add("min"); + keywords.add("max"); } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateValveHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateValveHandler.java new file mode 100644 index 00000000..c5034219 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateValveHandler.java @@ -0,0 +1,14 @@ +package org.simantics.sysdyn.ui.handlers; + +import org.simantics.h2d.editor.IDiagramEditor; +import org.simantics.h2d.event.IEvent; +import org.simantics.sysdyn.ui.actions.CreateValve; + +public class CreateValveHandler extends DiagramContextMenuActionHandler { + + protected void handleEvent(IDiagramEditor editor, IEvent event) { + CreateValve cv = new CreateValve(); + cv.handle(editor, event); + } + +} \ No newline at end of file -- 2.47.1