Java Code Examples for com.google.gwt.user.client.Event#setEventListener()
The following examples show how to use
com.google.gwt.user.client.Event#setEventListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PerspectiveDragConfigModalView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addItem(String name, Command onSelect) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); selectorItems.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { onSelect.execute(); } }); }
Example 2
Source File: TableEmptyState.java From cuba with Apache License 2.0 | 6 votes |
public TableEmptyState() { container = Document.get().createDivElement(); container.setClassName("c-table-empty-state"); messageBox = Document.get().createDivElement(); messageBox.setClassName("c-table-empty-state-message-box"); messageLabel = Document.get().createDivElement(); messageLabel.setClassName("c-table-empty-state-message"); linkMessageLabel = Document.get().createSpanElement(); linkMessageLabel.setClassName("c-table-empty-state-link-message v-button-link"); container.appendChild(messageBox); Event.sinkEvents(container, Event.ONCLICK); Event.setEventListener(container, this); }
Example 3
Source File: DataStore.java From djvu-html5 with GNU General Public License v2.0 | 6 votes |
private CanvasElement prepareMissingTileImage() { int tileSize = DjvuContext.getTileSize(); CanvasElement canvas = createImage(tileSize, tileSize); Context2d context2d = canvas.getContext2d(); context2d.setFillStyle("white"); context2d.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); Image image = new Image(); final ImageElement imageElement = image.getElement().cast(); imageElement.getStyle().setProperty("visibility", "hidden"); Event.setEventListener(imageElement, event -> { if (Event.ONLOAD == event.getTypeInt()) { missingTileImage.getContext2d().drawImage(imageElement, 0, 0); RootPanel.get().getElement().removeChild(imageElement); } }); RootPanel.get().getElement().appendChild(imageElement); image.setUrl(getBlankImageUrl()); return canvas; }
Example 4
Source File: PerspectivesExplorerView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addPerspective(String name, Command onClicked) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.getStyle().setCursor(Style.Cursor.POINTER); anchor.getStyle().setColor("black"); anchor.getStyle().setProperty("fontSize", "larger"); anchor.setInnerText(name); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { onClicked.execute(); } }); SpanElement icon = Document.get().createSpanElement(); icon.getStyle().setMarginRight(10, Style.Unit.PX); icon.setClassName("pficon-virtual-machine"); icon.getStyle().setProperty("fontSize", "larger"); DivElement gi = createItemDiv(new Element[] {icon, anchor}); perspectivesDiv.appendChild((Node) gi); }
Example 5
Source File: TopMenuBar.java From dashbuilder with Apache License 2.0 | 6 votes |
private void addEntry(String entry, boolean logout) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(entry); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if (Event.ONCLICK == event.getTypeInt()) { if (!logout) { onRoleClicked(entry); } else { onLogoutClicked(); } } }); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); roleList.appendChild((Node) li); }
Example 6
Source File: DisplayerHtmlEditorView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addSourceCodeItem(String name) { AnchorElement anchor = Document.get().createAnchorElement(); String displayName = DisplayerHtmlConstants.INSTANCE.getString("displayer_source_code_" + name); anchor.setInnerText(displayName); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); tabList.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { presenter.onSourceCodeItemSelected(name); if (selectedItem != null) { selectedItem.setClassName(""); selectedItem.getStyle().setCursor(Style.Cursor.POINTER); } selectedItem = li; selectedItem.setClassName("active"); selectedItem.getStyle().setCursor(Style.Cursor.DEFAULT); previewItem.setClassName(""); } }); }
Example 7
Source File: SourceCodeEditorView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void declareVariable(String var, String description) { SpanElement span = Document.get().createSpanElement(); span.setInnerText(var); AnchorElement anchor = Document.get().createAnchorElement(); anchor.setTitle(description); anchor.appendChild(span); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); variablesMenu.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { presenter.onVariableSelected(var); } }); }
Example 8
Source File: CubaGridEmptyState.java From cuba with Apache License 2.0 | 6 votes |
public CubaGridEmptyState() { container = Document.get().createDivElement(); container.setClassName("c-datagrid-empty-state"); messageBox = Document.get().createDivElement(); messageBox.setClassName("c-datagrid-empty-state-message-box"); messageLabel = Document.get().createDivElement(); messageLabel.setClassName("c-datagrid-empty-state-message"); linkMessageLabel = Document.get().createSpanElement(); linkMessageLabel.setClassName("c-datagrid-empty-state-link-message v-button-link"); container.appendChild(messageBox); Event.sinkEvents(container, Event.ONCLICK); Event.setEventListener(container, this); }
Example 9
Source File: NavTilesWidgetView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addBreadcrumbItem(String navItemName, Command onClicked) { LIElement li = Document.get().createLIElement(); breadcrumb.appendChild((Node) li); if (onClicked != null) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(navItemName); li.appendChild(anchor); li.getStyle().setCursor(Style.Cursor.POINTER); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if (Event.ONCLICK == event.getTypeInt()) { onClicked.execute(); } }); } else { ((Node) li).setTextContent(navItemName); li.setClassName("active"); } }
Example 10
Source File: NavComponentConfigModalView.java From dashbuilder with Apache License 2.0 | 6 votes |
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); li.setClassName(selected ? "selected" : ""); unorderedList.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { onSelect.execute(); } }); }
Example 11
Source File: NavRootNodeEditorView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addCommand(String name, Command command) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); commandMenu.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { command.execute(); } }); }
Example 12
Source File: TargetPerspectiveEditorView.java From dashbuilder with Apache License 2.0 | 6 votes |
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); li.setClassName(selected ? "selected" : ""); unorderedList.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { onSelect.execute(); } }); }
Example 13
Source File: NavItemDefaultEditorView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addCommand(String name, Command command) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); commandMenu.appendChild((Node) li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if(Event.ONCLICK == event.getTypeInt()) { command.execute(); } }); }
Example 14
Source File: BaseNavWidgetView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void addItem(String id, String name, String description, Command onItemSelected) { AnchorElement anchor = Document.get().createAnchorElement(); anchor.setInnerText(name); if (description != null && !description.equals(name)) { anchor.setTitle(description); } LIElement li = Document.get().createLIElement(); li.getStyle().setCursor(Style.Cursor.POINTER); li.appendChild(anchor); navWidget.appendChild((Node) li); itemMap.put(id, li); Event.sinkEvents(anchor, Event.ONCLICK); Event.setEventListener(anchor, event -> { if (Event.ONCLICK == event.getTypeInt()) { onItemSelected.execute(); } }); }
Example 15
Source File: NavTreeWidgetView.java From dashbuilder with Apache License 2.0 | 5 votes |
protected void addItem(String iconClass, String id, String name, String description, Command onClicked) { Element nameEl = onClicked != null ? Document.get().createAnchorElement() : Document.get().createSpanElement(); nameEl.setInnerText(name); nameEl.setClassName(onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable"); if (description != null && !description.equals(name)) { nameEl.setTitle(description); } SpanElement iconSpan = Document.get().createSpanElement(); iconSpan.setClassName("uf-navtree-widget-icon " + iconClass); DivElement div = Document.get().createDivElement(); div.appendChild(iconSpan); div.appendChild(nameEl); navWidget.appendChild((Node) div); itemMap.put(id, nameEl); if (onClicked != null) { Event.sinkEvents(nameEl, Event.ONCLICK); Event.setEventListener(nameEl, event -> { if (Event.ONCLICK == event.getTypeInt()) { onClicked.execute(); } }); } }
Example 16
Source File: DjVuPage.java From djvu-html5 with GNU General Public License v2.0 | 5 votes |
private GPixmap decodeJPEG(CachedInputStream iff) throws IOException { final GPixmap result = new GPixmap(); final Image image = new Image(); final ImageElement imageElement = image.getElement().cast(); imageElement.getStyle().setProperty("visibility", "hidden"); Event.setEventListener(imageElement, new EventListener() { @Override public void onBrowserEvent(Event event) { if (Event.ONLOAD == event.getTypeInt()) { final int w = imageElement.getWidth(), h = imageElement.getHeight(); final Canvas canvas = Canvas.createIfSupported(); canvas.setWidth(w + "px"); canvas.setCoordinateSpaceWidth(w); canvas.setHeight(h + "px"); canvas.setCoordinateSpaceHeight(h); canvas.getContext2d().drawImage(imageElement, 0, 0); result.init(h, w, null); //TODO result.setImageData(canvas.getContext2d().getImageData(0, 0, w, h)); } } }); StringBuilder data = new StringBuilder(); int b; while ((b = iff.read()) != -1) { data.append((char) b); } String dataURL = "data:image/jpeg;base64," + btoa(data.toString()); image.setUrl(dataURL); return result; }
Example 17
Source File: CubaWindowWidget.java From cuba with Apache License 2.0 | 5 votes |
public CubaWindowWidget() { DOM.sinkEvents(header, DOM.getEventsSunk(header) | Event.ONCONTEXTMENU); addStyleName(NONMODAL_WINDOW_CLASSNAME); Event.sinkEvents(getModalityCurtain(), Event.ONCLICK); Event.setEventListener(getModalityCurtain(), event -> { if (closeOnClickOutside) { if (clickOnModalityCurtain != null) { clickOnModalityCurtain.run(); } } }); }