exmmt-commit Mailing List for Eclipse XML Meta-Modeling Tools
Status: Inactive
Brought to you by:
lgrammel
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(28) |
Jun
(81) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
|
Dec
|
---|
From: <lgr...@us...> - 2006-10-12 20:07:13
|
Revision: 124 http://svn.sourceforge.net/exmmt/?rev=124&view=rev Author: lgrammel Date: 2006-10-12 13:07:11 -0700 (Thu, 12 Oct 2006) Log Message: ----------- Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 20:02:56 UTC (rev 123) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 20:07:11 UTC (rev 124) @@ -32,7 +32,6 @@ void setPosition(Point position); - // @tag todo.split: into moveHorizontal, moveVertical void moveHorizontal(int deltaX); Point getPosition(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 20:03:02
|
Revision: 123 http://svn.sourceforge.net/exmmt/?rev=123&view=rev Author: lgrammel Date: 2006-10-12 13:02:56 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 19:56:27 UTC (rev 122) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 20:02:56 UTC (rev 123) @@ -31,9 +31,8 @@ gc.drawText(text, position.x, position.y); } - public void changePosition(int deltaX, int deltaY) { + public void moveHorizontal(int deltaX) { position.x += deltaX; - position.y += deltaY; } public void drawFocusRectangle(Rectangle size) { Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 19:56:27 UTC (rev 122) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 20:02:56 UTC (rev 123) @@ -33,7 +33,7 @@ void setPosition(Point position); // @tag todo.split: into moveHorizontal, moveVertical - void changePosition(int deltaX, int deltaY); + void moveHorizontal(int deltaX); Point getPosition(); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 19:56:27 UTC (rev 122) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 20:02:56 UTC (rev 123) @@ -68,7 +68,7 @@ for (IRenderer renderer : subRenderers) { renderer.render(drawArea); - drawArea.changePosition(renderer.getSize().width, 0); + drawArea.moveHorizontal(renderer.getSize().width); } drawArea.setPosition(position); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 19:56:27 UTC (rev 122) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 20:02:56 UTC (rev 123) @@ -125,7 +125,7 @@ renderer.render(drawArea); expect(renderer.getSize()).andReturn(rectangle); - drawArea.changePosition(rectangle.width, 0); + drawArea.moveHorizontal(rectangle.width); } private void expectSizeCalculation(ISizeCalculator sizeCalculator, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 19:56:29
|
Revision: 122 http://svn.sourceforge.net/exmmt/?rev=122&view=rev Author: lgrammel Date: 2006-10-12 12:56:27 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 18:54:59 UTC (rev 121) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 19:56:27 UTC (rev 122) @@ -1,6 +1,7 @@ package net.sourceforge.exmmt; import net.sourceforge.exmmt.graphics.IDrawArea; +import net.sourceforge.exmmt.renderer.IRenderer; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; @@ -43,5 +44,11 @@ gc.drawRectangle(position.x, position.y, size.width, size.height); gc.setBackground(oldBackground); } + + public void finishDrawing(IRenderer renderer) { + } + + public void startDrawing(IRenderer renderer) { + } } \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 18:54:59 UTC (rev 121) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 19:56:27 UTC (rev 122) @@ -12,15 +12,27 @@ */ package net.sourceforge.exmmt.graphics; +import net.sourceforge.exmmt.renderer.IRenderer; + import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +// @tag todo: positions should be relative to the current position from the +// superior node +// @tag todo: save the complete context on the stack +// @tag todo.rename +// @tag todo.move: move gc abstract away to create testeable drawarea implementation public interface IDrawArea { + void startDrawing(IRenderer renderer); + + void finishDrawing(IRenderer renderer); + void drawText(String text); - + void setPosition(Point position); - + + // @tag todo.split: into moveHorizontal, moveVertical void changePosition(int deltaX, int deltaY); Point getPosition(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 18:55:14
|
Revision: 121 http://svn.sourceforge.net/exmmt/?rev=121&view=rev Author: lgrammel Date: 2006-10-12 11:54:59 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 18:47:48 UTC (rev 120) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 18:54:59 UTC (rev 121) @@ -4,6 +4,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; @@ -11,42 +12,35 @@ private final GC gc; - private int x; + private Point position; - private int y; - public DefaultDrawArea(GC gc) { this.gc = gc; } - public void setPosition(int x, int y) { - this.x = x; - this.y = y; + public void setPosition(Point position) { + this.position = position; } - public int getY() { - return y; + public Point getPosition() { + return position; } - public int getX() { - return x; - } - public void drawText(String text) { - gc.drawText(text, x, y); + gc.drawText(text, position.x, position.y); } public void changePosition(int deltaX, int deltaY) { - x += deltaX; - y += deltaY; + position.x += deltaX; + position.y += deltaY; } public void drawFocusRectangle(Rectangle size) { Color color = new Color(gc.getDevice(), new RGB(128, 128, 255)); Color oldBackground = gc.getBackground(); gc.setBackground(color); - gc.fillRectangle(x, y, size.width, size.height); - gc.drawRectangle(x, y, size.width, size.height); + gc.fillRectangle(position.x, position.y, size.width, size.height); + gc.drawRectangle(position.x, position.y, size.width, size.height); gc.setBackground(oldBackground); } Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 18:47:48 UTC (rev 120) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 18:54:59 UTC (rev 121) @@ -127,11 +127,10 @@ List<Point> locations = renderer.getLocations(focusedElementRenderer); Rectangle size = focusedElementRenderer.getSize(); for (Point point : locations) { - int x = area.getX(); - int y = area.getY(); - area.setPosition(point.x, point.y); + Point originalPoint = area.getPosition(); + area.setPosition(point); area.drawFocusRectangle(size); - area.setPosition(x, y); + area.setPosition(originalPoint); } } Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 18:47:48 UTC (rev 120) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 18:54:59 UTC (rev 121) @@ -12,20 +12,18 @@ */ package net.sourceforge.exmmt.graphics; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; -// @tag todo.introduce: Point class public interface IDrawArea { void drawText(String text); - void setPosition(int x, int y); + void setPosition(Point position); void changePosition(int deltaX, int deltaY); - int getX(); - - int getY(); + Point getPosition(); void drawFocusRectangle(Rectangle size); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:47:48 UTC (rev 120) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:54:59 UTC (rev 121) @@ -64,15 +64,14 @@ // drawarea with point stack, start and finish methods // extract render as template method to superclass afterwards public void render(IDrawArea drawArea) { - int originalX = drawArea.getX(); - int originalY = drawArea.getY(); + Point position = drawArea.getPosition(); for (IRenderer renderer : subRenderers) { renderer.render(drawArea); drawArea.changePosition(renderer.getSize().width, 0); } - drawArea.setPosition(originalX, originalY); + drawArea.setPosition(position); } public void add(IRenderer subRenderer) { Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 18:47:48 UTC (rev 120) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 18:54:59 UTC (rev 121) @@ -139,13 +139,11 @@ public void render() { IDrawArea drawArea = createMock(IDrawArea.class); - int startingX = 1; - int startingY = 2; + Point position = new Point(1,2); - expect(drawArea.getX()).andReturn(startingX); - expect(drawArea.getY()).andReturn(startingY); + expect(drawArea.getPosition()).andReturn(position); - drawArea.setPosition(startingX, startingY); + drawArea.setPosition(position); expectRendering(drawArea, childRenderer1, new Rectangle(0, 0, 10, 10)); expectRendering(drawArea, childRenderer2, new Rectangle(0, 0, 11, 11)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 18:47:53
|
Revision: 120 http://svn.sourceforge.net/exmmt/?rev=120&view=rev Author: lgrammel Date: 2006-10-12 11:47:48 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java 2006-10-12 18:39:19 UTC (rev 119) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java 2006-10-12 18:47:48 UTC (rev 120) @@ -1,6 +1,3 @@ -/** - * - */ package net.sourceforge.exmmt; import net.sourceforge.exmmt.graphics.ISizeCalculator; Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:39:19 UTC (rev 119) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:47:48 UTC (rev 120) @@ -60,6 +60,9 @@ return list; } + // @tag idea: callback to drawArea (visitor pattern) + // drawarea with point stack, start and finish methods + // extract render as template method to superclass afterwards public void render(IDrawArea drawArea) { int originalX = drawArea.getX(); int originalY = drawArea.getY(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 18:39:23
|
Revision: 119 http://svn.sourceforge.net/exmmt/?rev=119&view=rev Author: lgrammel Date: 2006-10-12 11:39:19 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 18:17:30 UTC (rev 118) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 18:39:19 UTC (rev 119) @@ -2,7 +2,9 @@ import net.sourceforge.exmmt.graphics.IDrawArea; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; public class DefaultDrawArea implements IDrawArea { @@ -40,7 +42,12 @@ } public void drawFocusRectangle(Rectangle size) { + Color color = new Color(gc.getDevice(), new RGB(128, 128, 255)); + Color oldBackground = gc.getBackground(); + gc.setBackground(color); + gc.fillRectangle(x, y, size.width, size.height); gc.drawRectangle(x, y, size.width, size.height); + gc.setBackground(oldBackground); } } \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java 2006-10-12 18:17:30 UTC (rev 118) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java 2006-10-12 18:39:19 UTC (rev 119) @@ -19,9 +19,12 @@ public Rectangle calculateSize(String text) { TextLayout textLayout = new TextLayout(gc.getDevice()); + textLayout.setFont(gc.getFont()); textLayout.setText(text); return textLayout.getBounds(); + + // @tag todo.dispose: textlayout } } \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 18:17:30 UTC (rev 118) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 18:39:19 UTC (rev 119) @@ -59,7 +59,7 @@ case SWT.KeyDown: handleKeyEvent(event); NewModelText.this.editor.control.redraw(); -// NewModelText.this.editor.handleKeyDown(event); + // NewModelText.this.editor.handleKeyDown(event); break; } } @@ -110,24 +110,29 @@ IDrawArea area = new DefaultDrawArea(gc); ISizeCalculator sizeCalculator = new DefaultSizeCalculator(gc); - // clean solution: method that gathers all the positions the focused - // element - // appears at - IRenderer focusedElementRenderer = focus.getFocusedElement() - .getRenderer(); IRenderer renderer = controller.getRenderer(); renderer.calculateSize(sizeCalculator); + + drawFocus(area, renderer); + renderer.render(area); + color.dispose(); + } + + private void drawFocus(IDrawArea area, IRenderer renderer) { + IRenderer focusedElementRenderer = focus.getFocusedElement() + .getRenderer(); List<Point> locations = renderer.getLocations(focusedElementRenderer); Rectangle size = focusedElementRenderer.getSize(); for (Point point : locations) { + int x = area.getX(); + int y = area.getY(); area.setPosition(point.x, point.y); area.drawFocusRectangle(size); + area.setPosition(x, y); } - - color.dispose(); } private Controller createController() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 18:17:35
|
Revision: 118 http://svn.sourceforge.net/exmmt/?rev=118&view=rev Author: lgrammel Date: 2006-10-12 11:17:30 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:03:10 UTC (rev 117) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:17:30 UTC (rev 118) @@ -45,8 +45,16 @@ public List<Point> getLocations(IRenderer renderer) { List<Point> list = super.getLocations(renderer); + int currentY = 0; + for (IRenderer subRenderer : subRenderers) { - list.addAll(subRenderer.getLocations(renderer)); + List<Point> subLocations = subRenderer.getLocations(renderer); + + for (Point location : subLocations) { + list.add(new Point(currentY + location.x, location.y)); + } + + currentY += subRenderer.getSize().width; } return list; Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 18:03:10 UTC (rev 117) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 18:17:30 UTC (rev 118) @@ -76,10 +76,14 @@ @Override public void getSelfLocation() { + Rectangle size = new Rectangle(2, 3, 4, 5); + expect(childRenderer1.getLocations(renderer)).andReturn( new ArrayList<Point>()); + expect(childRenderer1.getSize()).andReturn(size); expect(childRenderer2.getLocations(renderer)).andReturn( new ArrayList<Point>()); + expect(childRenderer2.getSize()).andReturn(size); replay(childRenderer1, childRenderer2); super.getSelfLocation(); @@ -90,19 +94,23 @@ @Test public void getSubLocations() { Point point = new Point(2, 2); + Rectangle child1Size = new Rectangle(2, 3, 4, 5); List<Point> list = new ArrayList<Point>(); list.add(point); - expect(childRenderer1.getLocations(childRenderer1)).andReturn(list); - expect(childRenderer2.getLocations(childRenderer1)).andReturn( + expect(childRenderer1.getLocations(childRenderer2)).andReturn( new ArrayList<Point>()); + expect(childRenderer1.getSize()).andReturn(child1Size); + expect(childRenderer2.getLocations(childRenderer2)).andReturn(list); + expect(childRenderer2.getSize()).andReturn(child1Size); replay(childRenderer1, childRenderer2); - List<Point> locations = renderer.getLocations(childRenderer1); + List<Point> locations = renderer.getLocations(childRenderer2); assertEquals(1, locations.size()); - assertEquals(point, locations.get(0)); + assertEquals(new Point(point.x + child1Size.width, point.y), locations + .get(0)); verify(childRenderer1, childRenderer2); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 18:03:14
|
Revision: 117 http://svn.sourceforge.net/exmmt/?rev=117&view=rev Author: lgrammel Date: 2006-10-12 11:03:10 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 17:54:31 UTC (rev 116) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 18:03:10 UTC (rev 117) @@ -18,6 +18,7 @@ import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; public class HorizontalSequenceRenderer extends AbstractRenderer { @@ -30,9 +31,9 @@ for (IRenderer renderer : subRenderers) { renderer.calculateSize(sizeCalculator); - + Rectangle bounds = renderer.getSize(); - + height = Math.max(height, bounds.height); width += bounds.width; } @@ -40,6 +41,17 @@ setSize(new Rectangle(0, 0, width, height)); } + @Override + public List<Point> getLocations(IRenderer renderer) { + List<Point> list = super.getLocations(renderer); + + for (IRenderer subRenderer : subRenderers) { + list.addAll(subRenderer.getLocations(renderer)); + } + + return list; + } + public void render(IDrawArea drawArea) { int originalX = drawArea.getX(); int originalY = drawArea.getY(); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 17:54:31 UTC (rev 116) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 18:03:10 UTC (rev 117) @@ -17,24 +17,26 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + import junit.framework.JUnit4TestAdapter; import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.junit.Before; import org.junit.Test; -public class HorizontalSequenceRendererTest { +public class HorizontalSequenceRendererTest extends AbstractRendererTest { // @tag compability: Junit 3.8.1 public static junit.framework.Test suite() { return new JUnit4TestAdapter(HorizontalSequenceRendererTest.class); } - private HorizontalSequenceRenderer renderer; - private IRenderer childRenderer1; private IRenderer childRenderer2; @@ -62,6 +64,54 @@ verifyChildRenderers(); } + @Before + public void createChildRenderers() { + childRenderer1 = createMock(IRenderer.class); + childRenderer2 = createMock(IRenderer.class); + + // @tag todo.useGenerics + ((HorizontalSequenceRenderer) renderer).add(childRenderer1); + ((HorizontalSequenceRenderer) renderer).add(childRenderer2); + } + + @Override + public void getSelfLocation() { + expect(childRenderer1.getLocations(renderer)).andReturn( + new ArrayList<Point>()); + expect(childRenderer2.getLocations(renderer)).andReturn( + new ArrayList<Point>()); + replay(childRenderer1, childRenderer2); + + super.getSelfLocation(); + + verify(childRenderer1, childRenderer2); + } + + @Test + public void getSubLocations() { + Point point = new Point(2, 2); + + List<Point> list = new ArrayList<Point>(); + list.add(point); + + expect(childRenderer1.getLocations(childRenderer1)).andReturn(list); + expect(childRenderer2.getLocations(childRenderer1)).andReturn( + new ArrayList<Point>()); + replay(childRenderer1, childRenderer2); + + List<Point> locations = renderer.getLocations(childRenderer1); + + assertEquals(1, locations.size()); + assertEquals(point, locations.get(0)); + + verify(childRenderer1, childRenderer2); + } + + @Override + protected IRenderer createRenderer() { + return new HorizontalSequenceRenderer(); + } + private void expectRendering(IDrawArea drawArea, IRenderer renderer, Rectangle rectangle) { @@ -78,12 +128,6 @@ } @Test - public void isRenderer() { - assertTrue(IRenderer.class - .isAssignableFrom(HorizontalSequenceRenderer.class)); - } - - @Test public void render() { IDrawArea drawArea = createMock(IDrawArea.class); @@ -112,17 +156,6 @@ replay(childRenderer2); } - @Before - public void setUp() { - renderer = new HorizontalSequenceRenderer(); - - childRenderer1 = createMock(IRenderer.class); - childRenderer2 = createMock(IRenderer.class); - - renderer.add(childRenderer1); - renderer.add(childRenderer2); - } - private void verifyChildRenderers() { verify(childRenderer1); verify(childRenderer2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 17:54:40
|
Revision: 116 http://svn.sourceforge.net/exmmt/?rev=116&view=rev Author: lgrammel Date: 2006-10-12 10:54:31 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java 2006-10-12 17:43:30 UTC (rev 115) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java 2006-10-12 17:54:31 UTC (rev 116) @@ -54,7 +54,7 @@ IModelElement rootArea; - private Canvas control; + Canvas control; private Document document; Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 17:43:30 UTC (rev 115) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 17:54:31 UTC (rev 116) @@ -42,6 +42,10 @@ private Caret caret; + private Controller controller; + + private Focus focus; + public NewModelText(NewModelEditor editor, Composite parent, int style) { super(parent, style); this.editor = editor; @@ -53,7 +57,9 @@ handlePaint(event); break; case SWT.KeyDown: - NewModelText.this.editor.handleKeyDown(event); + handleKeyEvent(event); + NewModelText.this.editor.control.redraw(); +// NewModelText.this.editor.handleKeyDown(event); break; } } @@ -64,8 +70,28 @@ caret = new Caret(this, SWT.NULL); setCaret(caret); + + controller = createController(); + focus = new Focus(controller); } + protected void handleKeyEvent(Event event) { + if ((event.stateMask & SWT.CTRL) == SWT.CTRL) { + if (event.keyCode == SWT.ARROW_UP) { + focus.moveToParent(); + } + if (event.keyCode == SWT.ARROW_DOWN) { + focus.moveToChild(); + } + if (event.keyCode == SWT.ARROW_LEFT) { + focus.moveToPreviousSibling(); + } + if (event.keyCode == SWT.ARROW_RIGHT) { + focus.moveToNextSibling(); + } + } + } + public void dispose() { caret.dispose(); super.dispose(); @@ -84,21 +110,16 @@ IDrawArea area = new DefaultDrawArea(gc); ISizeCalculator sizeCalculator = new DefaultSizeCalculator(gc); - Controller controller = createController(); - Focus focus = new Focus(controller); - - // @tag problem: focus rendering needs exact element position - // one element may have more than one position if it is rendered at different - // locations - - // clean solution: method that gathers all the positions the focused element + // clean solution: method that gathers all the positions the focused + // element // appears at - IRenderer focusedElementRenderer = focus.getFocusedElement().getRenderer(); + IRenderer focusedElementRenderer = focus.getFocusedElement() + .getRenderer(); IRenderer renderer = controller.getRenderer(); - + renderer.calculateSize(sizeCalculator); renderer.render(area); - + List<Point> locations = renderer.getLocations(focusedElementRenderer); Rectangle size = focusedElementRenderer.getSize(); for (Point point : locations) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 17:43:36
|
Revision: 115 http://svn.sourceforge.net/exmmt/?rev=115&view=rev Author: lgrammel Date: 2006-10-12 10:43:30 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 17:38:20 UTC (rev 114) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 17:43:30 UTC (rev 115) @@ -1,11 +1,9 @@ -/** - * - */ package net.sourceforge.exmmt; import net.sourceforge.exmmt.graphics.IDrawArea; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; public class DefaultDrawArea implements IDrawArea { @@ -40,4 +38,9 @@ x += deltaX; y += deltaY; } + + public void drawFocusRectangle(Rectangle size) { + gc.drawRectangle(x, y, size.width, size.height); + } + } \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 17:38:20 UTC (rev 114) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 17:43:30 UTC (rev 115) @@ -12,6 +12,8 @@ */ package net.sourceforge.exmmt; +import java.util.List; + import net.sourceforge.exmmt.builder.Controller; import net.sourceforge.exmmt.builder.ControllerTreeBuilder; import net.sourceforge.exmmt.graphics.IDrawArea; @@ -22,7 +24,9 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Caret; import org.eclipse.swt.widgets.Composite; @@ -95,6 +99,12 @@ renderer.calculateSize(sizeCalculator); renderer.render(area); + List<Point> locations = renderer.getLocations(focusedElementRenderer); + Rectangle size = focusedElementRenderer.getSize(); + for (Point point : locations) { + area.setPosition(point.x, point.y); + area.drawFocusRectangle(size); + } color.dispose(); } Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 17:38:20 UTC (rev 114) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 17:43:30 UTC (rev 115) @@ -12,6 +12,8 @@ */ package net.sourceforge.exmmt.graphics; +import org.eclipse.swt.graphics.Rectangle; + // @tag todo.introduce: Point class public interface IDrawArea { @@ -25,4 +27,6 @@ int getY(); + void drawFocusRectangle(Rectangle size); + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 17:38:27
|
Revision: 114 http://svn.sourceforge.net/exmmt/?rev=114&view=rev Author: lgrammel Date: 2006-10-12 10:38:20 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java 2006-10-12 17:27:46 UTC (rev 113) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java 2006-10-12 17:38:20 UTC (rev 114) @@ -12,9 +12,12 @@ */ package net.sourceforge.exmmt.renderer; +import java.util.List; + import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; public abstract class DelegatingRenderer extends AbstractRenderer { @@ -22,6 +25,16 @@ public void calculateSize(ISizeCalculator sizeCalculator) { getDelegate().calculateSize(sizeCalculator); } + + @Override + public List<Point> getLocations(IRenderer renderer) { + List<Point> list = super.getLocations(renderer); + List<Point> subLocations = getDelegate().getLocations(renderer); + + list.addAll(subLocations); + + return list; + } protected abstract IRenderer getDelegate(); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java 2006-10-12 17:27:46 UTC (rev 113) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java 2006-10-12 17:38:20 UTC (rev 114) @@ -17,10 +17,15 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + import junit.framework.JUnit4TestAdapter; import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.junit.Before; import org.junit.Test; @@ -35,28 +40,53 @@ mockRenderer.render(drawArea); - replay(drawArea); - replay(mockRenderer); + replay(mockRenderer, drawArea); renderer.render(drawArea); - verify(drawArea); + verify(mockRenderer, drawArea); + } + + @Override + public void getSelfLocation() { + expect(mockRenderer.getLocations(renderer)).andReturn( + new ArrayList<Point>()); + replay(mockRenderer); + + super.getSelfLocation(); + verify(mockRenderer); } @Test + public void getSubLocations() { + Point point = new Point(2, 2); + + List<Point> list = new ArrayList<Point>(); + list.add(point); + + expect(mockRenderer.getLocations(mockRenderer)).andReturn(list); + replay(mockRenderer); + + List<Point> locations = renderer.getLocations(mockRenderer); + + assertEquals(1, locations.size()); + assertEquals(point, locations.get(0)); + + verify(mockRenderer); + } + + @Test public void calculateSize() { ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); mockRenderer.calculateSize(sizeCalculator); - replay(sizeCalculator); - replay(mockRenderer); + replay(sizeCalculator, mockRenderer); renderer.calculateSize(sizeCalculator); - verify(sizeCalculator); - verify(mockRenderer); + verify(sizeCalculator, mockRenderer); } @Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 17:28:01
|
Revision: 113 http://svn.sourceforge.net/exmmt/?rev=113&view=rev Author: lgrammel Date: 2006-10-12 10:27:46 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/AbstractRenderer.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/IRenderer.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/NullRenderer.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java Added Paths: ----------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AbstractRendererTest.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 17:27:46 UTC (rev 113) @@ -15,6 +15,9 @@ import net.sourceforge.exmmt.builder.Controller; import net.sourceforge.exmmt.builder.ControllerTreeBuilder; import net.sourceforge.exmmt.graphics.IDrawArea; +import net.sourceforge.exmmt.graphics.ISizeCalculator; +import net.sourceforge.exmmt.navigation.Focus; +import net.sourceforge.exmmt.renderer.IRenderer; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -65,38 +68,49 @@ } void handlePaint(Event event) { - System.out.println("handlePaint"); final GC gc = event.gc; Color color = new Color(gc.getDevice(), new RGB(255, 255, 255)); - Color color2 = new Color(gc.getDevice(), new RGB(200, 255, 255)); - Color color3 = new Color(gc.getDevice(), new RGB(255, 200, 200)); gc.setBackground(color); drawBackground(gc, getClientArea().x, getClientArea().y, getClientArea().width, getClientArea().height); - // create draw area - // call render with draw area + // @tag todo.test: algorithm once extracted + // @tag todo.combine IDrawArea area = new DefaultDrawArea(gc); + ISizeCalculator sizeCalculator = new DefaultSizeCalculator(gc); - ControllerTreeBuilder builder = new ControllerTreeBuilder(); - Element root = getDocumentRoot(); - Controller controller = builder.build(root); + Controller controller = createController(); + Focus focus = new Focus(controller); - controller.getRenderer().calculateSize(new DefaultSizeCalculator(gc)); - controller.getRenderer().render(area); + // @tag problem: focus rendering needs exact element position + // one element may have more than one position if it is rendered at different + // locations + + // clean solution: method that gathers all the positions the focused element + // appears at + IRenderer focusedElementRenderer = focus.getFocusedElement().getRenderer(); + IRenderer renderer = controller.getRenderer(); + + renderer.calculateSize(sizeCalculator); + renderer.render(area); + color.dispose(); - color2.dispose(); - color3.dispose(); } + private Controller createController() { + ControllerTreeBuilder builder = new ControllerTreeBuilder(); + Element root = getDocumentRoot(); + return builder.build(root); + } + private Element getDocumentRoot() { Element root = new Element("root"); - - root.setAttribute("blah","blub"); - root.setAttribute("blah2","blub222"); - + + root.setAttribute("blah", "blub"); + root.setAttribute("blah2", "blub222"); + return root; } Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/AbstractRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/AbstractRenderer.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/AbstractRenderer.java 2006-10-12 17:27:46 UTC (rev 113) @@ -12,6 +12,10 @@ */ package net.sourceforge.exmmt.renderer; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; public abstract class AbstractRenderer implements IRenderer { @@ -26,4 +30,14 @@ this.size = size; } + public List<Point> getLocations(IRenderer renderer) { + ArrayList<Point> result = new ArrayList<Point>(); + + if (renderer == this) { + result.add(new Point(0,0)); + } + + return result; + } + } \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/DelegatingRenderer.java 2006-10-12 17:27:46 UTC (rev 113) @@ -17,7 +17,7 @@ import org.eclipse.swt.graphics.Rectangle; -public abstract class DelegatingRenderer implements IRenderer { +public abstract class DelegatingRenderer extends AbstractRenderer { public void calculateSize(ISizeCalculator sizeCalculator) { getDelegate().calculateSize(sizeCalculator); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/IRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/IRenderer.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/IRenderer.java 2006-10-12 17:27:46 UTC (rev 113) @@ -12,13 +12,18 @@ */ package net.sourceforge.exmmt.renderer; +import java.util.List; + import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; public interface IRenderer { + List<Point> getLocations(IRenderer renderer); + void render(IDrawArea drawArea); void calculateSize(ISizeCalculator sizeCalculator); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/NullRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/NullRenderer.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/NullRenderer.java 2006-10-12 17:27:46 UTC (rev 113) @@ -12,6 +12,7 @@ */ package net.sourceforge.exmmt.renderer; + import org.eclipse.swt.graphics.Rectangle; import net.sourceforge.exmmt.graphics.IDrawArea; @@ -22,7 +23,7 @@ public NullRenderer() { setSize(new Rectangle(0, 0, 0, 0)); } - + public void calculateSize(ISizeCalculator sizeCalculator) { } Added: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AbstractRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AbstractRendererTest.java (rev 0) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AbstractRendererTest.java 2006-10-12 17:27:46 UTC (rev 113) @@ -0,0 +1,36 @@ +package net.sourceforge.exmmt.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.eclipse.swt.graphics.Point; +import org.junit.Before; +import org.junit.Test; + +public abstract class AbstractRendererTest { + + protected IRenderer renderer; + + protected abstract IRenderer createRenderer(); + + @Test + public void getSelfLocation() { + List<Point> locations = renderer.getLocations(renderer); + + assertEquals(1, locations.size()); + assertEquals(new Point(0, 0), locations.get(0)); + } + + @Test + public void isRenderer() { + assertTrue(IRenderer.class.isAssignableFrom(renderer.getClass())); + } + + @Before + public void setUp() { + renderer = createRenderer(); + } + +} Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java 2006-10-12 17:27:46 UTC (rev 113) @@ -17,7 +17,6 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import junit.framework.JUnit4TestAdapter; import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; @@ -26,18 +25,11 @@ import org.junit.Before; import org.junit.Test; -public class DelegatingRendererTest { +public class DelegatingRendererTest extends AbstractRendererTest { private IRenderer mockRenderer; - private DelegatingRenderer delegatingRenderer; - @Test - public void isRenderer() { - assertTrue(IRenderer.class.isAssignableFrom(DelegatingRenderer.class)); - } - - @Test public void render() { IDrawArea drawArea = createMock(IDrawArea.class); @@ -46,7 +38,7 @@ replay(drawArea); replay(mockRenderer); - delegatingRenderer.render(drawArea); + renderer.render(drawArea); verify(drawArea); verify(mockRenderer); @@ -61,7 +53,7 @@ replay(sizeCalculator); replay(mockRenderer); - delegatingRenderer.calculateSize(sizeCalculator); + renderer.calculateSize(sizeCalculator); verify(sizeCalculator); verify(mockRenderer); @@ -70,21 +62,19 @@ @Test public void getSize() { Rectangle bounds = new Rectangle(20, 20, 20, 20); - + expect(mockRenderer.getSize()).andReturn(bounds); replay(mockRenderer); - assertEquals(bounds, delegatingRenderer.getSize()); + assertEquals(bounds, renderer.getSize()); verify(mockRenderer); } - @Before - public void setUp() { - mockRenderer = createMock(IRenderer.class); - - delegatingRenderer = new DelegatingRenderer() { + @Override + protected IRenderer createRenderer() { + return new DelegatingRenderer() { @Override protected IRenderer getDelegate() { return mockRenderer; @@ -92,6 +82,11 @@ }; } + @Before + public void createMockRenderer() { + mockRenderer = createMock(IRenderer.class); + } + // Junit 3.8.1 backward compability public static junit.framework.Test suite() { return new JUnit4TestAdapter(DelegatingRendererTest.class); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java 2006-10-12 16:32:39 UTC (rev 112) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java 2006-10-12 17:27:46 UTC (rev 113) @@ -16,36 +16,34 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; + + import junit.framework.JUnit4TestAdapter; import net.sourceforge.exmmt.graphics.ISizeCalculator; import org.eclipse.swt.graphics.Rectangle; import org.junit.Test; -public class NullRendererTest { +public class NullRendererTest extends AbstractRendererTest { @Test - public void isRenderer() { - assertTrue(IRenderer.class.isAssignableFrom(NullRenderer.class)); - } - - @Test public void computeSize() { - IRenderer renderer = new NullRenderer(); - ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); replay(sizeCalculator); - + renderer.calculateSize(sizeCalculator); - + assertEquals(new Rectangle(0, 0, 0, 0), renderer.getSize()); verify(sizeCalculator); } - // Junit 3.8.1 backward compability + protected AbstractRenderer createRenderer() { + return new NullRenderer(); + } + + // @tag compability: Junit 3.8.1 public static junit.framework.Test suite() { return new JUnit4TestAdapter(NullRendererTest.class); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 16:32:47
|
Revision: 112 http://svn.sourceforge.net/exmmt/?rev=112&view=rev Author: lgrammel Date: 2006-10-12 09:32:39 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java Added Paths: ----------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java Added: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java (rev 0) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultSizeCalculator.java 2006-10-12 16:32:39 UTC (rev 112) @@ -0,0 +1,27 @@ +/** + * + */ +package net.sourceforge.exmmt; + +import net.sourceforge.exmmt.graphics.ISizeCalculator; + +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.TextLayout; + +public final class DefaultSizeCalculator implements ISizeCalculator { + + private final GC gc; + + public DefaultSizeCalculator(GC gc) { + this.gc = gc; + } + + public Rectangle calculateSize(String text) { + TextLayout textLayout = new TextLayout(gc.getDevice()); + + textLayout.setText(text); + + return textLayout.getBounds(); + } +} \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 16:30:12 UTC (rev 111) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 16:32:39 UTC (rev 112) @@ -15,14 +15,11 @@ import net.sourceforge.exmmt.builder.Controller; import net.sourceforge.exmmt.builder.ControllerTreeBuilder; import net.sourceforge.exmmt.graphics.IDrawArea; -import net.sourceforge.exmmt.graphics.ISizeCalculator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.TextLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Caret; import org.eclipse.swt.widgets.Composite; @@ -86,17 +83,7 @@ Element root = getDocumentRoot(); Controller controller = builder.build(root); - controller.getRenderer().calculateSize(new ISizeCalculator() { - - public Rectangle calculateSize(String text) { - TextLayout textLayout = new TextLayout(gc.getDevice()); - - textLayout.setText(text); - - return textLayout.getBounds(); - } - - }); + controller.getRenderer().calculateSize(new DefaultSizeCalculator(gc)); controller.getRenderer().render(area); color.dispose(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 16:30:22
|
Revision: 111 http://svn.sourceforge.net/exmmt/?rev=111&view=rev Author: lgrammel Date: 2006-10-12 09:30:12 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/.classpath net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java Modified: net.sourceforge.exmmt.test/trunk/.classpath =================================================================== --- net.sourceforge.exmmt.test/trunk/.classpath 2006-10-12 16:29:21 UTC (rev 110) +++ net.sourceforge.exmmt.test/trunk/.classpath 2006-10-12 16:30:12 UTC (rev 111) @@ -5,5 +5,6 @@ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="lib" path="lib/easymock.jar"/> <classpathentry kind="lib" path="lib/junit-4.1.jar"/> + <classpathentry kind="lib" path="/net.sourceforge.exmmt/lib/org.jdom.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-10-12 16:29:21 UTC (rev 110) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-10-12 16:30:12 UTC (rev 111) @@ -77,7 +77,7 @@ renderer = new AttributeRenderer(attribute); } - // Junit 3.8.1 backward compability + // @tag compability: Junit 3.8.1 backward compability public static junit.framework.Test suite() { return new JUnit4TestAdapter(AttributeRendererTest.class); } Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 16:29:21 UTC (rev 110) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-10-12 16:30:12 UTC (rev 111) @@ -28,16 +28,55 @@ public class HorizontalSequenceRendererTest { + // @tag compability: Junit 3.8.1 + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(HorizontalSequenceRendererTest.class); + } + private HorizontalSequenceRenderer renderer; private IRenderer childRenderer1; private IRenderer childRenderer2; - private Rectangle rectangle1; + @Test + public void computeSize() { + ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); - private Rectangle rectangle2; + Rectangle rectangle1 = new Rectangle(10, 10, 20, 30); + Rectangle rectangle2 = new Rectangle(101, 110, 120, 130); + expectSizeCalculation(sizeCalculator, childRenderer1, rectangle1); + expectSizeCalculation(sizeCalculator, childRenderer2, rectangle2); + + replay(sizeCalculator); + replayChildRenderers(); + + renderer.calculateSize(sizeCalculator); + Rectangle result = renderer.getSize(); + + assertEquals(new Rectangle(0, 0, rectangle1.width + rectangle2.width, + Math.max(rectangle1.height, rectangle2.height)), result); + + verify(sizeCalculator); + verifyChildRenderers(); + } + + private void expectRendering(IDrawArea drawArea, IRenderer renderer, + Rectangle rectangle) { + + renderer.render(drawArea); + expect(renderer.getSize()).andReturn(rectangle); + drawArea.changePosition(rectangle.width, 0); + } + + private void expectSizeCalculation(ISizeCalculator sizeCalculator, + IRenderer renderer, Rectangle rectangle) { + + renderer.calculateSize(sizeCalculator); + expect(renderer.getSize()).andReturn(rectangle); + } + @Test public void isRenderer() { assertTrue(IRenderer.class @@ -48,54 +87,29 @@ public void render() { IDrawArea drawArea = createMock(IDrawArea.class); - int oldX = 1; - int oldY = 2; - Rectangle childSize = new Rectangle(0,0,10,10); - Rectangle child2Size = new Rectangle(0,0,11,11); + int startingX = 1; + int startingY = 2; - expect(drawArea.getX()).andReturn(oldX); - expect(drawArea.getY()).andReturn(oldY); - childRenderer1.render(drawArea); - expect(childRenderer1.getSize()).andReturn(childSize); - drawArea.changePosition(childSize.width, 0); - childRenderer2.render(drawArea); - expect(childRenderer2.getSize()).andReturn(child2Size); - drawArea.changePosition(child2Size.width, 0); - drawArea.setPosition(oldX, oldY); + expect(drawArea.getX()).andReturn(startingX); + expect(drawArea.getY()).andReturn(startingY); + drawArea.setPosition(startingX, startingY); + + expectRendering(drawArea, childRenderer1, new Rectangle(0, 0, 10, 10)); + expectRendering(drawArea, childRenderer2, new Rectangle(0, 0, 11, 11)); + replay(drawArea); - replay(childRenderer1); - replay(childRenderer2); + replayChildRenderers(); renderer.render(drawArea); verify(drawArea); - verify(childRenderer1); - verify(childRenderer2); + verifyChildRenderers(); } - @Test - public void computeSize() { - ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); - - childRenderer1.calculateSize(sizeCalculator); - expect(childRenderer1.getSize()).andReturn(rectangle1); - childRenderer2.calculateSize(sizeCalculator); - expect(childRenderer2.getSize()).andReturn(rectangle2); - - replay(sizeCalculator); + private void replayChildRenderers() { replay(childRenderer1); replay(childRenderer2); - - renderer.calculateSize(sizeCalculator); - Rectangle result = renderer.getSize(); - - assertEquals(new Rectangle(0, 0, rectangle1.width + rectangle2.width, - Math.max(rectangle1.height, rectangle2.height)), result); - - verify(sizeCalculator); - verify(childRenderer1); - verify(childRenderer2); } @Before @@ -107,15 +121,11 @@ renderer.add(childRenderer1); renderer.add(childRenderer2); - - rectangle1 = new Rectangle(10, 10, 20, 30); - rectangle2 = new Rectangle(101, 110, 120, 130); - } - // Junit 3.8.1 backward compability - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(HorizontalSequenceRendererTest.class); + private void verifyChildRenderers() { + verify(childRenderer1); + verify(childRenderer2); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-10-12 16:29:31
|
Revision: 110 http://svn.sourceforge.net/exmmt/?rev=110&view=rev Author: lgrammel Date: 2006-10-12 09:29:21 -0700 (Thu, 12 Oct 2006) Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/plugin.xml net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Controller.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/ControllerTreeBuilder.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java Added Paths: ----------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java Modified: net.sourceforge.exmmt/trunk/plugin.xml =================================================================== --- net.sourceforge.exmmt/trunk/plugin.xml 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/plugin.xml 2006-10-12 16:29:21 UTC (rev 110) @@ -9,6 +9,12 @@ icon="resources/icons/editor.gif" id="net.sourceforge.exmmt.ModelEditor" name="Model Editor"/> + <editor + class="net.sourceforge.exmmt.NewModelEditor" + extensions="xml" + icon="resources/icons/editor.gif" + id="net.sourceforge.exmmt.NewModelEditor" + name="New Model Editor"/> </extension> </plugin> Added: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java (rev 0) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/DefaultDrawArea.java 2006-10-12 16:29:21 UTC (rev 110) @@ -0,0 +1,43 @@ +/** + * + */ +package net.sourceforge.exmmt; + +import net.sourceforge.exmmt.graphics.IDrawArea; + +import org.eclipse.swt.graphics.GC; + +public class DefaultDrawArea implements IDrawArea { + + private final GC gc; + + private int x; + + private int y; + + public DefaultDrawArea(GC gc) { + this.gc = gc; + } + + public void setPosition(int x, int y) { + this.x = x; + this.y = y; + } + + public int getY() { + return y; + } + + public int getX() { + return x; + } + + public void drawText(String text) { + gc.drawText(text, x, y); + } + + public void changePosition(int deltaX, int deltaY) { + x += deltaX; + y += deltaY; + } +} \ No newline at end of file Added: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java (rev 0) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelEditor.java 2006-10-12 16:29:21 UTC (rev 110) @@ -0,0 +1,317 @@ +/* $HeadURL: https://svn.sourceforge.net/svnroot/exmmt/net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/ModelEditor.java $ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorPart; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +public class NewModelEditor extends EditorPart { + + final static boolean IS_CARBON, IS_GTK, IS_MOTIF; + + // TODO move / change + static { + String platform = SWT.getPlatform(); + IS_CARBON = "carbon".equals(platform); + IS_GTK = "gtk".equals(platform); + IS_MOTIF = "motif".equals(platform); + } + + IModelElement selectedLiteral; + + IModelElement rootArea; + + private Canvas control; + + private Document document; + + private boolean dirty = false; + + private IFile file; + + private Map<String, IMetaModelElement> metaModelMap; + + @Override + public void createPartControl(Composite parent) { + control = new NewModelText(this, parent, SWT.NONE); + } + + @Override + public void dispose() { + if (control != null) { + control.dispose(); + } + + super.dispose(); + } + + @Override + public void doSave(IProgressMonitor monitor) { + try { + // write the document back + XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + outputter.output(document, out); + + out.flush(); + out.close(); + + ByteArrayInputStream in = new ByteArrayInputStream(out + .toByteArray()); + + file.setContents(in, true, true, null); + + dirty = false; + firePropertyChange(PROP_DIRTY); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void doSaveAs() { + } + + public Document getMappingFile() throws JDOMException, IOException { + String mappingFile = document.getRootElement().getAttributeValue( + "file", document.getRootElement().getNamespace("mapping")); + + System.out.println(mappingFile); + + IPath projectLocation = file.getProject().getLocation(); + IPath path2 = projectLocation.append(file.getProjectRelativePath() + .removeLastSegments(1)); + IPath path = path2.append(mappingFile); + + SAXBuilder builder = new SAXBuilder(); + return builder.build(path.toFile()); + } + + @Override + public void init(IEditorSite site, IEditorInput input) + throws PartInitException { + setSite(site); + setInput(input); + + file = (IFile) input.getAdapter(IFile.class); + try { + document = new SAXBuilder().build(file.getContents()); + System.out.println(document); + } catch (JDOMException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + createMetaModelMap(); + rootArea = metaModelMap.get(document.getRootElement().getName()) + .create(document.getRootElement(), null); + selectedLiteral = getNavigationElements().get(0); + } + + @Override + public boolean isDirty() { + return dirty; + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + public void setFocus() { + } + + void handleKeyDown(Event event) { + System.out.println(event); + + // TODO refactor + if (((event.keyCode == SWT.TAB) && ((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) + || event.keyCode == SWT.ARROW_UP) { + int index = getNavigationElements().indexOf(selectedLiteral) - 1; + if (index < 0) { + index = getNavigationElements().size() - 1; + } + selectedLiteral = getNavigationElements().get(index); + control.redraw(); + } else if (((event.keyCode == SWT.TAB) && !((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) + || event.keyCode == SWT.ARROW_DOWN) { + int index = getNavigationElements().indexOf(selectedLiteral) + 1; + if (index >= getNavigationElements().size()) { + index = 0; + } + selectedLiteral = getNavigationElements().get(index); + control.redraw(); + } else if (selectedLiteral instanceof VariableLiteral) { + VariableLiteral literal = (VariableLiteral) selectedLiteral; + if (event.keyCode == SWT.ARROW_RIGHT) { + literal.setCaretPosition(literal.getCaretPosition() + 1); + } else if (event.keyCode == SWT.ARROW_LEFT) { + literal.setCaretPosition(literal.getCaretPosition() - 1); + } else if (event.keyCode == SWT.DEL + && (literal.getCaretPosition() < literal.getValue() + .length())) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.deleteCharAt(literal.getCaretPosition()); + literal.setValue(value.toString()); + changed(); + } else if (event.keyCode == SWT.BS + && (literal.getCaretPosition() > 0)) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.deleteCharAt(literal.getCaretPosition() - 1); + literal.setValue(value.toString()); + literal.setCaretPosition(literal.getCaretPosition() - 1); + changed(); + } else if (isValidCharacter(event.stateMask, event.character)) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.insert(literal.getCaretPosition(), event.character); + literal.setValue(value.toString()); + literal.setCaretPosition(literal.getCaretPosition() + 1); + changed(); + } + control.redraw(); + } else if (event.keyCode == SWT.CR + && selectedLiteral instanceof AdditionPoint) { + AdditionPoint literal = (AdditionPoint) selectedLiteral; + literal.execute(); + control.redraw(); + } + } + + private void changed() { + dirty = true; + firePropertyChange(PROP_DIRTY); + } + + private void createMetaModelMap() { + metaModelMap = new HashMap<String, IMetaModelElement>(); + Map<String, IMetaMetaModelElement> metaMetaModelMap = createMetaMetaModelMap(); + + try { + Document mappingFile = getMappingFile(); + + Element rootElement = mappingFile.getRootElement(); + List<Element> mappings = rootElement.getChildren("mapping"); + + for (Element mappingElement : mappings) { + Element configuration = (Element) mappingElement.getChildren() + .get(0); + + IMetaMetaModelElement metaMetaModelElement = metaMetaModelMap + .get(configuration.getName()); + IMetaModelElement metaModelElement = metaMetaModelElement + .create(configuration, metaMetaModelMap, metaModelMap); + + metaModelMap.put(mappingElement.getAttributeValue("select"), + metaModelElement); + } + + } catch (JDOMException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private Map<String, IMetaMetaModelElement> createMetaMetaModelMap() { + Map<String, IMetaMetaModelElement> metaMappingMap = new HashMap<String, IMetaMetaModelElement>(); + + metaMappingMap.put("area", new AreaFactoryFactory()); + metaMappingMap.put("line", new LineFactoryFactory()); + metaMappingMap.put("edit", new VariableFactoryFactory()); + metaMappingMap.put("literal", new FixedLiteralFactoryFactory()); + metaMappingMap.put("apply-mappings", new ApplyMappingsFactoryFactory()); + metaMappingMap.put("addition-point", new AdditionPointFactoryFactory()); + + return metaMappingMap; + } + + // TODO performance: use caching instead of recalculation + private List<IModelElement> getNavigationElements() { + NavigationElementSearcher visitor = new NavigationElementSearcher(); + + rootArea.accept(visitor); + + return visitor.getNavigationElements(); + } + + private boolean isValidCharacter(int stateMask, char character) { + boolean ignore = false; + + if (IS_CARBON) { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Do not + // ignore COMMAND+ALT combinations since that key sequence + // produces characters on the mac. + ignore = (stateMask ^ SWT.COMMAND) == 0 + || (stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0; + } else if (IS_MOTIF) { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Do not + // ignore ALT combinations since this key sequence + // produces characters on motif. + ignore = (stateMask ^ SWT.CTRL) == 0 + || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; + } else { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Don't + // ignore CTRL+ALT combinations since that is the Alt Gr + // key on some keyboards. See bug 20953. + ignore = (stateMask ^ SWT.ALT) == 0 || (stateMask ^ SWT.CTRL) == 0 + || (stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 + || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; + } + boolean isCharacter = !ignore && character > 31 && character != SWT.DEL; + // -ignore anything below SPACE except for line delimiter keys and tab. + // -ignore DEL + return isCharacter; + } +} Added: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java (rev 0) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/NewModelText.java 2006-10-12 16:29:21 UTC (rev 110) @@ -0,0 +1,116 @@ +/* $HeadURL: https://svn.sourceforge.net/svnroot/exmmt/net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/ModelText.java $ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import net.sourceforge.exmmt.builder.Controller; +import net.sourceforge.exmmt.builder.ControllerTreeBuilder; +import net.sourceforge.exmmt.graphics.IDrawArea; +import net.sourceforge.exmmt.graphics.ISizeCalculator; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.TextLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Caret; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.jdom.Element; + +public class NewModelText extends Canvas { + + private final NewModelEditor editor; + + private Listener listener; + + private Caret caret; + + public NewModelText(NewModelEditor editor, Composite parent, int style) { + super(parent, style); + this.editor = editor; + + listener = new Listener() { + public void handleEvent(Event event) { + switch (event.type) { + case SWT.Paint: + handlePaint(event); + break; + case SWT.KeyDown: + NewModelText.this.editor.handleKeyDown(event); + break; + } + } + + }; + addListener(SWT.Paint, listener); + addListener(SWT.KeyDown, listener); + + caret = new Caret(this, SWT.NULL); + setCaret(caret); + } + + public void dispose() { + caret.dispose(); + super.dispose(); + } + + void handlePaint(Event event) { + System.out.println("handlePaint"); + final GC gc = event.gc; + + Color color = new Color(gc.getDevice(), new RGB(255, 255, 255)); + Color color2 = new Color(gc.getDevice(), new RGB(200, 255, 255)); + Color color3 = new Color(gc.getDevice(), new RGB(255, 200, 200)); + gc.setBackground(color); + drawBackground(gc, getClientArea().x, getClientArea().y, + getClientArea().width, getClientArea().height); + + // create draw area + // call render with draw area + IDrawArea area = new DefaultDrawArea(gc); + + ControllerTreeBuilder builder = new ControllerTreeBuilder(); + Element root = getDocumentRoot(); + Controller controller = builder.build(root); + + controller.getRenderer().calculateSize(new ISizeCalculator() { + + public Rectangle calculateSize(String text) { + TextLayout textLayout = new TextLayout(gc.getDevice()); + + textLayout.setText(text); + + return textLayout.getBounds(); + } + + }); + controller.getRenderer().render(area); + + color.dispose(); + color2.dispose(); + color3.dispose(); + } + + private Element getDocumentRoot() { + Element root = new Element("root"); + + root.setAttribute("blah","blub"); + root.setAttribute("blah2","blub222"); + + return root; + } + +} \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Controller.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Controller.java 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Controller.java 2006-10-12 16:29:21 UTC (rev 110) @@ -18,6 +18,7 @@ import net.sourceforge.exmmt.renderer.IRenderer; import net.sourceforge.exmmt.renderer.NullRenderer; +// @tag structure.tree public class Controller { private final Object model; @@ -30,6 +31,7 @@ public Controller(Object model) { assert model != null; + this.model = model; } @@ -43,7 +45,7 @@ assert children.contains(child); } - // TODO result should be immutable or a copy + // @tag todo: result should be immutable or a copy public List<Controller> getChildren() { return children; } Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/ControllerTreeBuilder.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/ControllerTreeBuilder.java 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/ControllerTreeBuilder.java 2006-10-12 16:29:21 UTC (rev 110) @@ -23,6 +23,7 @@ public class ControllerTreeBuilder { + // @tag structure.tree public Controller build(Element element) { Controller controller = new Controller(element); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/graphics/IDrawArea.java 2006-10-12 16:29:21 UTC (rev 110) @@ -12,7 +12,7 @@ */ package net.sourceforge.exmmt.graphics; -// TODO check introduction of Point class +// @tag todo.introduce: Point class public interface IDrawArea { void drawText(String text); Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-10-12 16:29:21 UTC (rev 110) @@ -51,6 +51,8 @@ int currentIndex = siblings.indexOf(focusedElement); + // @tag todo.refactor.extractStaticMethod: interval restriction + assert currentIndex >= 0; assert currentIndex <= siblings.size() - 1; @@ -78,6 +80,8 @@ int currentIndex = siblings.indexOf(focusedElement); + // @tag todo.refactor.extractStaticMethod: interval restriction + assert currentIndex >= 0; assert currentIndex <= siblings.size() - 1; Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-06-05 16:10:27 UTC (rev 109) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/renderer/HorizontalSequenceRenderer.java 2006-10-12 16:29:21 UTC (rev 110) @@ -27,15 +27,13 @@ public void calculateSize(ISizeCalculator sizeCalculator) { int height = 0; int width = 0; - + for (IRenderer renderer : subRenderers) { renderer.calculateSize(sizeCalculator); + Rectangle bounds = renderer.getSize(); - if (bounds.height > height) { - height = bounds.height; - } - + height = Math.max(height, bounds.height); width += bounds.width; } @@ -43,18 +41,15 @@ } public void render(IDrawArea drawArea) { - int oldX = drawArea.getX(); - int oldY = drawArea.getY(); - + int originalX = drawArea.getX(); + int originalY = drawArea.getY(); + for (IRenderer renderer : subRenderers) { renderer.render(drawArea); - - Rectangle bounds = renderer.getSize(); - - drawArea.changePosition(bounds.width, 0); + drawArea.changePosition(renderer.getSize().width, 0); } - - drawArea.setPosition(oldX, oldY); + + drawArea.setPosition(originalX, originalY); } public void add(IRenderer subRenderer) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 03:08:56
|
Revision: 50 Author: lgrammel Date: 2006-06-05 02:32:00 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=50&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java 2006-06-05 09:29:53 UTC (rev 49) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java 2006-06-05 09:32:00 UTC (rev 50) @@ -45,4 +45,8 @@ this.parent = parent; } -} + public boolean isRoot() { + return parent == null; + } + +} \ No newline at end of file Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:29:53 UTC (rev 49) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:32:00 UTC (rev 50) @@ -41,14 +41,9 @@ } public void moveToParent() { - Composite parent = focusedElement.getParent(); - - // TODO extract isRoot() method - if (parent == null) { - return; + if (!focusedElement.isRoot()) { + focusedElement = focusedElement.getParent(); } - - focusedElement = parent; } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 03:01:31
|
Revision: 59 Author: lgrammel Date: 2006-06-05 02:48:47 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=59&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java 2006-06-05 09:48:40 UTC (rev 58) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java 2006-06-05 09:48:47 UTC (rev 59) @@ -66,6 +66,14 @@ } @Test + public void moveToNextSibling() { + focus.moveToChild(); + focus.moveToNextSibling(); + + assertEquals(childComposite2, focus.getFocusedElement()); + } + + @Test public void moveToNextSiblingWithoutSibling() { focus.moveToNextSibling(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 03:01:26
|
Revision: 57 Author: lgrammel Date: 2006-06-05 02:45:18 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=57&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java 2006-06-05 09:45:10 UTC (rev 56) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java 2006-06-05 09:45:18 UTC (rev 57) @@ -26,8 +26,10 @@ private Focus focus; - private Composite childComposite; + private Composite childComposite1; + private Composite childComposite2; + @Test public void getInitialFocus() { assertEquals(composite, focus.getFocusedElement()); @@ -37,7 +39,7 @@ public void moveToChild() { focus.moveToChild(); - assertEquals(childComposite, focus.getFocusedElement()); + assertEquals(childComposite1, focus.getFocusedElement()); } @Test @@ -45,7 +47,7 @@ focus.moveToChild(); focus.moveToChild(); - assertEquals(childComposite, focus.getFocusedElement()); + assertEquals(childComposite1, focus.getFocusedElement()); } @Test @@ -63,11 +65,20 @@ assertEquals(composite, focus.getFocusedElement()); } + @Test + public void moveToNextSiblingWithoutSibling() { + focus.moveToNextSibling(); + + assertEquals(composite, focus.getFocusedElement()); + } + @Before public void setUp() { composite = new Composite(new Element("test")); - childComposite = new Composite(new Element("child")); - composite.addChild(childComposite); + childComposite1 = new Composite(new Element("child1")); + composite.addChild(childComposite1); + childComposite2 = new Composite(new Element("child2")); + composite.addChild(childComposite2); focus = new Focus(composite); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:54:51
|
Revision: 68 Author: lgrammel Date: 2006-06-05 03:35:56 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=68&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-06-05 10:33:51 UTC (rev 67) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-06-05 10:35:56 UTC (rev 68) @@ -18,21 +18,23 @@ import junit.framework.JUnit4TestAdapter; import net.sourceforge.exmmt.graphics.IOutputArea; +import org.jdom.Attribute; import org.junit.Test; public class AttributeRendererTest { @Test public void render() { - String text = "test"; + String value = "value"; + Attribute attribute = new Attribute("name", value); AttributeRenderer renderer = new AttributeRenderer(); IOutputArea outputArea = createMock(IOutputArea.class); - outputArea.drawText(text, 0, 0); + outputArea.drawText(value, 0, 0); replay(outputArea); - renderer.render(outputArea, text); + renderer.render(outputArea, attribute); verify(outputArea); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:54:49
|
Revision: 94 Author: lgrammel Date: 2006-06-05 06:05:11 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=94&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-06-05 13:04:57 UTC (rev 93) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/AttributeRendererTest.java 2006-06-05 13:05:11 UTC (rev 94) @@ -61,7 +61,8 @@ replay(sizeCalculator); - Rectangle result = renderer.calculateSize(sizeCalculator); + renderer.calculateSize(sizeCalculator); + Rectangle result = renderer.getSize(); assertEquals(rectangle, result); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-06-05 13:04:57 UTC (rev 93) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/HorizontalSequenceRendererTest.java 2006-06-05 13:05:11 UTC (rev 94) @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import junit.framework.JUnit4TestAdapter; +import net.sourceforge.exmmt.graphics.IDrawArea; import net.sourceforge.exmmt.graphics.ISizeCalculator; import org.eclipse.swt.graphics.Rectangle; @@ -28,9 +29,13 @@ public class HorizontalSequenceRendererTest { private HorizontalSequenceRenderer renderer; + private IRenderer childRenderer1; + private IRenderer childRenderer2; + private Rectangle rectangle1; + private Rectangle rectangle2; @Test @@ -40,33 +45,66 @@ } @Test + public void render() { + IDrawArea drawArea = createMock(IDrawArea.class); + + int oldX = 1; + int oldY = 2; + Rectangle childSize = new Rectangle(0,0,10,10); + Rectangle child2Size = new Rectangle(0,0,11,11); + + expect(drawArea.getX()).andReturn(oldX); + expect(drawArea.getY()).andReturn(oldY); + childRenderer1.render(drawArea); + expect(childRenderer1.getSize()).andReturn(childSize); + drawArea.changePosition(childSize.width, 0); + childRenderer2.render(drawArea); + expect(childRenderer2.getSize()).andReturn(child2Size); + drawArea.changePosition(child2Size.width, 0); + drawArea.setPosition(oldX, oldY); + + replay(drawArea); + replay(childRenderer1); + replay(childRenderer2); + + renderer.render(drawArea); + + verify(drawArea); + verify(childRenderer1); + verify(childRenderer2); + } + + @Test public void computeSize() { ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); - expect(childRenderer1.calculateSize(sizeCalculator)).andReturn( - rectangle1); - expect(childRenderer2.calculateSize(sizeCalculator)).andReturn( - rectangle2); + childRenderer1.calculateSize(sizeCalculator); + expect(childRenderer1.getSize()).andReturn(rectangle1); + childRenderer2.calculateSize(sizeCalculator); + expect(childRenderer2.getSize()).andReturn(rectangle2); replay(sizeCalculator); replay(childRenderer1); replay(childRenderer2); - Rectangle result = renderer.calculateSize(sizeCalculator); + renderer.calculateSize(sizeCalculator); + Rectangle result = renderer.getSize(); assertEquals(new Rectangle(0, 0, rectangle1.width + rectangle2.width, Math.max(rectangle1.height, rectangle2.height)), result); verify(sizeCalculator); + verify(childRenderer1); + verify(childRenderer2); } @Before public void setUp() { renderer = new HorizontalSequenceRenderer(); - + childRenderer1 = createMock(IRenderer.class); childRenderer2 = createMock(IRenderer.class); - + renderer.add(childRenderer1); renderer.add(childRenderer2); Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java 2006-06-05 13:04:57 UTC (rev 93) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/NullRendererTest.java 2006-06-05 13:05:11 UTC (rev 94) @@ -37,13 +37,13 @@ ISizeCalculator sizeCalculator = createMock(ISizeCalculator.class); replay(sizeCalculator); + + renderer.calculateSize(sizeCalculator); + + assertEquals(new Rectangle(0, 0, 0, 0), renderer.getSize()); - assertEquals(new Rectangle(0, 0, 0, 0), renderer - .calculateSize(sizeCalculator)); - verify(sizeCalculator); } - // Junit 3.8.1 backward compability public static junit.framework.Test suite() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:50:50
|
Revision: 98 Author: lgrammel Date: 2006-06-05 08:04:34 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=98&view=rev Log Message: ----------- #1500774 scenario "shopping list" Added Paths: ----------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java Added: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java (rev 0) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java 2006-06-05 15:04:34 UTC (rev 98) @@ -0,0 +1,31 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt.renderer; + +import static org.junit.Assert.assertTrue; +import junit.framework.JUnit4TestAdapter; + +import org.junit.Test; + +public class DelegatingRendererTest { + + @Test + public void isRenderer() { + assertTrue(IRenderer.class.isAssignableFrom(DelegatingRenderer.class)); + } + + // Junit 3.8.1 backward compability + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(DelegatingRendererTest.class); + } +} Property changes on: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/DelegatingRendererTest.java ___________________________________________________________________ Name: svn:keywords + HeadURL Id LastChangedBy LastChangedDate LastChangedRevision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:43:12
|
Revision: 106 Author: lgrammel Date: 2006-06-05 08:42:20 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=106&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/SubRendererProxyTest.java Modified: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/SubRendererProxyTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/SubRendererProxyTest.java 2006-06-05 15:34:11 UTC (rev 105) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/renderer/SubRendererProxyTest.java 2006-06-05 15:42:20 UTC (rev 106) @@ -12,32 +12,34 @@ */ package net.sourceforge.exmmt.renderer; +import static org.easymock.EasyMock.createMock; +import static org.junit.Assert.assertEquals; import junit.framework.JUnit4TestAdapter; - import net.sourceforge.exmmt.builder.Controller; import org.jdom.Element; import org.junit.Test; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; public class SubRendererProxyTest { -// @Test -// public void getRenderer() { -// IRenderer mockRenderer = createMock(IRenderer.class); -// -// Controller controller = new Controller(new Element("test"), mockRenderer); -// new SubRendererProxy(controller, 0); -// // 1. Feldindex -// // 2. -// } -// -// // Junit 3.8.1 backward compability -// public static junit.framework.Test suite() { -// return new JUnit4TestAdapter(SubRendererProxyTest.class); -// } -// + @Test + public void getRenderer() { + IRenderer mockRenderer = createMock(IRenderer.class); + + Controller controller = new Controller(new Element("test")); + Controller childController = new Controller(new Element("test2")); + controller.addChild(childController); + + childController.setRenderer(mockRenderer); + + SubRendererProxy proxy = new SubRendererProxy(controller, 0); + + assertEquals(mockRenderer, proxy.getDelegate()); + } + + // Junit 3.8.1 backward compability + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(SubRendererProxyTest.class); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:30:35
|
Revision: 44 Author: lgrammel Date: 2006-06-05 02:23:56 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=44&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:21:24 UTC (rev 43) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:23:56 UTC (rev 44) @@ -12,6 +12,8 @@ */ package net.sourceforge.exmmt.navigation; +import java.util.List; + import net.sourceforge.exmmt.builder.Composite; public class Focus { @@ -29,7 +31,13 @@ } public void moveToChild() { - focusedElement = focusedElement.getChildren().get(0); + List<Composite> children = focusedElement.getChildren(); + + if (children.isEmpty()) { + return; + } + + focusedElement = children.get(0); } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:30:10
|
Revision: 40 Author: lgrammel Date: 2006-06-05 02:05:52 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=40&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/META-INF/MANIFEST.MF net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java Added Paths: ----------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java Modified: net.sourceforge.exmmt/trunk/META-INF/MANIFEST.MF =================================================================== --- net.sourceforge.exmmt/trunk/META-INF/MANIFEST.MF 2006-06-05 08:48:30 UTC (rev 39) +++ net.sourceforge.exmmt/trunk/META-INF/MANIFEST.MF 2006-06-05 09:05:52 UTC (rev 40) @@ -21,6 +21,7 @@ net.sourceforge.exmmt, net.sourceforge.exmmt.builder, net.sourceforge.exmmt.graphics, + net.sourceforge.exmmt.navigation, net.sourceforge.exmmt.renderer, org.jaxen;x-friends:="net.sourceforge.exmmt.test", org.jaxen.expr;x-friends:="net.sourceforge.exmmt.test", Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java 2006-06-05 08:48:30 UTC (rev 39) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/builder/Composite.java 2006-06-05 09:05:52 UTC (rev 40) @@ -41,7 +41,7 @@ return parent; } - void setParent(Composite parent) { + public void setParent(Composite parent) { this.parent = parent; } Added: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java (rev 0) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:05:52 UTC (rev 40) @@ -0,0 +1,31 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt.navigation; + +import net.sourceforge.exmmt.builder.Composite; + +public class Focus { + + private Composite focusedElement; + + public Focus(Composite root) { + assert root != null; + + this.focusedElement = root; + } + + public Composite getFocusedElement() { + return focusedElement; + } + +} \ No newline at end of file Property changes on: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java ___________________________________________________________________ Name: svn:keywords + HeadURL Id LastChangedBy LastChangedDate LastChangedRevision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lgr...@us...> - 2006-06-06 02:30:09
|
Revision: 41 Author: lgrammel Date: 2006-06-05 02:06:08 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=41&view=rev Log Message: ----------- #1500774 scenario "shopping list" Added Paths: ----------- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java Added: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java =================================================================== --- net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java (rev 0) +++ net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java 2006-06-05 09:06:08 UTC (rev 41) @@ -0,0 +1,38 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt.navigation; + +import static org.junit.Assert.assertEquals; + +import junit.framework.JUnit4TestAdapter; +import net.sourceforge.exmmt.builder.Composite; + +import org.jdom.Element; +import org.junit.Test; + +public class FocusTest { + + @Test public void getInitialFocus() { + Composite composite = new Composite(new Element("test")); + + Focus manager = new Focus(composite); + + assertEquals(composite, manager.getFocusedElement()); + } + + // Junit 3.8.1 backward compability + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(FocusTest.class); + } + +} \ No newline at end of file Property changes on: net.sourceforge.exmmt.test/trunk/src/net/sourceforge/exmmt/navigation/FocusTest.java ___________________________________________________________________ Name: svn:keywords + HeadURL Id LastChangedBy LastChangedDate LastChangedRevision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |