Example #1
0
 protected void exportAsSvg() {
   GWT.log("exportAsSvg()");
   SVGModel model = getActiveModel();
   String markup = model.getMarkup();
   String url = "data:image/svg+xml;base64," + base64encode(markup);
   String title = ((SVGNamedElementModel) model.getRoot()).getName();
   com.google.gwt.user.client.Window.open(url, title, "");
 }
Example #2
0
  public SVGWindow addWindow(OMSVGSVGElement svg, ILoadRequest request) {
    String title = request.getTitle();
    SVGModel model = SVGModel.newInstance(svg, title);
    SVGWindow window = new SVGWindow(model);
    window.setHeading(title);
    svgWindows.add(window);
    // To be notified when a window is activated in order to
    // keep track of the active window
    window.addListener(
        Events.Activate,
        new Listener<WindowEvent>() {

          @Override
          public void handleEvent(WindowEvent we) {
            SVGWindow svgWindow = (SVGWindow) we.getWindow();
            GWT.log("VectomaticApp2.Activate(" + svgWindow.getHeading() + ")");
            if (activeWindow != svgWindow) {
              if (activeWindow != null) {
                activeWindow.deactivate();
                fireEvent(new DeactivateWindowEvent(activeWindow));
              }
              activeWindow = svgWindow;
              activeWindow.activate();
              fireEvent(new ActivateWindowEvent(activeWindow));
            }
          }
        });
    window.addListener(
        Events.BeforeHide,
        new Listener<WindowEvent>() {

          @Override
          public void handleEvent(WindowEvent we) {
            SVGWindow svgWindow = (SVGWindow) we.getWindow();
            svgWindow.getSvgModel().getSelectionModel().deselectAll();
            GWT.log("VectomaticApp2.BeforeHide(" + svgWindow.getHeading() + ")");
            svgWindow.removeAllListeners();
            svgWindow.deactivate();
            fireEvent(new DeactivateWindowEvent(svgWindow));
            svgWindows.remove(svgWindow);
            activeWindow = null;
            update();
          }
        });

    // Update the recent docs menu
    if (!(request instanceof NewDocRequest)) {
      List<Component> recentDocs = recentDocsMenu.getItems();
      boolean alreadyInRecentDocs = false;
      for (Component item : recentDocs) {
        RecentDocMenuItem menuItem = (RecentDocMenuItem) item;
        if (request.equals(menuItem.getRequest())) {
          alreadyInRecentDocs = true;
          break;
        }
      }
      if (!alreadyInRecentDocs) {
        if (recentDocs.size() >= 8) {
          Component oldestItem = recentDocs.get(0);
          oldestItem.removeAllListeners();
          recentDocsMenu.remove(oldestItem);
        }
        RecentDocMenuItem recentDocItem = new RecentDocMenuItem(request);
        recentDocsMenu.add(recentDocItem);
      }
    }

    int windowBarHeight = getWindowBarHeight();
    windowY += windowBarHeight;
    window.setPagePosition(windowX, windowY);
    windowX += windowBarHeight;
    //		window.show();
    viewport.add(window);
    window.setVisible(true);
    update();
    return window;
  }