Java Code Examples for com.google.gwt.dom.client.Document

The following are top voted examples for showing how to use com.google.gwt.dom.client.Document. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 7 votes vote down vote up
protected AccessibleCheckBox(Element elem) {
    super(DOM.createSpan());
    inputElem = InputElement.as(elem);
    labelElem = Document.get().createLabelElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(labelElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    labelElem.setHtmlFor(uid);

    // Accessibility: setting tab index to be 0 by default, ensuring element
    // appears in tab sequence. FocusWidget's setElement method already
    // calls setTabIndex, which is overridden below. However, at the time
    // that this call is made, inputElem has not been created. So, we have
    // to call setTabIndex again, once inputElem has been created.
    setTabIndex(0);
}
 
Example 2
Project: Mindustry   File: HtmlLauncher.java   Source Code and License 6 votes vote down vote up
@Override
public GwtApplicationConfiguration getConfig() {
    GwtApplicationConfiguration config = new GwtApplicationConfiguration(WIDTH, HEIGHT);

    Element element = Document.get().getElementById("embed-html");
    VerticalPanel panel = new VerticalPanel();
    panel.setWidth("100%");
    panel.setHeight("100%");
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    element.appendChild(panel.getElement());
    config.rootPanel = panel;
    config.width = 2000;
    config.height = 2000;

    return config;
}
 
Example 3
Project: empiria.player   File: FlashModule.java   Source Code and License 6 votes vote down vote up
@Override
protected void initModule(Element element) {
    String src = element.getAttribute("src");
    int lastSlash = ((src.lastIndexOf("/") > src.lastIndexOf("\\")) ? src.lastIndexOf("/") : src.lastIndexOf("\\"));
    String basePath = src.substring(0, lastSlash + 1);
    com.google.gwt.dom.client.Element paramNameElement = Document.get().createElement("param");
    paramNameElement.setAttribute("name", "movie");
    paramNameElement.setAttribute("value", src);
    com.google.gwt.dom.client.Element paramBaseElement = Document.get().createElement("param");
    paramBaseElement.setAttribute("name", "base");
    paramBaseElement.setAttribute("value", basePath);
    com.google.gwt.dom.client.Element embedElement = Document.get().createElement("embed");
    embedElement.setAttribute("src", src);
    embedElement.setAttribute("base", basePath);
    panel.getElement().appendChild(paramNameElement);
    panel.getElement().appendChild(paramBaseElement);
    panel.getElement().appendChild(embedElement);

}
 
Example 4
Project: empiria.player   File: VideoExecutorSwf.java   Source Code and License 6 votes vote down vote up
@Override
public void init() {
    FlowPanel flowPanel = new FlowPanel();
    FlashVideo video = FlashVideoFactory.createVideo(source, flowPanel, baseMediaConfiguration.getWidth(), baseMediaConfiguration.getHeight());
    flashMedia = video;
    if (this.mediaWrapper instanceof SwfMediaWrapper) {
        ((SwfMediaWrapper) this.mediaWrapper).setMediaWidget(flowPanel);
    }
    if (baseMediaConfiguration.getNarrationText().trim().length() > 0) {
        final TextTrack textTrack = textTrackFactory.getTextTrack(TextTrackKind.SUBTITLES, mediaWrapper);
        // FIXME do poprawy gdy narrationScript bedzie zawieral informacje o czasie wyswietlania
        // zamiast Double.MAX_VALUE tu powinna sie znalezc wartosc czasowa okreslajaca
        // kiedy napis znika poniewaz w tej chwili narrationScript nie posiada takiej informacji
        // przypisuje najwieksza dostepna wartosc
        textTrack.addCue(new TextTrackCue(Document.get().createUniqueId(), 0, Double.MAX_VALUE, baseMediaConfiguration.getNarrationText()));
        eventsBus.addHandlerToSource(MediaEvent.getType(MediaEventTypes.ON_TIME_UPDATE), mediaWrapper, new MediaEventHandler() {

            @Override
            public void onMediaEvent(MediaEvent event) {
                textTrack.setCurrentTime(mediaWrapper.getCurrentTime());
            }
        }, pageScopeFactory.getCurrentPageScope());

    }
    super.init();
}
 
Example 5
Project: empiria.player   File: AccessibleListBox.java   Source Code and License 6 votes vote down vote up
/**
 * Inserts an item into the list box, specifying its direction and an initial value for the item. If the index is less than zero, or greater than or equal
 * to the length of the list, then the item will be appended to the end of the list.
 *
 * @param item  the text of the item to be inserted
 * @param dir   the item's direction. If {@code null}, the item is displayed in the widget's overall direction, or, if a direction estimator has been set, in
 *              the item's estimated direction.
 * @param value the item's value, to be submitted if it is part of a {@link FormPanel}.
 * @param index the index at which to insert it
 */
public void insertItem(String item, Direction dir, String value, int index) {
    SelectElement select = getSelectElement();
    OptionElement option = Document.get().createOptionElement();
    setOptionText(option, item, dir);
    option.setValue(value);

    int itemCount = select.getLength();
    if (index < 0 || index > itemCount) {
        index = itemCount;
    }
    if (index == itemCount) {
        select.add(option, null);
    } else {
        OptionElement before = select.getOptions().getItem(index);
        select.add(option, before);
    }
}
 
Example 6
Project: Charba   File: Injector.java   Source Code and License 6 votes vote down vote up
/**
 * Injects ChartJS if not injected yet.
 */
static void ensureInjected() {
	if (!injected) {
		// gets resource
		Resources res = GWT.create(Resources.class);
		// gets source of ChartJS
		String source = res.chartJsSource().getText();
		// creates a script element
		ScriptElement scriptElement = Document.get().createScriptElement();
		// sets ID
		scriptElement.setId(CHART_JS_SCRIPT_ELEMENT_ID);
		// sets the script content with ChartJS source
		scriptElement.setInnerText(source);
		// appends to the body
		Document.get().getBody().appendChild(scriptElement);
		injected = true;
	}
}
 
Example 7
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 6 votes vote down vote up
public WTPdfViewerWidget() {
	Document document = Document.get();
	root = document.createDivElement();
	root.addClassName("loadingInProgress");

	outerContainer = createChildDiv(document, root, "outerContainer");
	createSidebar(document, outerContainer);

	mainContainer = createChildDiv(document, outerContainer, "mainContainer");
	createFindBar(document, mainContainer);
	//the toolbar on the right that opens after click on double arrow on the right
	createSecondaryToolbar(document, mainContainer);
	createMainToolbar(document, mainContainer);

	loadingBar = createChildDiv_withId(document, mainContainer, "loadingBar");
	progress = createChildDiv_withId(document, loadingBar, "progress");

	createViewerContainer(document, mainContainer);
	printContainer = createChildDiv(document, root, "printContainer");

	setElement(root);
	startWebViewerLoad(this);

	setStyleName("wtpdfviewer");
}
 
Example 8
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 6 votes vote down vote up
private void createViewerContainer(Document document, DivElement mainContainer) {
	viewerContainer = createChildDiv(document, mainContainer, "viewerContainer");
	viewerContainer.setTabIndex(0); // keyboard scrolling does not work without this tabindex 

	viewer = createChildDiv(document, viewerContainer, "viewer");
	viewer.addClassName("pdfViewer");

	overlayContainer = createChildDiv(document, outerContainer, "overlayContainer");
	overlayContainer.addClassName("hidden");

	passwordOverlay = createChildDiv(document, overlayContainer, "passwordOverlay");
	passwordOverlay.addClassName("container");
	passwordOverlay.addClassName("hidden");

	createDocumentPropertiesOverlay(document, overlayContainer);
	createPrintServiceOverlay(document, overlayContainer);
}
 
Example 9
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 6 votes vote down vote up
private void createPrintServiceOverlay(Document document, DivElement parent) {
	printServiceOverlay = createChildDiv(document, parent, "printServiceOverlay");
	printServiceOverlay.addClassName("container");
	printServiceOverlay.addClassName("hidden");

	DivElement dialog = createChildDiv(document, printServiceOverlay, "dialog");
	DivElement row1 = createChildDiv(document, dialog, "row");
	SpanElement message = createChildSpan(document, row1, "");
	message.setInnerText("Preparing document for printing!");

	DivElement row2 = createChildDiv(document, dialog, "row");
	createChildProgress(document, row2, 0, 100);
	SpanElement relativeProgressSpan = createChildSpan(document, row2, "relative-progress");
	relativeProgressSpan.setInnerText("0%");

	DivElement row3 = createChildDiv(document, dialog, "row");
	printCancel = createChildButton(document, row3, "printCancel");
	printCancel.addClassName("overlayButton");
	SpanElement printCancelMessage = createChildSpan(document, printCancel, "");
	printCancelMessage.setInnerText("Cancel");
}
 
Example 10
Project: gwt-history   File: HistoryTest.java   Source Code and License 6 votes vote down vote up
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testClickLink() {
  AnchorElement anchorElement = Document.get().createAnchorElement();
  anchorElement.setHref("#href1");
  Document.get().getBody().appendChild(anchorElement);

  try {
    History.newItem("something_as_base");

    addHistoryListenerImpl(
        event -> {
          assertEquals("href1", event.getValue());
          finishTest();
        });

    delayTestFinish(5000);

    NativeEvent clickEvent =
        Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);

    anchorElement.dispatchEvent(clickEvent);

  } finally {
    Document.get().getBody().removeChild(anchorElement);
  }
}
 
Example 11
Project: Wiab.pro   File: RepairerGwtTest.java   Source Code and License 6 votes vote down vote up
public void testRevertEmptyElement() {
  init();
  initEmptyP();
  c.insertBefore(root, p, null);

  // essentially a noop
  assertTrue(p.isConsistent());
  p.revertImplementation();
  assertTrue(p.isConsistent());

  // add some random text node
  p.getImplNodelet().appendChild(Document.get().createTextNode("blah"));
  p.revertImplementation();
  assertEquals(null, p.getImplNodelet().getFirstChild());

  p.getImplNodelet().appendChild(ca());
  p.revertImplementation();
  assertEquals(null, p.getImplNodelet().getFirstChild());

  p.getImplNodelet().appendChild(ca());
  p.revertImplementation();
  assertEquals(null, p.getImplNodelet().getFirstChild());

  l.check(0, 0); // calls through revertInner, so none reported
}
 
Example 12
Project: GWT-AL   File: AudioDecoder.java   Source Code and License 6 votes vote down vote up
public static boolean isSupported(FileFormat format)
{
    if (tempAudioElement == null)
        tempAudioElement = Document.get().createAudioElement();

    switch (format)
    {
        case MP3:
            return !tempAudioElement.canPlayType(AudioElement.TYPE_MP3).equals(MediaElement.CANNOT_PLAY);

        case WAV:
            return !tempAudioElement.canPlayType(AudioElement.TYPE_WAV).equals(MediaElement.CANNOT_PLAY);

        case OGG:
            return !tempAudioElement.canPlayType(AudioElement.TYPE_OGG).equals(MediaElement.CANNOT_PLAY);

        case WEBM:
            return !tempAudioElement.canPlayType("audio/webm").equals(MediaElement.CANNOT_PLAY);
    }

    return false;
}
 
Example 13
Project: Wiab.pro   File: EventDispatcherPanelGwtTest.java   Source Code and License 6 votes vote down vote up
@Override
protected void gwtSetUp() {
  SafeHtml dom = EscapeUtils.fromSafeConstant("" + // \u2620
      "<div id='base' kind='base'>" + // \u2620
      "  <div>" + // \u2620
      "    <div kind='foo' id='foo'>" + // \u2620
      "      <div kind='unused'>" + // \u2620
      "        <div kind='bar' id='bar'>" + // \u2620
      "          <div id='source'></div>" + // \u2620
      "        </div>" + // \u2620
      "      </div>" + // \u2620
      "    </div>" + // \u2620
      "  </div>" + // \u2620
      "</div>");

  top = load(dom);
  foo = Document.get().getElementById("foo");
  bar = Document.get().getElementById("bar");

  // Register some handlers.
  handlers = new MockHandlers(top);
  fooHandler = new MyHandler();
  barHandler = new MyHandler();
  handlers.register("foo", fooHandler);
  handlers.register("bar", barHandler);
}
 
Example 14
Project: Wiab.pro   File: EditorEventHandlerGwtTest.java   Source Code and License 6 votes vote down vote up
public void testDeleteWithRangeSelectedDeletesRange() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.DELETE, KeyCodes.KEY_LEFT);

  //Event event = Document.get().createKeyPressEvent(
  //    false, false, false, false, KeyCodes.KEY_BACKSPACE, 0).cast();

  Text input = Document.get().createTextNode("ABCDE");
  ContentNode node = new ContentTextNode(input, null);

  final Point<ContentNode> start = Point.inText(node, 1);
  final Point<ContentNode> end = Point.inText(node, 4);
  FakeEditorInteractor interactor = setupFakeEditorInteractor(
      new FocusedContentRange(start, end));
  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  interactor.call(FakeEditorInteractor.DELETE_RANGE).nOf(1).withArgs(
      start, end, false).returns(start);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
Example 15
Project: walkaround   File: UploadFormPopup.java   Source Code and License 6 votes vote down vote up
/**
 * Creates an upload popup.
 */
public UploadFormPopup() {
  form = BINDER.createAndBindUi(this);

  PopupChrome chrome = PopupChromeFactory.createPopupChrome();
  chrome.enableTitleBar();
  popup = PopupFactory.createPopup(null, new CenterPopupPositioner(), chrome, false);
  popup.getTitleBar().setTitleText("Upload attachment");
  popup.add(form);

  iframe = Document.get().createIFrameElement();
  iframe.setName("_uploadform" + iframeId++);
  // HACK(danilatos): Prevent browser from caching due to whatever reason
  iframe.setSrc("/uploadform?nocache=" + Duration.currentTimeMillis());
  form.getElement().setAttribute("target", iframe.getName());

  onloadRegistration =
      DomHelper.registerEventHandler(iframe, "load", new JavaScriptEventListener() {
        @Override
        public void onJavaScriptEvent(String name, Event event) {
          onIframeLoad();
        }
      });
  UIObject.setVisible(iframe, false);
}
 
Example 16
Project: walkaround   File: Walkaround.java   Source Code and License 6 votes vote down vote up
/** Reveals the log div, and executes a task when done. */
// The async API for this method is intended to support two things: a cool
// spew animation, and also the potential to runAsync the whole LogPanel code.
private static void attachLogPanel() {
  Logs.get().addHandler(domLogger);
  final Panel logHolder = RootPanel.get("logHolder");
  logHolder.setVisible(true);

  // Need one layout and paint cycle after revealing it to start animation.
  // Use high priority to avoid potential starvation by other tasks if a
  // problem is occurring.
  SchedulerInstance.getHighPriorityTimer().scheduleDelayed(new Task() {
    @Override
    public void execute() {
      logHolder.add(domLogger);
      Style waveStyle = Document.get().getElementById(WAVEPANEL_PLACEHOLDER).getStyle();
      Style logStyle = logHolder.getElement().getStyle();
      logStyle.setHeight(250, Unit.PX);
      waveStyle.setBottom(250, Unit.PX);
    }
  }, 50);
}
 
Example 17
Project: Wiab.pro   File: EditorEventHandlerGwtTest.java   Source Code and License 6 votes vote down vote up
/**
 * Ensure that the event handler normalises the selection when necessary
 * Note that this is currently just for firefox.
 */
public void testNormalisesSelection() {
  FakeEditorEvent fakeEvent = FakeEditorEvent.create(KeySignalType.INPUT, 'a');
  final Point<ContentNode> caret =
      Point.<ContentNode> end(newParaElement());

  EditorEventsSubHandler subHandler = new FakeEditorEventsSubHandler();
  FakeEditorInteractor interactor = setupFakeEditorInteractor(new FocusedContentRange(caret));
  final Point<ContentNode> newCaret = Point.<ContentNode>inText(
      new ContentTextNode(Document.get().createTextNode("hi"), null), 2);
  interactor.call(FakeEditorInteractor.NORMALIZE_POINT).returns(newCaret);
  interactor.call(FakeEditorInteractor.SET_CARET).nOf(1).withArgs(newCaret);
  interactor.call(FakeEditorInteractor.NOTIFYING_TYPING_EXTRACTOR).nOf(1).withArgs(
      newCaret, false);
  EditorEventHandler handler = createEditorEventHandler(interactor, subHandler);

  handler.handleEvent(fakeEvent);
  interactor.checkExpectations();
}
 
Example 18
Project: Wiab.pro   File: KeyBindingRegistryIntegrationGwtTest.java   Source Code and License 6 votes vote down vote up
/** Ensure that when other keys are pressed, they are not passed to the action. */
public void testAlternativeKeyPress() {
  KeyBindingRegistry bindings = new KeyBindingRegistry();
  callTracker = 0;
  EditorAction testAction =
      new EditorAction() {

        @Override
        public void execute(EditorContext context) {
          callTracker++;
        }
      };
  bindings.registerAction(KeyCombo.CTRL_G, testAction);
  EditorImpl editor = createEditor(bindings);

  // This event is not ORDER_G, it has other accelerators thrown in.
  Event rawEvent = Document.get().createKeyPressEvent(
      true, true, true, false, G_CODE, G_CODE).cast();
  editor.onJavaScriptEvent(JsEvents.KEY_PRESS, rawEvent);
  assertEquals("Callback action called on unregistered keypress", callTracker, 0);
}
 
Example 19
Project: Wiab.pro   File: KeyBindingRegistryIntegrationGwtTest.java   Source Code and License 6 votes vote down vote up
/**
 * Ensure that new keybindings are used after changing them in the editor.
 */
public void testReregistrationKeyBinding() {
  KeyBindingRegistry bindings = new KeyBindingRegistry();
  callTracker = 0;
  EditorAction testAction =
      new EditorAction() {

        @Override
        public void execute(EditorContext context) {
          callTracker++;
        }
      };
  bindings.registerAction(KeyCombo.CTRL_G, testAction);

  EditorImpl editor = createEditor(bindings);
  Event rawEvent = Document.get().createKeyPressEvent(
      true, false, false, false, G_CODE, G_CODE).cast();
  editor.onJavaScriptEvent(JsEvents.KEY_PRESS, rawEvent);
  // callTracker should be 1 assuming the test above passes

  bindings.removeAction(KeyCombo.CTRL_G);
  initEditor(editor, Editor.ROOT_REGISTRIES, bindings);
  editor.onJavaScriptEvent(JsEvents.KEY_PRESS, rawEvent);
  assertEquals("Callback action called on deregistered keypress", callTracker, 1);
}
 
Example 20
Project: cuba   File: CubaFileDownloaderConnector.java   Source Code and License 6 votes vote down vote up
public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
 
Example 21
Project: Wiab.pro   File: WebClient.java   Source Code and License 6 votes vote down vote up
private void setupWavePanel() {
  // Hide the frame until waves start getting opened
  UIObject.setVisible(waveFrame.getElement(), false);

  Document.get().getElementById(SIGNOUT_ELEMENT_ID).setInnerText(messages.signout());

  // Handles opening waves.
  ClientEvents.get().addWaveSelectionEventHandler(new WaveSelectionEventHandler() {

    @Override
    public void onSelection(WaveRef waveRef, boolean ctrlDown, boolean altDown) {
      // Ctrl or Alt isn't pressed => open wave with diffs
      closeAndOpenWave(new OpenWaveData(waveRef, false, null, !ctrlDown && !altDown));
    }
  });

  waveFrame.getElement().setId(WAVE_ELEMENT_ID);
}
 
Example 22
Project: Wiab.pro   File: WebClient.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a dialogBox that informs about not saved data.
 */
private DialogActivator getNotSavedDialogActivator() {
  if (notSavedDialogActivator == null) {
    PopupChrome chrome = PopupChromeFactory.createPopupChrome();
    UniversalPopup popup = PopupFactory.createPopup(Document.get().getElementById(APP_ELEMENT_ID),
        new CenterPopupPositioner(), chrome, false);

    Label messageLabel = new Label(messages.changesNotSavedMessage());
    messageLabel.setStyleName(Dialog.getCss().infoLabel());

    DialogBox.create(popup, messages.changesNotSavedTitle(), messageLabel,
        new DialogButton[] { notSavedDialogNo, notSavedDialogYes });

    notSavedDialogActivator = new DialogActivator(popup);
  }
  return notSavedDialogActivator;
}
 
Example 23
Project: Wiab.pro   File: UndercurrentHarness.java   Source Code and License 6 votes vote down vote up
/**
 * Populates the info box. Continuously reports which element has browser
 * focus, and reports timing information for the stage loading.
 *
 * @param timeline timeline to report
 */
private static void showInfo(Timeline timeline) {
  Element timeBox = Document.get().getElementById("timeline");
  timeline.dump(timeBox);

  Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
    private final Element activeBox = Document.get().getElementById("active");

    @Override
    public boolean execute() {
      Element e = getActiveElement();
      String text = (e != null ? e.getTagName() + " id:" + e.getId() : "none");
      activeBox.setInnerText(text);
      return true;
    }

    private native Element getActiveElement() /*-{
      return $doc.activeElement;
    }-*/;
  }, 1000);
}
 
Example 24
Project: Wiab.pro   File: CheckBox.java   Source Code and License 6 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  InputElement inputElem = Document.get().createCheckInputElement();
  inputElem.setClassName(CheckConstants.css.check());

  // Wrap in non-editable span- Firefox does not fire events for checkboxes
  // inside contentEditable region.
  SpanElement nonEditableSpan = Document.get().createSpanElement();
  DomHelper.setContentEditable(nonEditableSpan, false, false);
  nonEditableSpan.appendChild(inputElem);

  return nonEditableSpan;
}
 
Example 25
Project: Wiab.pro   File: CajolerFacade.java   Source Code and License 6 votes vote down vote up
private void appendToDocument(HTML target, PluginContext pluginContext, CajolerResponse response) {
  DivElement domitaVdocElement = Document.get().createDivElement();
  domitaVdocElement.setClassName("innerHull");

  target.getElement().setInnerHTML("");
  target.getElement().setClassName("outerHull");
  target.getElement().appendChild(domitaVdocElement);

  initializeDoodadEnvironment(
      cajaFrame, domitaVdocElement, pluginContext.getJSOInterface());

  // Render HTML
  domitaVdocElement.setInnerHTML(response.getHtml());

  // Inject JS
  Document cajaFrameDoc = cajaFrame.getContentDocument();
  cajaFrameDoc.getBody().appendChild(cajaFrameDoc.createScriptElement(response.getJs()));
}
 
Example 26
Project: Wiab.pro   File: DynamicDomRenderer.java   Source Code and License 6 votes vote down vote up
private void setFlapPanelVisible(boolean visible) {
  if (flapPanelVisible != visible) {
    if (flapPanel == null) {
      flapPanel = Document.get().createDivElement();
    }
    flapPanel.setClassName(getCss().flap() + " " +
        (visible ? getCss().opaque() : getCss().transparent()) );
    if (visible) {
      DomUtil.putCover(flapPanel, getScrollPanel());
      DomUtil.setProgressCursor(flapPanel);
    } else {
      getTimer().scheduleDelayed(hideFlapPanelTask, HIDE_FLAP_PANEL_DELAY_MS);
    }
    flapPanelVisible = visible;
  }
}
 
Example 27
Project: Wiab.pro   File: DomLogger.java   Source Code and License 6 votes vote down vote up
/**
 * Appends an entry to the log panel.
 * @param formatted
 * @param level
 */
public static void appendEntry(String formatted, Level level) {
  DivElement entry = Document.get().createDivElement();
  entry.setClassName(RESOURCES.css().entry());
  entry.setInnerHTML(formatted);

  // Add the style name associated with the log level.
  switch (level) {
    case ERROR:
      entry.addClassName(RESOURCES.css().error());
      break;
    case FATAL:
      entry.addClassName(RESOURCES.css().fatal());
      break;
    case TRACE:
      entry.addClassName(RESOURCES.css().trace());
      break;
  }

  // Make fatals detectable by WebDriver, so that tests can early out on
  // failure:
  if (level.equals(Level.FATAL)) {
    latestFatalError = formatted;
  }
  writeOrCacheOutput(entry);
}
 
Example 28
Project: Wiab.pro   File: KeyBindingRegistryIntegrationGwtTest.java   Source Code and License 6 votes vote down vote up
/**
 * Ensure that an action bound to ORDER_G is executed when the appropriate JS keypress
 * event is fired at the editor.
 */
public void testKeyBinding() {
  KeyBindingRegistry bindings = new KeyBindingRegistry();
  callTracker = 0;
  EditorAction testAction =
      new EditorAction() {

        @Override
        public void execute(EditorContext context) {
          callTracker++;
        }
      };
  bindings.registerAction(KeyCombo.CTRL_G, testAction);
  EditorImpl editor = createEditor(bindings);

  // 103 = g, this event = CTRL_G which is bound to ORDER_G by the EventWrapper
  Event rawEvent = Document.get().createKeyPressEvent(
      true, false, false, false, G_CODE, G_CODE).cast();
  editor.onJavaScriptEvent(JsEvents.KEY_PRESS, rawEvent);
  assertEquals("Callback action not called on registered keypress", callTracker, 1);
}
 
Example 29
Project: Wiab.pro   File: FocusManager.java   Source Code and License 6 votes vote down vote up
/**
 * Installs a key handler for key events on this window.
 *
 * @param handler handler to receive key events.
 */
static void install(KeySignalHandler handler) {
  //
  // NOTE: There are three potential candidate elements for sinking keyboard
  // events: the window, the document, and the document body. IE7 does not
  // fire events on the window element, and GWT's RootPanel is already a
  // listener on the body, leaving the document as the only cross-browser
  // whole-window event-sinking 'element'.
  //
  DocumentPanel panel = new DocumentPanel(handler);
  panel.setElement(Document.get().<Element>cast());
  panel.addDomHandler(panel, KeyDownEvent.getType());
  panel.addDomHandler(panel, KeyPressEvent.getType());
  panel.addDomHandler(panel, KeyUpEvent.getType());
  RootPanel.detachOnWindowClose(panel);
  panel.onAttach();
}
 
Example 30
Project: Wiab.pro   File: ParagraphHelperBr.java   Source Code and License 6 votes vote down vote up
/**
 * Get the spacer for the given paragraph.
 * Lazily creates & registers one if not present.
 * If there's one that the browser created, registers it as our own.
 * If the browser put a different one in to the one that we were already
 * using, replace ours with the browser's.
 * @param paragraph
 * @return The spacer
 */
protected BRElement getSpacer(Element paragraph) {
  Node last = paragraph.getLastChild();
  BRElement spacer = paragraph.getPropertyJSO(BR_REF).cast();
  if (spacer == null) {
    // Register our spacer, using one the browser put in if present
    spacer = isSpacer(last) ? last.<BRElement>cast() : Document.get().createBRElement();
    setupSpacer(paragraph, spacer);
  } else if (isSpacer(last) && last != spacer) {
    // The browser put a different one in by itself, so let's use that one
    if (spacer.hasParentElement()) {
      spacer.removeFromParent();
    }
    spacer = last.<BRElement>cast();
    setupSpacer(paragraph, spacer);
  }
  return spacer;
}
 
Example 31
Project: Wiab.pro   File: ContentTextNode.java   Source Code and License 6 votes vote down vote up
void setRendering(boolean isRendering) {
  /**
   * TODO(akaplanov) Return optimization (lines below) when successive updates of some node will correct.
   * (Remove and insert of one character in one aggregated operation).
   * if ((getImplNodelet() != null) == isRendering) {
   *   return;
   * }
   * if (isRendering) {
   *   setImplNodelet(Document.get().createTextNode(data));
   * } else {
   *   setImplNodelet(null);
   * }
   */
   if (isRendering) {
     if (getImplNodelet() != null) {
       getImplNodelet().setData(data);
     } else {
      setImplNodelet(Document.get().createTextNode(data));
     }
   } else {
     setImplNodelet(null);
   }
}
 
Example 32
Project: Wiab.pro   File: TestEditors.java   Source Code and License 6 votes vote down vote up
/** For testing purposes only. */
public static ContentDocument createTestDocument() {
  ContentDocument doc = new ContentDocument(DocumentSchema.NO_SCHEMA_CONSTRAINTS);
  Registries registries = Editor.ROOT_REGISTRIES.createExtension();
  for (String t : new String[] {"q", "a", "b", "c", "x"}) {
    final String tag = t;
    registries.getElementHandlerRegistry().registerRenderer(tag,
        new Renderer() {
          @Override
          public Element createDomImpl(Renderable element) {
            return element.setAutoAppendContainer(Document.get().createElement(tag));
          }
        });
  }
  doc.setRegistries(registries);
  Editor editor = getMinimalEditor();
  editor.setContent(doc);
  return doc;
}
 
Example 33
Project: Wiab.pro   File: ContentTextNodeGwtTest.java   Source Code and License 6 votes vote down vote up
public void testImplDataSumsTextNodes() throws HtmlMissing {
  ContentDocument dom = TestEditors.createTestDocument();
  c = dom.debugGetRawDocument();
  ContentElement root = c.getDocumentElement();

  ContentTextNode t1 = c.createTextNode("hello", root, null);
  Text txt = t1.getImplNodelet();

  assertEquals("hello", t1.getImplData());
  Text txt3 = Document.get().createTextNode(" there");
  txt.getParentNode().insertAfter(txt3, txt);
  assertEquals("hello there", t1.getImplData());
  Text txt2 = txt.splitText(2);
  assertEquals("hello there", t1.getImplData());
  assertSame(txt3, txt.getNextSibling().getNextSibling());
  assertTrue(t1.owns(txt) && t1.owns(txt2) && t1.owns(txt3));

  ContentTextNode t2 = c.createTextNode("before", root, t1);

  assertEquals("before", t2.getImplData());
  Text t2_2 = t2.getImplNodelet().splitText(3);
  assertEquals("before", t2.getImplData());
  assertTrue(t2.owns(t2_2));
}
 
Example 34
Project: Mindustry   File: HtmlLauncher.java   Source Code and License 5 votes vote down vote up
void scaleCanvas() {
    Element element = Document.get().getElementById("embed-html");
    int innerWidth = getWindowInnerWidth();
    int innerHeight = getWindowInnerHeight();
    int newWidth = innerWidth;
    int newHeight = innerHeight;
    float ratio = innerWidth / (float) innerHeight;
    float viewRatio = WIDTH / (float) HEIGHT;

    if (ratio > viewRatio) {
        newWidth = (int) (innerHeight * viewRatio);
    } else {
        newHeight = (int) (innerWidth / viewRatio);
    }

    NodeList<Element> nl = element.getElementsByTagName("canvas");

    if (nl != null && nl.getLength() > 0) {
        Element canvas = nl.getItem(0);
        canvas.setAttribute("width", "" + newWidth + "px");
        canvas.setAttribute("height", "" + newHeight + "px");
        canvas.getStyle().setWidth(newWidth, Style.Unit.PX);
        canvas.getStyle().setHeight(newHeight, Style.Unit.PX);
        canvas.getStyle().setTop((int) ((innerHeight - newHeight) * 0.5f), Style.Unit.PX);
        canvas.getStyle().setLeft((int) ((innerWidth - newWidth) * 0.5f), Style.Unit.PX);
        canvas.getStyle().setPosition(Style.Position.ABSOLUTE);
    }
}
 
Example 35
Project: empiria.player   File: GroupModuleBase.java   Source Code and License 5 votes vote down vote up
@Override
protected String getModuleId() {
    if (super.getModuleId() == null || "".equals(super.getModuleId().trim())) {
        if (moduleId == null)
            moduleId = Document.get().createUniqueId();
        return moduleId;
    }
    return super.getModuleId();
}
 
Example 36
Project: empiria.player   File: FlashLocalMediaImpl.java   Source Code and License 5 votes vote down vote up
public FlashLocalMediaImpl(String name) {
    elementId = Document.get().createUniqueId();
    panelMain = new FlowPanel();
    panelMain.setStyleName("qp-" + name + "-flash-local");
    panelContent = new FlowPanel();
    panelContent.getElement().setId(elementId);
    panelMain.add(panelContent);

    initWidget(panelMain);
}
 
Example 37
Project: empiria.player   File: VideoPlayer.java   Source Code and License 5 votes vote down vote up
@Inject
public VideoPlayer(@Assisted VideoElementWrapper videoElementWrapper, VideoPlayerNative nativePlayer, UserAgentUtil userAgentUtil) {
    this.nativePlayer = nativePlayer;
    this.videoElementWrapper = videoElementWrapper;
    this.userAgentUtil = userAgentUtil;
    divElement = Document.get().createDivElement();
    setElement(divElement);
}
 
Example 38
Project: empiria.player   File: VideoElementWrapperProvider.java   Source Code and License 5 votes vote down vote up
@Override
public VideoElementWrapper get() {
    String playerId = Document.get().createUniqueId();
    VideoElement videoElem = Document.get().createVideoElement();
    videoElem.setId(playerId);
    videoElem.addClassName(CLASS_NAME);
    return new VideoElementWrapper(videoElem);
}
 
Example 39
Project: empiria.player   File: MetaDescriptionManager.java   Source Code and License 5 votes vote down vote up
public void processDocument(com.google.gwt.xml.client.Document document) {
    if (document != null) {
        Element metaDescriptionNode = XMLUtils.getFirstElementWithTagName(document.getDocumentElement(), "metaDescription");
        if (metaDescriptionNode != null) {
            NodeList metaNodes = metaDescriptionNode.getElementsByTagName("meta");
            com.google.gwt.dom.client.Element htmlHeadNode = Document.get().getElementsByTagName("head").getItem(0);
            for (int n = 0; n < metaNodes.getLength(); n++) {
                com.google.gwt.dom.client.Element currElement = convertToDomElement((Element) metaNodes.item(n));
                htmlHeadNode.appendChild(currElement);
            }
        }
    }
}
 
Example 40
Project: empiria.player   File: MetaDescriptionManager.java   Source Code and License 5 votes vote down vote up
private com.google.gwt.dom.client.Element convertToDomElement(Element xmlElement) {
    com.google.gwt.dom.client.Element domElement = Document.get().createElement(xmlElement.getNodeName());
    for (int a = 0; a < xmlElement.getAttributes().getLength(); a++) {
        Node currAttr = xmlElement.getAttributes().item(a);
        domElement.setAttribute(currAttr.getNodeName(), currAttr.getNodeValue());
    }
    return domElement;
}
 
Example 41
Project: empiria.player   File: InlineBodyGenerator.java   Source Code and License 5 votes vote down vote up
private Widget generateBody(Node mainNode, boolean nodeChildrens) {
    DivElement div = Document.get().createDivElement();
    Document.get().getBody().appendChild(div);
    Widget inlineHtml = InlineHTML.wrap(div);
    // after wrapping, div is removed from main body
    Document.get().getBody().removeChild(div);
    inlineHtml.setStyleName(styleNames.QP_TEXT_INLINE());
    if (nodeChildrens) {
        parseXML(mainNode.getChildNodes(), inlineHtml.getElement());
    } else {
        parseNode(mainNode, inlineHtml.getElement());
    }
    return inlineHtml;
}
 
Example 42
Project: empiria.player   File: InlineBodyGenerator.java   Source Code and License 5 votes vote down vote up
/**
 * Parsuje pojedynczy wezel xml-a i generuje reprezentacje w postaci widgeta. Widget jest dodawany do parentElement
 *
 * @param currNode
 * @param parentElement
 * @return
 */
protected com.google.gwt.dom.client.Element parseNode(Node currNode, com.google.gwt.dom.client.Element parentElement) {
    if (currNode.getNodeType() == Node.ELEMENT_NODE) {
        if (options.getIgnoredInlineTags().contains(currNode.getNodeName())) {
            return parentElement;
        } else if (modulesRegistrySocket.isModuleSupported(currNode.getNodeName()) && modulesRegistrySocket.isInlineModule(currNode.getNodeName())) {
            IModule module = modulesRegistrySocket.createModule((Element) currNode);
            if (module instanceof IInlineModule) {
                parenthood.addChild(module);
                ((IInlineModule) module).initModule((Element) currNode, moduleSocket, eventsBus);
                Widget moduleView = ((IInlineModule) module).getView();
                if (moduleView != null) {
                    parentElement.appendChild(moduleView.getElement());
                }
                if (module instanceof IInlineContainerModule) {
                    parenthood.pushParent((IInlineContainerModule) module);
                    parseElementNode(currNode, parentElement);
                    parenthood.popParent();
                }
            }
        } else {
            parseElementNode(currNode, parentElement);
        }
    } else if (currNode.getNodeType() == Node.TEXT_NODE) {
        Document doc = Document.get();
        com.google.gwt.dom.client.SpanElement span = doc.createSpanElement();
        span.appendChild(doc.createTextNode(currNode.getNodeValue()));
        span.setClassName(styleNames.QP_TEXT());
        parentElement.appendChild(span);
    }
    return parentElement;
}
 
Example 43
Project: empiria.player   File: InlineBodyGenerator.java   Source Code and License 5 votes vote down vote up
protected void parseNode(Node node, Widget parent) {
    if (node == null) {
        return;
    }
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        String moduleName = node.getNodeName();
        if (modulesRegistrySocket.isModuleSupported(moduleName) && modulesRegistrySocket.isInlineModule(moduleName)) {
            IModule module = modulesRegistrySocket.createModule((Element) node);
            if (module instanceof IInlineModule) {
                ((IInlineModule) module).initModule((Element) node, moduleSocket, eventsBus);
                Widget moduleView = ((IInlineModule) module).getView();
                if (parent instanceof ComplexPanel && moduleView != null) {
                    Panel parentPanel = ((Panel) parent);
                    parentPanel.add(moduleView);

                    if (module instanceof IInlineContainerModule) {
                        IInlineContainerModule inlineContainer = (IInlineContainerModule) module;
                        createInlineFormattedModule(node, parentPanel, inlineContainer);
                    }
                }
            }

        } else {
            HTMLPanel panel = new HTMLPanel(node.getNodeName(), "");
            if (parent instanceof ComplexPanel) {
                ((Panel) parent).add(panel);
                parseXMLAttributes((Element) node, panel.getElement());
                parseXML(node.getChildNodes(), panel);
            }
        }
    } else if (node.getNodeType() == Node.TEXT_NODE) {
        parent.getElement().appendChild(Document.get().createTextNode(node.getNodeValue()));
    }

}
 
Example 44
Project: empiria.player   File: InlineBodyGenerator.java   Source Code and License 5 votes vote down vote up
private Element getElementFromString(String value) {
    com.google.gwt.xml.client.Document doc = XMLParser.createDocument();
    com.google.gwt.xml.client.Element textElement = doc.createElement("content");

    textElement.appendChild(doc.createTextNode(value));

    return textElement;
}
 
Example 45
Project: empiria.player   File: SoundExecutorSwfSimple.java   Source Code and License 5 votes vote down vote up
private void playFromSource(String src) {
    panelMain.clear();
    FlowPanel panelEmbed = new FlowPanel();
    String htmlId = Document.get().createUniqueId();
    panelEmbed.getElement().setId(htmlId);
    panelMain.add(panelEmbed);
    String installSrc = GWT.getModuleBaseURL() + "swfobject/expressInstall.swf";
    String swfSrc = GWT.getModuleBaseURL() + "flashAudioExecutorSimple/flashAudioExecutorSimple.swf";
    embedSwf(htmlId, swfSrc, installSrc, src);
}
 
Example 46
Project: empiria.player   File: AbstractTemplateParser.java   Source Code and License 5 votes vote down vote up
private void parseNode(Node mainNode, Widget parent) {
    if (mainNode == null) {
        return;
    }
    NodeList nodes = mainNode.getChildNodes();
    for (int x = 0; x < nodes.getLength(); ++x) {
        Node node = nodes.item(x);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            String moduleName = node.getNodeName();
            if (!moduleName.trim().isEmpty() && isModuleSupported(moduleName)) {
                MediaController mediaController = getMediaControllerNewInstance(moduleName, node);
                mediaController.init();
                parseXMLAttributes((Element) node, mediaController.asWidget().getElement());
                if (parent instanceof HasWidgets) {
                    ((HasWidgets) parent).add(mediaController.asWidget());
                    if (mediaController instanceof Widget) {
                        parseNode(node, (Widget) mediaController);
                    }
                }
            } else if (parent instanceof ComplexPanel) {
                Panel panel = getPanel(node.getNodeName());
                ((Panel) parent).add(panel);
                parseXMLAttributes((Element) node, panel.getElement());
                parseNode(node, panel);
            }

        } else if (node.getNodeType() == Node.TEXT_NODE) {
            parent.getElement().appendChild(Document.get().createTextNode(node.getNodeValue()));
        }
    }
}
 
Example 47
Project: react4j   File: ReactWidget.java   Source Code and License 5 votes vote down vote up
/**
 * Create the widget.
 *
 * @param reactElement the react element to render.
 */
public ReactWidget( @Nonnull final ReactElement<?, ?> reactElement )
{
  _element = Document.get().createDivElement();
  _reactElement = Objects.requireNonNull( reactElement );
  setElement( _element );
}
 
Example 48
Project: Charba   File: Animation.java   Source Code and License 5 votes vote down vote up
/**
 * Callback called on each step of an animation.
 * 
 * @param item animation item info.
 */
protected void onProgress(AnimationItem item) {
	// creates a native event by GWT (change)
	NativeEvent event = Document.get().createChangeEvent();
	// fires the event
	getChart().fireEvent(new AnimationProgressEvent(event, item));
}
 
Example 49
Project: Charba   File: Animation.java   Source Code and License 5 votes vote down vote up
/**
 * Callback called at the end of an animation.
 * 
 * @param item animation item info.
 */
protected void onComplete(AnimationItem item) {
	// creates a native event by GWT (change)
	NativeEvent event = Document.get().createChangeEvent();
	// fires the event
	getChart().fireEvent(new AnimationCompleteEvent(event, item));
}
 
Example 50
Project: Charba   File: AbstractChart.java   Source Code and License 5 votes vote down vote up
/**
 * Initializes HTMl elements (DIV and Canvas).<br>
 * It sets also some default behaviors (width in percentage) for resizing
 */
public AbstractChart() {
	// creates DIV
	div = Document.get().createDivElement();
	div.setId(id);
	// sets relative position
	div.getStyle().setPosition(Position.RELATIVE);
	// sets default width values
	div.getStyle().setWidth(DEFAULT_PCT_WIDTH, Unit.PCT);
	div.getStyle().setHeight(100, Unit.PCT);
	// checks if canvas is supported
	if (isCanvasSupported) {
		// creates a canvas and add to DIV
		canvas = Document.get().createCanvasElement();
		div.appendChild(canvas);
	} else {
		// creates a header element
		HeadingElement h = Document.get().createHElement(3);
		// to show the error message
		// because canvas is not supported
		h.setInnerText(CANVAS_NOT_SUPPORTED_MESSAGE);
		div.appendChild(h);
		// resets canvas
		canvas = null;
	}
	// sets DIV as element of the widget
	setElement(div);
	// injects Chart.js java script source
	Injector.ensureInjected();
	// creates plugins container
	plugins = new Plugins(this);
	// creates global options
	options = new GlobalOptions(createGlobalOptions(getType().name()));
}
 
Example 51
Project: unitimes   File: ImageLink.java   Source Code and License 5 votes vote down vote up
private void initElements() { 
    iElement = Document.get().createSpanElement(); 
    iAnchor = Document.get().createAnchorElement(); 
    iElement.appendChild(iAnchor); 
    setElement(iElement); 
    sinkEvents(Event.MOUSEEVENTS); 
    setTarget("_blank"); 
}
 
Example 52
Project: unitimes   File: ImageLink.java   Source Code and License 5 votes vote down vote up
public void setText(String text) {
	if (iTextElement == null) {
		iTextElement = Document.get().createSpanElement();
		iAnchor.appendChild(iTextElement);
	}
	iTextElement.setInnerText(text);
}
 
Example 53
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
/**
 * Left sidebar with thumbnail, outline and attachments.

  <div id="sidebarContainer">
    <div id="toolbarSidebar">
      <div class="splitToolbarButton toggled">
        <button id="viewThumbnail" class="toolbarButton toggled" title="Show Thumbnails" tabindex="2" data-l10n-id="thumbs">
           <span data-l10n-id="thumbs_label">Thumbnails</span>
        </button>
        <button id="viewOutline" class="toolbarButton" title="Show Document Outline (double-click to expand/collapse all items)" tabindex="3" data-l10n-id="document_outline">
           <span data-l10n-id="document_outline_label">Document Outline</span>
        </button>
        <button id="viewAttachments" class="toolbarButton" title="Show Attachments" tabindex="4" data-l10n-id="attachments">
           <span data-l10n-id="attachments_label">Attachments</span>
        </button>
      </div>
    </div>
    <div id="sidebarContent">
      <div id="thumbnailView">
      </div>
      <div id="outlineView" class="hidden">
      </div>
      <div id="attachmentsView" class="hidden">
      </div>
    </div>
  </div>  <!-- sidebarContainer -->
 *
 */
private void createSidebar(Document document, DivElement parent) {
	sidebarContainer = createChildDiv(document, parent, "sidebarContainer");
	// create sidebar toolbar
	toolbarSidebar = createChildDiv(document, sidebarContainer, "toolbarSidebar");
	DivElement splitToolbarButton = createChildDiv(document, toolbarSidebar, "splitToolbarButton");
	viewThumbnail = createChildButton(document, splitToolbarButton, "viewThumbnail");
	viewThumbnail.setTabIndex(2);
	viewThumbnail.addClassName("toolbarButton");
	viewThumbnail.setTitle("Show Thumbnails");

	viewOutline = createChildButton(document, splitToolbarButton, "viewOutline");
	viewOutline.setTabIndex(3);
	viewOutline.addClassName("toolbarButton");
	viewOutline.setTitle("Show Document Outline (double-click to expand/collapse all items)");

	viewAttachments = createChildButton(document, splitToolbarButton, "viewAttachments");
	viewAttachments.setTabIndex(4);
	viewAttachments.addClassName("toolbarButton");
	viewAttachments.setTitle("Show Attachments");

	// create sidebar content
	sidebarContent = createChildDiv(document, sidebarContainer, "sidebarContent");
	thumbnailView = createChildDiv(document, sidebarContent, "thumbnailView");
	outlineView = createChildDiv(document, sidebarContent, "outlineView");
	outlineView.addClassName("hidden");
	attachmentsView = createChildDiv(document, sidebarContent, "attachmentsView");
	attachmentsView.addClassName("hidden");
}
 
Example 54
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private void createMainToolbar(Document document, DivElement mainContainer) {
	toolbar = createChildDiv(document, mainContainer, "toolbar");
	toolbarContainer = createChildDiv(document, toolbar, "toolbarContainer");
	toolbarViewer = createChildDiv(document, toolbarContainer, "toolbarViewer");
	toolbarViewerLeft = createChildDiv(document, toolbarViewer, "toolbarViewerLeft");

	sidebarToggleBtn = createChildButton(document, toolbarViewerLeft, "sidebarToggle");
	sidebarToggleBtn.addClassName("toolbarButton");
	sidebarToggleBtn.setTabIndex(11);

	toolbarButtonSpacer = createChildDiv(document, toolbarViewerLeft, "toolbarButtonSpacer");

	viewFind = createChildDiv(document, toolbarViewerLeft, "viewFind");
	viewFind.addClassName("toolbarButton");
	viewFind.setTabIndex(12);
	viewFind.setTitle("Find in Document");

	//paging - previous, next, current page number, jump and all pages
	createPagingSection(document, toolbarViewerLeft);

	toolbarViewerMiddle = createChildDiv(document, toolbarViewer, "toolbarViewerMiddle");
	createZoomingSection(document, toolbarViewerLeft);

	toolbarViewerRight = createChildDiv(document, toolbarViewer, "toolbarViewerRight");
	DivElement verticalToolbarSeparator = createChildDiv(document, toolbarViewerRight, "verticalToolbarSeparator");
	verticalToolbarSeparator.addClassName("hiddenSmallView");

	secondaryToolbarToggle = createChildButton(document, toolbarViewerRight, "secondaryToolbarToggle");
	secondaryToolbarToggle.addClassName("toolbarButton");
	secondaryToolbarToggle.setTitle("Tools");
	secondaryToolbarToggle.setTabIndex(36);
}
 
Example 55
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
/**
 * 
   <div class="splitToolbarButton hiddenSmallView">
     <button class="toolbarButton pageUp" title="Previous Page" id="previous" tabindex="13" data-l10n-id="previous">
       <span data-l10n-id="previous_label">Previous</span>
     </button>
     <div class="splitToolbarButtonSeparator"></div>
     <button class="toolbarButton pageDown" title="Next Page" id="next" tabindex="14" data-l10n-id="next">
       <span data-l10n-id="next_label">Next</span>
     </button>
   </div>
   <input type="number" id="pageNumber" class="toolbarField pageNumber" title="Page" value="1" size="4" min="1" tabindex="15" data-l10n-id="page">
   <span id="numPages" class="toolbarLabel"></span>
 * 
 */
private void createPagingSection(Document document, DivElement parent) {
	DivElement splitToolbarButton = createChildDiv(document, parent, "splitToolbarButton");
	splitToolbarButton.addClassName("hiddenSmallView");

	previousPage = createChildButton(document, splitToolbarButton, "pageUp");
	previousPage.addClassName("toolbarButton");
	previousPage.setTabIndex(13);
	previousPage.setTitle("Previous Page");

	createChildDiv(document, splitToolbarButton, "splitToolbarButtonSeparator");

	nextPage = createChildButton(document, splitToolbarButton, "pageDown");
	nextPage.addClassName("toolbarButton");
	nextPage.setTabIndex(14);
	nextPage.setTitle("Next Page");

	pageNumber = createChildNumber(document, splitToolbarButton, "pageNumber");
	pageNumber.addClassName("toolbarField");
	pageNumber.setTitle("Page");
	pageNumber.setValue("1");
	pageNumber.setSize(4);
	pageNumber.setAttribute("min", "1");
	pageNumber.setTabIndex(15);

	numPages = createChildSpan(document, splitToolbarButton, "numPages");
	numPages.addClassName("toolbarLabel");
}
 
Example 56
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private void createDocumentPropertiesOverlay(Document document, DivElement parent) {
	documentPropertiesOverlay = createChildDiv(document, parent, "documentPropertiesOverlay");
	documentPropertiesOverlay.addClassName("container");
	documentPropertiesOverlay.addClassName("hidden");

	DivElement dialog = createChildDiv(document, documentPropertiesOverlay, "dialog");
	fileNameField = addDocumentPropertiesRow(document, dialog, "File name:");
	fileSizeField = addDocumentPropertiesRow(document, dialog, "File size:");

	createChildDiv(document, dialog, "separator");

	titleField = addDocumentPropertiesRow(document, dialog, "Title:");
	authorField = addDocumentPropertiesRow(document, dialog, "Author:");
	subjectField = addDocumentPropertiesRow(document, dialog, "Subject:");
	keywordsField = addDocumentPropertiesRow(document, dialog, "Keywords:");
	creationDateField = addDocumentPropertiesRow(document, dialog, "Creation Date:");
	modificationDateField = addDocumentPropertiesRow(document, dialog, "Modification Date:");
	creatorField = addDocumentPropertiesRow(document, dialog, "Creator:");

	createChildDiv(document, dialog, "separator");

	producerField = addDocumentPropertiesRow(document, dialog, "PDF Producer:");
	versionField = addDocumentPropertiesRow(document, dialog, "PDF Version:");
	pageCountField = addDocumentPropertiesRow(document, dialog, "Page Count:");

	DivElement buttonRow = createChildDiv(document, dialog, "buttonRow");
	documentPropertiesClose = createChildButton(document, buttonRow, "documentPropertiesClose");
	documentPropertiesClose.addClassName("overlayButton");
	documentPropertiesClose.setInnerText("Close");

}
 
Example 57
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private ParagraphElement addDocumentPropertiesRow(Document document, DivElement dialog, String label) {
	DivElement row = createChildDiv(document, dialog, "row");

	SpanElement span = createChildSpan(document, row, "");
	span.setInnerText(label);

	ParagraphElement result = createChildP(document, row);
	result.setInnerText("-");
	return result;
}
 
Example 58
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private DivElement createDiv_withId(Document document, String nameId) {
	DivElement result = document.createDivElement();
	result.setId(nameId);
	result.addClassName(nameId);

	return result;
}
 
Example 59
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private Element createProgress(Document document, int value, int max) {
	Element result = document.createElement("progress");
	result.setAttribute("value", String.valueOf(value));
	result.setAttribute("max", String.valueOf(max));

	return result;
}
 
Example 60
Project: wt-pdf-viewer   File: WTPdfViewerWidget.java   Source Code and License 5 votes vote down vote up
private OptionElement createChildOption(Document document, SelectElement select, String value, String label) {
	OptionElement option = document.createOptionElement();
	option.setValue(value);
	option.setInnerText(label);

	select.add(option, null);

	return option;
}