1.1 --- a/isac-java/src/java-tests/isac/gui/mawen/editor/TestEditorPanel.java Tue Sep 12 10:38:02 2017 +0200
1.2 +++ b/isac-java/src/java-tests/isac/gui/mawen/editor/TestEditorPanel.java Tue Sep 12 12:02:50 2017 +0200
1.3 @@ -28,7 +28,6 @@
1.4 try {
1.5 Thread.sleep(200000);
1.6 } catch (InterruptedException e) {
1.7 - // TODO Auto-generated catch block
1.8 e.printStackTrace();
1.9 }
1.10 }
2.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Tue Sep 12 10:38:02 2017 +0200
2.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstComponent.scala Tue Sep 12 12:02:50 2017 +0200
2.3 @@ -26,7 +26,7 @@
2.4 var marker : Rectangle = new Rectangle()
2.5 //list of boxes touched by mouse while drawing a rectangle; the outmost is relevant
2.6 var markedBoxes : List[DrawBox] = List.empty[DrawBox]
2.7 - // TODWN
2.8 + // TODOWN
2.9 var mousePositionFunction : (Graphics, Int, Int, String, Box) => Unit = null
2.10 var box : DrawBox = null
2.11 setFocusable(true)
2.12 @@ -37,7 +37,7 @@
2.13 new Thread(new Runnable() {
2.14 def run() {
2.15 while (true) {
2.16 - //Thread.sleep(250);
2.17 + Thread.sleep(250);
2.18 repaint()
2.19 }
2.20 }
2.21 @@ -147,7 +147,7 @@
2.22 }
2.23 }
2.24 def mouseMoved(e: MouseEvent ) {
2.25 - EventUtil.drawBoxAt(e.getPoint())
2.26 + //EventUtil.drawBoxAt(e.getPoint())
2.27 repaint()
2.28 }
2.29 // \--- enforced by trait MouseMotionListener --------------------------------/
3.1 --- a/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala Tue Sep 12 10:38:02 2017 +0200
3.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/AstInfoUtil.scala Tue Sep 12 12:02:50 2017 +0200
3.3 @@ -34,10 +34,9 @@
3.4 case _ => false
3.5
3.6 }
3.7 - //TODOWN def FirstChild(ast: Ast): Option[Ast] = ...
3.8 - def FirstChild(ast: Ast) = ast match {
3.9 - case Appl(asts) => asts.head
3.10 - case _ => null
3.11 + def FirstChild(ast: Ast) : Option[Ast] = ast match {
3.12 + case Appl(asts) => Some(asts.head)
3.13 + case _ => None
3.14 }
3.15 def NextChild(parent: Ast, ast: Ast) : Ast = parent match {
3.16 case Appl(asts) => {
3.17 @@ -65,23 +64,22 @@
3.18 }
3.19 case _ => ast
3.20 }
3.21 - //TODOWN ..: Option[Ast] = ...
3.22 - def Parent(root: Ast, ast: Ast) : Ast = root match {
3.23 + def Parent(root: Ast, ast: Ast) : Option[Ast] = root match {
3.24 case Appl(asts) => {
3.25 for (a <- asts) {
3.26 if (a eq ast) {
3.27 - return root
3.28 + return Some(root)
3.29 }
3.30 }
3.31 for (a <- asts) {
3.32 - var child = Parent(a, ast)
3.33 - if ( child != null) {
3.34 - return child
3.35 - }
3.36 + Parent(a, ast) match {
3.37 + case Some(a) => return Some(a)
3.38 + case None => {}
3.39 + }
3.40 }
3.41 - return null
3.42 + return None
3.43 }
3.44 - case _ => null
3.45 + case _ => None
3.46 }
3.47 def hasBox(ast: Ast) : Boolean = ast match {
3.48 case Constant(str) if str.startsWith("BOX") => true
4.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala Tue Sep 12 10:38:02 2017 +0200
4.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EditingUtil.scala Tue Sep 12 12:02:50 2017 +0200
4.3 @@ -108,7 +108,11 @@
4.4 case Appl(c::a) => Appl(Appl(List(c, Constant("CURSOR"))) :: a)
4.5 case _ => Constant("GAP")
4.6 }
4.7 - c.setAst(TransformAstUtil.Update(c.getAst(), AstInfoUtil.Parent(c.getAst(), cursorAst), (a) => newOperatorAst))
4.8 + AstInfoUtil.Parent(c.getAst(), cursorAst) match {
4.9 + case Some(pa) => c.setAst(TransformAstUtil.Update(c.getAst(), pa, (a) => newOperatorAst))
4.10 + case None => {}
4.11 + }
4.12 +
4.13 None
4.14 }
4.15 }
5.1 --- a/isac-java/src/java/isac/gui/mawen/editor/EventUtil.scala Tue Sep 12 10:38:02 2017 +0200
5.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/EventUtil.scala Tue Sep 12 12:02:50 2017 +0200
5.3 @@ -46,11 +46,7 @@
5.4 f(g, box)
5.5 }
5.6 }
5.7 - //TODOWN unused
5.8 - def CreateMouseMotionHandler(c: AstContainer) : MouseMotionListener = new MouseMotionListener() {
5.9 - def mouseDragged(e:MouseEvent) {}
5.10 - def mouseMoved(e: MouseEvent ) {}
5.11 - }
5.12 +
5.13 def CreateMouseWheelHandler(c: AstContainer) : MouseWheelListener = new MouseWheelListener() {
5.14 def mouseWheelMoved(e: MouseWheelEvent): Unit = {
5.15 if (Settings.isZoomAllowed) {
6.1 --- a/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala Tue Sep 12 10:38:02 2017 +0200
6.2 +++ b/isac-java/src/java/isac/gui/mawen/editor/TransformAstUtil.scala Tue Sep 12 12:02:50 2017 +0200
6.3 @@ -37,8 +37,12 @@
6.4 if (boxAst != null) {// check if there is a box
6.5 val boxAstElem = TransformAstUtil.UnBox(boxAst) // get ast from Appl(Cursor, ast)
6.6 val unboxedroot = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.UnBox) // remove Box from Root Ast
6.7 - val parentAst = AstInfoUtil.Parent(unboxedroot, boxAstElem)
6.8 - c.setAst(TransformAstUtil.Update(unboxedroot, AstInfoUtil.NextChild(parentAst, boxAstElem), TransformAstUtil.Box))
6.9 + AstInfoUtil.Parent(unboxedroot, boxAstElem) match {
6.10 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedroot, AstInfoUtil.NextChild(parentAst, boxAstElem), TransformAstUtil.Box))
6.11 + case None => {}
6.12 + }
6.13 +
6.14 +
6.15 }
6.16 }
6.17 def BoxPrevChild(c: AstContainer) = {
6.18 @@ -46,7 +50,11 @@
6.19 if (boxAst != null) {// check if there is a box
6.20 val boxAstElem = TransformAstUtil.UnBox(boxAst)
6.21 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.UnBox)
6.22 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.PrevChild(AstInfoUtil.Parent(unboxedAst, boxAstElem), boxAstElem), TransformAstUtil.Box))
6.23 + AstInfoUtil.Parent(unboxedAst, boxAstElem) match {
6.24 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.PrevChild(parentAst, boxAstElem), TransformAstUtil.Box))
6.25 + case None => {}
6.26 + }
6.27 +
6.28 }
6.29 }
6.30 def BoxParent(c: AstContainer) = {
6.31 @@ -54,7 +62,11 @@
6.32 if (boxAst != null) {// check if there is a box
6.33 val boxAstElem = TransformAstUtil.UnBox(boxAst)
6.34 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.UnBox)
6.35 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.Parent(unboxedAst, boxAstElem), TransformAstUtil.Box))
6.36 + AstInfoUtil.Parent(unboxedAst, boxAstElem) match {
6.37 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedAst, parentAst, TransformAstUtil.Box))
6.38 + case None => {}
6.39 + }
6.40 +
6.41 }
6.42 }
6.43 def BoxChild(c: AstContainer) = {
6.44 @@ -63,7 +75,11 @@
6.45 val boxAstElem = TransformAstUtil.UnBox(boxAst)
6.46 if (AstInfoUtil.FirstChild(boxAstElem) != null) {
6.47 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.UnBox)
6.48 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.FirstChild(boxAstElem), TransformAstUtil.Box))
6.49 + AstInfoUtil.FirstChild(boxAstElem) match {
6.50 + case Some(a) => c.setAst(TransformAstUtil.Update(unboxedAst, a, TransformAstUtil.Box))
6.51 + case None => {}
6.52 + }
6.53 +
6.54 }
6.55 }
6.56 }
6.57 @@ -72,8 +88,11 @@
6.58 if (boxAst != null) {
6.59 val boxAstElem = TransformAstUtil.CursorToAst(boxAst) // get ast from Appl(Cursor, ast)
6.60 val unboxedroot = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.CursorToAst) // remove Box from Root Ast
6.61 - val parentAst = AstInfoUtil.Parent(unboxedroot, boxAstElem)
6.62 - c.setAst(TransformAstUtil.Update(unboxedroot, AstInfoUtil.NextChild(parentAst, boxAstElem), TransformAstUtil.AstToCursor))
6.63 + AstInfoUtil.Parent(unboxedroot, boxAstElem) match {
6.64 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedroot, AstInfoUtil.NextChild(parentAst, boxAstElem), TransformAstUtil.AstToCursor))
6.65 + case None => {}
6.66 + }
6.67 +
6.68 }
6.69 }
6.70 def CursorPrevChild(c: AstContainer) = {
6.71 @@ -81,7 +100,11 @@
6.72 if (boxAst != null) {// check if there is a box
6.73 val boxAstElem = TransformAstUtil.CursorToAst(boxAst)
6.74 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.CursorToAst)
6.75 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.PrevChild(AstInfoUtil.Parent(unboxedAst, boxAstElem), boxAstElem), TransformAstUtil.AstToCursor))
6.76 + AstInfoUtil.Parent(unboxedAst, boxAstElem) match {
6.77 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.PrevChild(parentAst, boxAstElem), TransformAstUtil.AstToCursor))
6.78 + case None => {}
6.79 + }
6.80 +
6.81 }
6.82 }
6.83 def CursorParent(c: AstContainer) = {
6.84 @@ -89,7 +112,10 @@
6.85 if (boxAst != null) {// check if there is a box
6.86 val boxAstElem = TransformAstUtil.CursorToAst(boxAst)
6.87 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.CursorToAst)
6.88 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.Parent(unboxedAst, boxAstElem), TransformAstUtil.AstToCursor))
6.89 + AstInfoUtil.Parent(unboxedAst, boxAstElem) match {
6.90 + case Some(parentAst) => c.setAst(TransformAstUtil.Update(unboxedAst, parentAst, TransformAstUtil.AstToCursor))
6.91 + case None => {}
6.92 + }
6.93 }
6.94 }
6.95 def CursorChild(c: AstContainer) = {
6.96 @@ -98,7 +124,11 @@
6.97 val boxAstElem = TransformAstUtil.CursorToAst(boxAst)
6.98 if (AstInfoUtil.FirstChild(boxAstElem) != null) {
6.99 val unboxedAst = TransformAstUtil.Update(c.getAst(), boxAst, TransformAstUtil.CursorToAst)
6.100 - c.setAst(TransformAstUtil.Update(unboxedAst, AstInfoUtil.FirstChild(boxAstElem), TransformAstUtil.AstToCursor))
6.101 + AstInfoUtil.FirstChild(boxAstElem) match {
6.102 + case Some(a) => c.setAst(TransformAstUtil.Update(unboxedAst, a, TransformAstUtil.AstToCursor))
6.103 + case None => {}
6.104 + }
6.105 +
6.106 }
6.107 }
6.108 }