Connector con = new Connector(x, y, 500, y, null, new SectionDecoration(DecorationType.ARROW_SOLID));
con.style = ConnectorStyle.SOLID;
con.showOnDiagram(diagram);
.....
//some Shaped Widgets
....
if(con.startEndPoint.isGluedToConnectionPoint())
{
//add Label to PopUp-Panel
pop.addChild(label);
}
.....private List<Widget> getConnectedWidgets(Shape shape) { List<Widget> widgets = new ArrayList<Widget>(); for (ConnectionPoint cp : shape.connectionPoints) { for (EndPoint endpoint : cp.gluedEndPoints) { EndPoint otherSideEndpoint = endpoint.isStart() ? endpoint.connector.endEndPoint : endpoint.connector.startEndPoint; if (otherSideEndpoint.isGluedToConnectionPoint()) { widgets.add(otherSideEndpoint.gluedConnectionPoint.parentWidget); } } } return widgets; }final Shape shapeConcrete = new Shape(tes);
shapeConcrete.showOnDiagram(diagram);
shapeConcrete.showConnectionPoints(diagram);
shapeConcrete.enableConnectionCreate(true);
for (Connector c : shapeConcrete.getConnectedConnectors())
for (ConnectionPoint cp : shapeConcrete.connectionPoints) {
for (EndPoint ep : cp.gluedEndPoints) {
if(ep.isGluedToConnectionPoint()){
if(c.startEndPoint.equals(ep)){
Label la = new Label ("it works A");
pop.addChild(la);
}
else if(c.endEndPoint.equals(ep)){
Label lb = new Label ("it works B");
pop.addChild(lb);
}
}
}
}
Connector connector = ... // the specified connector
// is start endpoint connected
if (connector.startEndPoint.isGluedToConnectionPoint()) { Widget connected = connector.startEndPoint.gluedConnectionPoint.parentWidget; LOG.info("-- start endpoint connected to widget: " + connected);}
// is end endpoint connectedif (connector.endEndPoint.isGluedToConnectionPoint()) { Widget connected = connector.endEndPoint.gluedConnectionPoint.parentWidget; LOG.info("-- end endpoint connected to widget: " + connected);}Connector connector = ... // the specified connector
Shape shape = ... // the specified shape
if (connector.startEndPoint.isGluedToConnectionPoint()) { Widget connected = connector.startEndPoint.gluedConnectionPoint.parentWidget; if (connected.equals(shape.connectedWidget)) { LOG.info("--- start endpoint connected to shape"); }}boolean isEndDragged = false; boolean isSeqDragged = false;
....
final Window pop = new Window();
...
//drag
seq.addDragStartHandler(new DragStartHandler() {
public void onDragStart(DragStartEvent event) {
event.setData("text", "images/con_sequenz.svg");
isSeqDragged = true;
}
});
.....
// drop
boundaryPanel.addDomHandler(new DropHandler() {
public void onDrop(DropEvent event) {
event.preventDefault();
final int x = (event.getNativeEvent().getClientX() - boundaryPanel.getAbsoluteLeft());
final int y = (event.getNativeEvent().getClientY() - boundaryPanel.getAbsoluteTop());
boundaryPanel.getElement().getStyle().clearBackgroundColor();
.....
if (isEndDragged) {
Image end2 = new Image("images/end.svg");
end2.setSize("90", "90");
boundaryPanel.add(end2, x, y);
Shape shapeConcrete = new Shape(end2);
shapeConcrete.showOnDiagram(diagram);
shapeConcrete.showConnectionPoints(diagram);
isEndDragged = false;
}
else if (isSeqDragged) {
Connector con_sequenz = new Connector(x, y, 500, y, null, new SectionDecoration(DecorationType.ARROW_SOLID));
con_sequenz.style = ConnectorStyle.SOLID;
con_sequenz.showOnDiagram(diagram);
if(con_sequenz.startEndPoint.isGluedToConnectionPoint()){
Label a = new Label("it works");
pop.addChild(a);
isSeqDragged = false;
};
for a better overview, i have tried to implement a short test-example:
package com.exa.projekt.client; import pl.tecna.gwt.connectors.client.Diagram; import pl.tecna.gwt.connectors.client.elements.Connector; import pl.tecna.gwt.connectors.client.elements.Shape; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.RootPanel; public class Projekt implements EntryPoint { private RootPanel rootPanel; public void onModuleLoad() { rootPanel = RootPanel.get("gwtContainer"); rootPanel.setSize("1902", "868"); AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setStyleName("frame1"); boundaryPanel.setSize("1455px", "600px"); Diagram diagram = new Diagram(boundaryPanel); RootPanel.get().add(boundaryPanel, 446, 242); Connector con = new Connector(100, 300, 300, 500); con.showOnDiagram(diagram); Image img = new Image("images/concrete.svg"); img.setSize("200", "200"); boundaryPanel.add(img, 100,100); Shape shapei = new Shape(img); shapei.showOnDiagram(diagram); if(con.startEndPoint.isGluedToConnectionPoint()){ Image logo = new Image("images/xor.svg"); logo.setSize("100", "100"); boundaryPanel.add(logo); }; }}the if-condition is not working yet :( when i add con.startEndPoint.setGluedToConnectionPoint(true) it is working. but that is not what i want...
i am using gwt-connectors 2.4. and gwt-2.5.1. Which Configuration do you use?
I have tried this, but it is also not working...did you reviewed my new code-example? Anything wrong? Or Is it maybe a browser problem? Which Browser do you use?
--
You received this message because you are subscribed to a topic in the Google Groups "gwt-connectors" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gwt-connectors/QuUEMUcBQ6E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gwt-connector...@googlegroups.com.
To post to this group, send email to gwt-con...@googlegroups.com.
Visit this group at https://groups.google.com/group/gwt-connectors.
For more options, visit https://groups.google.com/d/optout.
diagram.addDiagramListener(new DiagramListenerAdapter() { @Override public void onElementConnect(ElementConnectEvent event) { if (con.startEndPoint.isGluedToConnectionPoint()) { Image logo = new Image("images/xor.svg"); logo.setSize("100", "100"); boundaryPanel.add(logo); }; }});Wow, that's it! Thank you very very much! You saved me from a nervous breakdown :))