예제 #1
0
  /** Called whenever an update is received from the server */
  @Override
  public void updateFromUIDL(final UIDL uidl, final ApplicationConnection client) {
    if (client.updateComponent(this, uidl, true)) {
      return;
    }
    this.client = client;
    paintableId = uidl.getId();
    currentKeyModifiers = new HashSet<Integer>();
    final String operation = uidl.getStringAttribute("operation");

    if ("REPAINT".equals(operation)) {
      repaint(uidl);
    } else if ("SET_NODE_SIZE".equals(operation)) {
      style.setNodeSize(uidl.getIntAttribute("ns") / 2);
      graph.updateGraphProperties(style);
      paintGraph();
    } else if ("SET_VISUAL_STYLE".equals(operation)) {
      graph.updateGraphProperties(style);
      paintGraph();
    } else if ("SET_TEXT_VISIBILITY".equals(operation)) {
      style.setTextsVisible(uidl.getBooleanAttribute("texts"));
      graph.updateGraphProperties(style);
      paintGraph();
    } else if ("SET_OPTIMIZED_STYLES".equals(operation)) {
      graph.paintGraph();
    } else if ("UPDATE_NODE".equals(operation)) {
      graph.updateNode(uidl, uidl.getStringAttribute("node"));
    } else if ("SET_ZOOM".equals(operation)) {
      setZoom(uidl.getIntAttribute("zoom"));
    } else if ("REFRESH".equals(operation)) {
      refresh(uidl);
    } else {
      repaint(uidl);
    }
  }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal
   * .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
   */
  public void updateFromUIDL(UIDL childUIDL, final ApplicationConnection client) {
    if (client.updateComponent(this, childUIDL, false)) {
      return;
    }
    if (childUIDL.hasAttribute("projection")) {
      projection = Projection.get(childUIDL.getStringAttribute("projection"));
    } else {
      projection = null;
    }

    boolean update = vector != null;
    if (update) {
      // temporary remove erase the vector
      getLayer().eraseFeature(vector);
    }

    updateAttributes(childUIDL, client);

    createOrUpdateVector(childUIDL, client);
    if (childUIDL.hasAttribute("style")) {
      intent = childUIDL.getStringAttribute("style");
      getVector().setRenderIntent(intent);
    }
    updateStyle(childUIDL, client);

    if (update) {
      ((VVectorLayer) getParent()).vectorUpdated(this);
    } else {
      getLayer().addFeature(vector);
    }
  }
예제 #3
0
  /** Called whenever an update is received from the server */
  @Override
  public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    super.updateFromUIDL(uidl, client);
    if (client.updateComponent(this, uidl, false)) {
      hidePopup();
      return;
    }
    addStyleName(CLASSNAME);

    position = uidl.getStringAttribute("position");
    xOffset = uidl.getIntAttribute("xoffset");
    yOffset = uidl.getIntAttribute("yoffset");

    popupVisible = uidl.getBooleanVariable("popupVisible");
    if (popupVisible) {
      if (uidl.hasAttribute("popupPositionPaintable")) {
        popupPositionPaintable = uidl.getPaintableAttribute("popupPositionPaintable", client);
      } else {
        popupPositionPaintable = null;
      }

      if (uidl.hasAttribute("style")) {
        final String[] styles = uidl.getStringAttribute("style").split(" ");
        final StringBuffer styleBuf = new StringBuffer();
        final String primaryName = popup.getStylePrimaryName();
        styleBuf.append(primaryName);
        styleBuf.append(" ");
        styleBuf.append(VPopupView.CLASSNAME + "-popup");
        for (int i = 0; i < styles.length; i++) {
          styleBuf.append(" ");
          styleBuf.append(primaryName);
          styleBuf.append("-");
          styleBuf.append(styles[i]);
        }
        popup.setStyleName(styleBuf.toString());
      } else {
        popup.setStyleName(popup.getStylePrimaryName() + " " + VPopupView.CLASSNAME + "-popup");
      }

      UIDL popupUIDL = uidl.getChildUIDL(0);
      popup.setVisible(false);
      popup.show();
      popup.updateFromUIDL(popupUIDL);
      showPopup();
    } else {
      hidePopup();
    }
  }
예제 #4
0
  /**
   * This method must be implemented to update the client-side component from UIDL data received
   * from server.
   *
   * <p>This method is called when the page is loaded for the first time, and every time UI changes
   * in the component are received from the server.
   */
  public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
    // This call should be made first. Ensure correct implementation,
    // and let the containing layout manage caption, etc.
    if (client.updateComponent(this, uidl, true)) {
      return;
    }

    // Save reference to server connection object to be able to send
    // user interaction later
    this.client = client;

    // Save the UIDL identifier for the component
    uidlId = uidl.getId();

    // Get value received from server and actualize it in the GWT component
    setColor(uidl.getStringVariable("colorname"));
  }
예제 #5
0
  public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    this.client = client;
    id = uidl.getId();

    // Ensure correct implementation
    if (client.updateComponent(this, uidl, true)) {
      return;
    }

    immediate = uidl.getBooleanAttribute("immediate");
    disabled = uidl.getBooleanAttribute("disabled");
    readonly = uidl.getBooleanAttribute("readonly");

    vertical = uidl.hasAttribute("vertical");
    arrows = uidl.hasAttribute("arrows");

    String style = "";
    if (uidl.hasAttribute("style")) {
      style = uidl.getStringAttribute("style");
    }

    scrollbarStyle = style.indexOf("scrollbar") > -1;

    if (arrows) {
      DOM.setStyleAttribute(smaller, "display", "block");
      DOM.setStyleAttribute(bigger, "display", "block");
    }

    if (vertical) {
      addStyleName(CLASSNAME + "-vertical");
    } else {
      removeStyleName(CLASSNAME + "-vertical");
    }

    min = uidl.getDoubleAttribute("min");
    max = uidl.getDoubleAttribute("max");
    resolution = uidl.getIntAttribute("resolution");
    value = new Double(uidl.getDoubleVariable("value"));

    setFeedbackValue(value);

    handleSize = uidl.getIntAttribute("hsize");

    buildBase();

    if (!vertical) {
      // Draw handle with a delay to allow base to gain maximum width
      Scheduler.get()
          .scheduleDeferred(
              new Command() {
                public void execute() {
                  buildHandle();
                  setValue(value, false);
                }
              });
    } else {
      buildHandle();
      setValue(value, false);
    }
  }
예제 #6
0
  public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

    if (client.updateComponent(this, uidl, true)) {
      return;
    }

    m_client = client;
    m_paintableId = uidl.getId();

    setScale(
        uidl.getDoubleAttribute("scale"),
        uidl.getIntAttribute("clientX"),
        uidl.getIntAttribute("clientY"));
    setSemanticZoomLevel(uidl.getIntAttribute("semanticZoomLevel"));
    setActionKeys(uidl.getStringArrayAttribute("backgroundActions"));

    UIDL graph = uidl.getChildByTagName("graph");
    Iterator<?> children = graph.getChildIterator();

    GWTGraph graphConverted = GWTGraph.create();
    while (children.hasNext()) {
      UIDL child = (UIDL) children.next();

      if (child.getTag().equals("group")) {
        GWTGroup group =
            GWTGroup.create(
                child.getStringAttribute("key"),
                child.getIntAttribute("x"),
                child.getIntAttribute("y"));
        boolean booleanAttribute = child.getBooleanAttribute("selected");
        String[] actionKeys = child.getStringArrayAttribute("actionKeys");

        group.setActionKeys(actionKeys);

        group.setSelected(booleanAttribute);
        group.setIcon(child.getStringAttribute("iconUrl"));
        group.setSemanticZoomLevel(child.getIntAttribute("semanticZoomLevel"));
        graphConverted.addGroup(group);

        if (m_client != null) {
          TooltipInfo ttInfo = new TooltipInfo(group.getTooltipText());
          m_client.registerTooltip(this, group, ttInfo);
        }

      } else if (child.getTag().equals("vertex")) {

        GWTVertex vertex =
            GWTVertex.create(
                child.getStringAttribute("id"),
                child.getIntAttribute("x"),
                child.getIntAttribute("y"));
        boolean booleanAttribute = child.getBooleanAttribute("selected");
        String[] actionKeys = child.getStringArrayAttribute("actionKeys");
        vertex.setSemanticZoomLevel(child.getIntAttribute("semanticZoomLevel"));

        vertex.setActionKeys(actionKeys);

        if (child.hasAttribute("groupKey")) {
          String groupKey = child.getStringAttribute("groupKey");
          GWTGroup group = graphConverted.getGroup(groupKey);
          vertex.setParent(group);
        }

        vertex.setSelected(booleanAttribute);
        vertex.setIcon(child.getStringAttribute("iconUrl"));
        graphConverted.addVertex(vertex);

        if (m_client != null) {
          TooltipInfo ttInfo = new TooltipInfo(vertex.getTooltipText());
          m_client.registerTooltip(this, vertex, ttInfo);
        }

      } else if (child.getTag().equals("edge")) {
        GWTEdge edge =
            GWTEdge.create(
                graphConverted.findVertexById(child.getStringAttribute("source")),
                graphConverted.findVertexById(child.getStringAttribute("target")));
        String[] actionKeys = child.getStringArrayAttribute("actionKeys");
        edge.setActionKeys(actionKeys);
        graphConverted.addEdge(edge);

        if (m_client != null) {
          TooltipInfo edgeInfo = new TooltipInfo("Edge: " + edge.getId());
          m_client.registerTooltip(this, edge, edgeInfo);
        }
      } else if (child.getTag().equals("groupParent")) {
        String groupKey = child.getStringAttribute("key");
        String parentKey = child.getStringAttribute("parentKey");
        GWTGroup group = graphConverted.getGroup(groupKey);
        GWTGroup parentGroup = graphConverted.getGroup(parentKey);

        group.setParent(parentGroup);
      }
    }

    UIDL actions = uidl.getChildByTagName("actions");
    if (actions != null) {
      updateActionMap(actions);
    }

    setGraph(graphConverted);
  }