Beispiel #1
0
 public SVGWindow getWindow(SVGElement element) {
   SVGSVGElement svg = element.getOwnerSVGElement();
   for (SVGWindow svgWindow : svgWindows) {
     if (svg == svgWindow.getSvgModel().getDocumentRoot().getElement()) {
       return svgWindow;
     }
   }
   return null;
 }
Beispiel #2
0
  public void onModuleLoad() {
    instance = this;
    GWT.setUncaughtExceptionHandler(
        new GWT.UncaughtExceptionHandler() {
          public void onUncaughtException(Throwable throwable) {
            GWT.log("Uncaught exception", throwable);
            if (!GWT.isScript()) {
              String text = "Uncaught exception: ";
              while (throwable != null) {
                StackTraceElement[] stackTraceElements = throwable.getStackTrace();
                text += throwable.toString() + "\n";
                for (int i = 0; i < stackTraceElements.length; i++) {
                  text += "    at " + stackTraceElements[i] + "\n";
                }
                throwable = throwable.getCause();
                if (throwable != null) {
                  text += "Caused by: ";
                }
              }
              DialogBox dialogBox = new DialogBox(true);
              DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
              System.err.print(text);
              text = text.replaceAll(" ", "&nbsp;");
              dialogBox.setHTML("<pre>" + text + "</pre>");
              dialogBox.center();
            }
          }
        });
    AppBundle.INSTANCE.css().ensureInjected();

    // Create graphical context
    OMSVGDocument doc = OMSVGParser.currentDocument();
    SVGElement element = doc.createSVGPathElement().getElement().cast();
    element
        .getStyle()
        .setProperty(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_LIGHTBLUE_VALUE);
    element.getStyle().setProperty(SVGConstants.CSS_STROKE_PROPERTY, SVGConstants.CSS_BLACK_VALUE);
    SVGNamedElementModel.createTitleDesc(element, AppConstants.INSTANCE.graphicalContext());
    cssContext = new CssContextModel(element);

    svgWindows = new ArrayList<SVGWindow>();
    viewport = new ViewportExt();

    viewport.setLayout(new BorderLayout());
    viewport.add(createMenuBar(), new BorderLayoutData(LayoutRegion.NORTH, getWindowBarHeight()));
    viewport.setStyleAttribute("background-color", SVGConstants.CSS_BEIGE_VALUE);

    commandToolBar =
        new CommandFactoryToolBar(
            CommandFactories.getAllFactoriesStore(), getCommandFactorySelector());
    ContentPanel commandPanel = new ContentPanel();
    commandPanel.setHeaderVisible(false);
    commandPanel.setBottomComponent(commandToolBar);
    viewport.add(commandPanel, new BorderLayoutData(LayoutRegion.SOUTH, getWindowBarHeight()));

    new InternalLoadRequest(AppBundle.INSTANCE.fish(), "fish.svg").load();
    new InternalLoadRequest(AppBundle.INSTANCE.fries(), "fries.svg").load();
    new InternalLoadRequest(AppBundle.INSTANCE.sample(), "sample.svg").load();

    update();

    fileUpload = new FileUploadExt();
    Style style = fileUpload.getElement().getStyle();
    style.setVisibility(Visibility.HIDDEN);
    style.setWidth(0, Unit.PX);
    style.setHeight(0, Unit.PX);
    fileUpload.addChangeHandler(
        new ChangeHandler() {

          @Override
          public void onChange(ChangeEvent event) {
            processFiles(fileUpload.getFiles());
          }
        });

    RootPanel.get().add(viewport);
    RootPanel.get().add(fileUpload);
  }