Hello world exampleCreates and adds to root panel connections between two widgets. public class ExampleEntryPoint implements EntryPoint {
public void onModuleLoad() {
// Container for widgets and connections
AbsolutePanel panel = new AbsolutePanel();
panel.setWidth("100%");
panel.setHeight("100%");
RootPanel.get().add(panel);
// elements to connect
Widget label1 = new Label("Hello");
Widget label2 = new Label("world");
panel.add(label1, 100, 100);
panel.add(label2, 200, 200);
// gwt-diagrams stuff
Connector c1 = UIObjectConnector.wrap(label1);
Connector c2 = UIObjectConnector.wrap(label2);
Connection connection = new RectilinearTwoEndedConnection(c1, c2);
connection.appendTo(panel);
}
}
Multiple connections exampleCreates and adds to root panel connections between three widgets. This shows ability to connect one widget (Y) with multiple another widgets (X, Z). This example also shows how to add multiple connections between two widgets (Y, Z). public class ExampleEntryPoint implements EntryPoint {
public void onModuleLoad() {
// Container for widgets and connections
AbsolutePanel panel = new AbsolutePanel();
panel.setWidth("100%");
panel.setHeight("100%");
RootPanel.get().add(panel);
// elements to connect
Widget x = new Label("X");
Widget y = new Label("Y");
Widget z = new Label("Z");
panel.add(x, 100, 100);
panel.add(y, 200, 200);
panel.add(z, 300, 300);
// gwt-diagrams stuff
Connector c1 = UIObjectConnector.wrap(x);
Connector c2 = UIObjectConnector.wrap(y);
Connector c3 = UIObjectConnector.wrap(z);
Connection connection1 = new RectilinearTwoEndedConnection(c1, c2);
Connection connection2 = new BezierTwoEndedConnection(c2, c3);
Connection connection3 = new StraightTwoEndedConnection(c2, c3);
connection1.appendTo(panel);
connection2.appendTo(panel);
connection3.appendTo(panel);
}
}
gwt-dnd 1.2.x integration examplepublic class ExampleEntryPoint implements EntryPoint {
public void onModuleLoad() {
// Container for widgets and connections
AbsolutePanel panel = new AbsolutePanel();
panel.setWidth("100%");
panel.setHeight("100%");
RootPanel.get().add(panel);
// elements to connect
Widget x = new Label("X");
Widget y = new Label("Y");
panel.add(x, 100, 100);
panel.add(y, 200, 200);
// gwt-diagrams stuff
Connector c1 = UIObjectConnector.wrap(x);
Connector c2 = UIObjectConnector.wrap(y);
Connection connection0 = new RectilinearTwoEndedConnection(c1, c2);
connection0.appendTo(panel);
// gwt-dnd integration sample stuff
PickupDragController dragController = new PickupDragController(panel, true) {
public BoundaryDropController newBoundaryDropController(AbsolutePanel boundaryPanel, boolean allowDropping) {
return new BoundaryDropController(boundaryPanel, allowDropping) {
public void onMove(Widget reference, Widget draggable, DragController dragController) {
super.onMove(reference, draggable, dragController);
UIObjectConnector c = UIObjectConnector.getWrapper(draggable);
if (c != null) {
c.update();
}
}
};
}
};
dragController.makeDraggable(x);
dragController.makeDraggable(y);
}
}
|
hello
another
Hello World Example from above with gwt > 1.5.0 and actual gwt-dnd (2.5.2)
Remark: (Issue 27: Support for GWT 1.5) Remove this line "http://www.w3.org/TR/html4/loose.dtd" in your project.xml
/** * Entry point classes define <code>onModuleLoad()</code>. */ public class TestDnd implements EntryPoint { /** * This is the entry point method. */ public void onModuleLoad() { // Container for widgets and connections AbsolutePanel panel = new AbsolutePanel(); panel.setWidth("100%"); panel.setHeight("100%"); RootPanel.get().add(panel); // elements to connect Widget x = new Label("X"); Widget y = new Label("Y"); panel.add(x, 100, 100); panel.add(y, 200, 200); // gwt-diagrams stuff Connector c1 = UIObjectConnector.wrap(x); Connector c2 = UIObjectConnector.wrap(y); Connection connection0 = new RectilinearTwoEndedConnection(c1, c2); connection0.appendTo(panel); // gwt-dnd integration sample stuff PickupDragController dragController = new PickupDragController(panel, true) { public BoundaryDropController newBoundaryDropController(AbsolutePanel boundaryPanel, boolean allowDropping) { return new BoundaryDropController(boundaryPanel, allowDropping) { public void onMove(DragContext context) { super.onMove(context); UIObjectConnector c = UIObjectConnector.getWrapper(context.draggable); if (c != null) { c.update(); } } }; } }; dragController.makeDraggable(x); dragController.makeDraggable(y); } }I am trying to continue GWT-Diagrams since it looks Michal Balinsk has abandoned this one http://code.google.com/p/gwt-diagrams2/