Presentation is loading. Please wait.

Presentation is loading. Please wait.

ReuseTool Auxiliando o Processo de Instanciação. Processo de Instanciação 2010Frameworks2.

Similar presentations


Presentation on theme: "ReuseTool Auxiliando o Processo de Instanciação. Processo de Instanciação 2010Frameworks2."— Presentation transcript:

1 ReuseTool Auxiliando o Processo de Instanciação

2 Processo de Instanciação 2010Frameworks2

3 Cenário

4 Framework

5 Aplicação

6 Modelo

7 Código I 1.package org.eclipse.gef.examples.shapes.mymodel 2./** 3. * A crazy shape. 4. * @author Toacy Oliveira 5. */ 6.public class CrazyShape extends Shape { 7./** A 16x16 pictogram of a crazy shape. */ 8.private static final Image CRAZY_ICON = createImage("icons/crazy16.gif"); 9.private static final long serialVersionUID = 1; 10.public Image getIcon() { 11.return CRAZY_ICON; 12.} 13.public String toString() { 14.return "Crazy " + hashCode(); 15.} 16.public IFigure getFigure() { 17. 18. return new CrazyFigure ("Pop"); 19.} 20.public ConnectionAnchor getConnectionAnchor(IFigure iFigure) { 21.return new ChopboxAnchor(iFigure); 22.} 23.public boolean canConnect(Shape target) { 24.return (super.canConnect(target)) && !(target instanceof RectangularShape); 25.} 26.}

8 Código II 1.package org.eclipse.gef.examples.shapes.myfigures; 2.public class CrazyFigure extends RoundedRectangle { 3.public CrazyFigure(String name) { 4.super(); 5.ToolbarLayout layout = new ToolbarLayout(); 6.setLayoutManager(layout); 7.setBorder(new LineBorder(ColorConstants.black, 1)); 8.setBackgroundColor(ColorConstants.red); 9.setForegroundColor(ColorConstants.yellow); 10.setOpaque(true); 11.Label l = new Label("Crazy!" + name); 12.l.setForegroundColor(ColorConstants.red); 13.l.setBackgroundColor(ColorConstants.blue); 14.l.setFont(new Font(null, "Arial", 20, SWT.BOLD)); 15.l.setBorder(new LineBorder(ColorConstants.black, 2)); 16.add(l); 17.} 18.public void paintFigure(Graphics graphics) { 19.super.paintFigure(graphics); 20.graphics.setForegroundColor(ColorConstants.orange); 21.graphics.setLineStyle(Graphics.LINE_SOLID); 22.graphics.setLineWidth(3); 23.Rectangle r = getBounds(); 24.graphics.drawLine(new Point(r.x + r.width / 2, r.y + r.height * 0.3), 25.new Point(r.x + r.width / 2, r.y + r.height * 0.7)); 26.// horizontal line 27.graphics.drawLine(new Point(r.x + r.width * 0.3, r.y + r.height / 2), 28.new Point(r.x + r.width * 0.7, r.y + r.height / 2)); 29.}; 30.}

9 Hotspots Configurando a Forma – Ícones – Aparência – Conexões Alterando a Palette – Inserindo novo elemento na Palette

10 Reuse Description Language

11 A Solução RDL COOKBOOK ShapesProducts RECIPE main{ packA = NEW_PACKAGE(FrameworkModel,"org.reusetool.example.myshapeseditor"); LOOP ("Create another shape?") { // PREPARE Images EXTERNAL_TASK("Define 16x16 icon"); EXTERNAL_TASK("Define 24x24 icon"); // Define Shape SubClass shapeClass = CLASS_EXTENSION(Shape, packA,"?"); // Refine Abstract Methods m = METHOD_EXTENSION(Shape,shapeClass,addConnectionAnchor); ADD_CODE(shapeClass,m,"return new ChopboxAnchor(iFigure);"); m = METHOD_EXTENSION(Shape,shapeClass,getFigure); ADD_CODE(shapeClass,m,"return new IFIGURE_SUBCLASS);"); m = METHOD_EXTENSION(Shape,shapeClass,getIcon); ADD_CODE(shapeClass,m,"return createImage(\"NEW_SHAPE.gif\");"); // Configure Palette ADD_CODE(ShapesEditorPaletteFactory,createShapesDrawer, "component = new CombinedTemplateCreationEntry( \"NEW_SHAPE\", \"Create a NEW_SHAPE shape\", NEW_SHAPE.class, new SimpleFactory(NEW_SHAPE.class), ImageDescriptor.createFromFile(ShapesPlugin.class, \"icons/crazy16.gif\"), ImageDescriptor.createFromFile(ShapesPlugin.class, \"icons/crazy24.gif\")); componentsDrawer.add(component); "); // Redefine Method to treat How Connections can be handled IF ("Add Feature - Restrict Connections?") THEN { m = METHOD_EXTENSION(Shape,shapeClass,canConnect); ADD_CODE(shapeClass,m,"Code that checks if the connection can be made."); } IF ("Add Feature - New Figure?") THEN{ // Define Shape SubClass figClass = CLASS_EXTENSION(Figure, packA,"?"); m = METHOD_EXTENSION(Figure,figClass,paintFigure); } END_COOKBOOK


Download ppt "ReuseTool Auxiliando o Processo de Instanciação. Processo de Instanciação 2010Frameworks2."

Similar presentations


Ads by Google