tags:

views:

402

answers:

1

I write a testing class below, but I not able to add it into the com.smartgwt.client.widgets.Window.

Anyone can help me on this? Thanks in advanced!

package com.smartgwt.sample.showcase.client;

import pl.tecna.gwt.connectors.client.ConnectionPoint; import pl.tecna.gwt.connectors.client.Connector; import pl.tecna.gwt.connectors.client.Diagram; import pl.tecna.gwt.connectors.client.SectionDecoration; import pl.tecna.gwt.connectors.client.Shape;

import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Image; import com.smartgwt.client.widgets.Label;

public class NetworkMap{

public NetworkMap() { AbsolutePanel widget = new AbsolutePanel();

    final Diagram diagram = new Diagram(widget);

    final Label label = new Label("LABEL");

final Image image = new Image("http://code.google.com/images/code_sm.png"); image.setPixelSize(153, 55);

widget.add(label, 50, 250); widget.add(image, 200, 300);

Shape shapeForLabel = new Shape(label); shapeForLabel.showOnDiagram(diagram);

Shape shapeForImage = new Shape(image); shapeForImage.showOnDiagram(diagram);

ConnectionPoint labelConnectionPoint = shapeForLabel.connectionPoints[Shape.E]; ConnectionPoint imageConnectionPoint = shapeForImage.connectionPoints[Shape.W];

 Connector label2image = new Connector
     (labelConnectionPoint.getAbsoluteLeft(),
                  labelConnectionPoint.getAbsoluteTop(),
                  imageConnectionPoint.getAbsoluteLeft(),
                  imageConnectionPoint.getAbsoluteTop(),
                  null,
                  new SectionDecoration(SectionDecoration.DECORATE_ARROW));

 label2image.startEndPoint.glueToConnectionPoint(labelConnectionPoint);
 label2image.endEndPoint.glueToConnectionPoint(imageConnectionPoint);

 label2image.showOnDiagram(diagram);  
    /* // Create boundary panel

AbsolutePanel boundaryPanel = new AbsolutePanel();

initWidget(boundaryPanel); boundaryPanel.setSize("700px", "700px"); RootPanel.get().add(boundaryPanel, 10, 10);

final Diagram diagram = new Diagram(boundaryPanel);

boundaryPanel.add(new Label("Connectors example for GWT 1.7"), 10, 2);

// Add some elements that can be connected final Label label = new Label("LABEL"); final Image image = new Image("http://code.google.com/images/code_sm.png"); image.setPixelSize(153, 55);

boundaryPanel.add(label, 50, 250); boundaryPanel.add(image, 200, 300);

Shape shapeForLabel = new Shape(label); shapeForLabel.showOnDiagram(diagram);

Shape shapeForImage = new Shape(image); shapeForImage.showOnDiagram(diagram);

// Connect label and image ConnectionPoint labelConnectionPoint = shapeForLabel.connectionPoints[Shape.E]; ConnectionPoint imageConnectionPoint = shapeForImage.connectionPoints[Shape.W];

 Connector label2image = new Connector
     (labelConnectionPoint.getAbsoluteLeft(),
                  labelConnectionPoint.getAbsoluteTop(),
                  imageConnectionPoint.getAbsoluteLeft(),
                  imageConnectionPoint.getAbsoluteTop(),
                  null,
                  new SectionDecoration(SectionDecoration.DECORATE_ARROW));

 label2image.startEndPoint.glueToConnectionPoint(labelConnectionPoint);
 label2image.endEndPoint.glueToConnectionPoint(imageConnectionPoint);

 label2image.showOnDiagram(diagram);  
 */

}

}

A: 

As far as I understand you are trying to put the NetworkMap into a Window widget. The NetworkMap class needs to implement the Composite interface for it to be considered as a widget and displayed in a Window, Panel, etc... Once you implement the Composite interface you need to call the initWidget() function by providing the main panel/layout that contains your widgets inside your NetworkMap class (you have done this). Therefore you need to write;

public class NetworkMap extends Composite { ... }
jaxvy