List of usage examples for com.google.gwt.user.client.ui Widget addStyleName
public void addStyleName(String style)
From source file:org.openelis.gwt.widget.table.TableColumn.java
License:Open Source License
public void setExceptions(final Widget wid, ArrayList<Exception> exceptions) { //Clean up previous MouseHandlers if (mouseOver != null) { try {// www . j a va 2 s . c o m mouseOver.removeHandler(); } catch (AssertionError e) { mouseOver = null; } } if (mouseOut != null) { try { mouseOut.removeHandler(); } catch (AssertionError e) { mouseOut = null; } } if (exceptions == null || exceptions.size() == 0) { wid.removeStyleName("InputError"); wid.removeStyleName("InputWarning"); return; } errorPanel = new VerticalPanel(); String style = "InputWarning"; if (wid instanceof HasField) { ((HasField) wid).clearExceptions(); ((HasField) wid).getField().drawErrors = false; } for (Exception error : exceptions) { HorizontalPanel hp = new HorizontalPanel(); if (error instanceof Warning) { AbsolutePanel ap = new AbsolutePanel(); ap.setStyleName("warnIcon"); hp.add(ap); hp.setStyleName("warnPopupLabel"); } else { AbsolutePanel ap = new AbsolutePanel(); ap.setStyleName("errorIcon"); hp.add(ap); hp.setStyleName("errorPopupLabel"); style = "InputError"; } hp.add(new Label(error.getMessage())); errorPanel.add(hp); if (wid instanceof HasField) ((HasField) wid).addException(error); } if (wid instanceof HasField) ((HasField) wid).addExceptionStyle(style); else wid.addStyleName(style); mouseOver = ((HasMouseOverHandlers) wid).addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { String styleName = ((Widget) event.getSource()).getStyleName(); //if(styleName.indexOf("InputError") > -1 || styleName.indexOf("InputWarning") > -1){ if (pop == null) { pop = new PopupPanel(true); //pop.setStyleName("ErrorPopup"); } DecoratorPanel dp = new DecoratorPanel(); //ScreenWindow win = new ScreenWindow(pop,"","","",false); dp.setStyleName("ErrorWindow"); dp.add(errorPanel); dp.setVisible(true); pop.setWidget(dp); int left = ((Widget) event.getSource()).getAbsoluteLeft() + ((Widget) event.getSource()).getOffsetWidth(); if (left > controller.view.cellView.getAbsoluteLeft() + controller.view.cellView.getOffsetWidth()) left = controller.view.cellView.getAbsoluteLeft() + controller.view.cellView.getOffsetWidth(); pop.setPopupPosition(left, ((Widget) event.getSource()).getAbsoluteTop()); pop.show(); Timer timer = new Timer() { public void run() { pop.hide(); } }; timer.schedule(5000); } // } }); mouseOut = ((HasMouseOutHandlers) wid).addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { String styleName = ((Widget) event.getSource()).getStyleName(); //if(styleName.indexOf("InputError") > -1 || styleName.indexOf("InputWarning") > -1){ if (pop != null) { pop.hide(); } //} } }); }
From source file:org.openelis.gwt.widget.tree.TreeColumn.java
License:Open Source License
public Widget getDisplayWidget(TreeDataItem row) { TableDataCell cell = new TableDataCell(null); if (columnIndex < row.cells.size()) cell = row.cells.get(columnIndex); Widget wid = null; Object val = null; if (colWidget instanceof CheckBox) { wid = new CheckBoxContainer(); IconContainer icon = new IconContainer(); if (CheckBox.CHECKED.equals(cell.getValue())) icon.setStyleName(CheckBox.CHECKED_STYLE); else if (controller.queryMode && cell.getValue() == null) icon.setStyleName(CheckBox.UNKNOWN_STYLE); else//www.j a v a2s .c o m icon.setStyleName(CheckBox.UNCHECKED_STYLE); setAlign(HasHorizontalAlignment.ALIGN_CENTER); ((AbsolutePanel) wid).add(icon); DOM.setStyleAttribute(wid.getElement(), "align", "center"); wid.setWidth((currentWidth) + "px"); } else { if (colWidget instanceof AutoComplete) { if (controller.queryMode) { val = cell.getValue(); if (val == null) val = ""; } else { TableDataRow vrow = (TableDataRow) cell.getValue(); if (vrow != null) ((AutoComplete) colWidget).setSelection(vrow); else ((AutoComplete) colWidget).setSelection(null, ""); val = ((AutoComplete) colWidget).getTextBoxDisplay(); } } else if (colWidget instanceof Dropdown) { if (cell.getValue() instanceof ArrayList) ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue()); else ((Dropdown) colWidget).setSelection(cell.getValue()); val = ((Dropdown) colWidget).getTextBoxDisplay(); } else { ((HasField) colWidget).setFieldValue(cell.getValue()); } if (val == null) val = ((HasField) colWidget).getFieldValue(); Label label = new Label(""); if (colWidget instanceof org.openelis.gwt.widget.Label) label.setStyleName(colWidget.getStyleName()); else label.setStyleName("ScreenLabel"); if (val != null) { if (colWidget instanceof CalendarLookUp) { label.setText((((CalendarLookUp) colWidget).getField().format())); } else if (colWidget instanceof AutoComplete && controller.queryMode) { label.setText((String) val); } else if (colWidget instanceof DropdownWidget) { label.setText(((DropdownWidget) colWidget).getTextBoxDisplay()); } else if (colWidget instanceof TextBoxBase) { label.setText(((TextBoxBase) colWidget).getText()); } else if (colWidget instanceof Label) label.setText(((Label) colWidget).getText()); } label.setWordWrap(false); wid = label; wid.setWidth((currentWidth) + "px"); } setExceptions(wid, cell.exceptions); wid.addStyleName("TableWidget"); return wid; }
From source file:org.openelis.gwt.widget.tree.TreeColumn.java
License:Open Source License
public Widget getWidgetEditor(TableDataRow row) { TableDataCell cell = new TableDataCell(null); if (columnIndex < row.cells.size()) cell = row.cells.get(columnIndex); Widget editor = colWidget; if (colWidget instanceof CheckBox) { CheckBoxContainer ap = new CheckBoxContainer(); ((CheckBox) editor).setValue((String) cell.getValue()); ap.setWidth((currentWidth) + "px"); ap.add(editor);/* ww w .java2 s .c o m*/ return ap; } editor = colWidget; editor.setWidth((currentWidth) + "px"); if (colWidget instanceof AutoComplete) { if (controller.queryMode) { ((AutoComplete) colWidget).textbox.setText((String) cell.getValue()); } else { TableDataRow vrow = (TableDataRow) cell.getValue(); if (vrow != null) ((AutoComplete) colWidget).setSelection(vrow); else ((AutoComplete) colWidget).setSelection(null, ""); } } else if (colWidget instanceof Dropdown) { if (cell.getValue() instanceof ArrayList) ((Dropdown) colWidget).setSelectionKeys((ArrayList<Object>) cell.getValue()); else ((Dropdown) colWidget).setSelection(cell.getValue()); } else ((HasField) editor).setFieldValue(cell.getValue()); ((HasField) editor).clearExceptions(); setExceptions(editor, cell.exceptions); editor.addStyleName("TableWidget"); return editor; }
From source file:org.openelis.gwt.widget.tree.TreeColumn.java
License:Open Source License
public void setExceptions(Widget wid, ArrayList<Exception> exceptions) { //Clean up previous MouseHandlers if (mouseOver != null) { try {/* w w w . j av a 2s.co m*/ mouseOver.removeHandler(); } catch (AssertionError e) { mouseOver = null; } } if (mouseOut != null) { try { mouseOut.removeHandler(); } catch (AssertionError e) { mouseOut = null; } } if (exceptions == null || exceptions.size() == 0) { wid.removeStyleName("InputError"); wid.removeStyleName("InputWarning"); return; } errorPanel = new VerticalPanel(); String style = "InputWarning"; if (wid instanceof HasField) { ((HasField) wid).clearExceptions(); ((HasField) wid).getField().drawErrors = false; } for (Exception error : exceptions) { HorizontalPanel hp = new HorizontalPanel(); if (error instanceof Warning) { AbsolutePanel ap = new AbsolutePanel(); ap.setStyleName("warnIcon"); hp.add(ap); hp.setStyleName("warnPopupLabel"); } else { AbsolutePanel ap = new AbsolutePanel(); ap.setStyleName("errorIcon"); hp.add(ap); hp.setStyleName("errorPopupLabel"); style = "InputError"; } hp.add(new Label(error.getMessage())); errorPanel.add(hp); if (wid instanceof HasField) ((HasField) wid).addException(error); } if (wid instanceof HasField) ((HasField) wid).addExceptionStyle(style); else wid.addStyleName(style); mouseOver = ((HasMouseOverHandlers) wid).addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(MouseOverEvent event) { String styleName = ((Widget) event.getSource()).getStyleName(); //if(styleName.indexOf("InputError") > -1 || styleName.indexOf("InputWarning") > -1){ if (pop == null) { pop = new PopupPanel(true); //pop.setStyleName("ErrorPopup"); } DecoratorPanel dp = new DecoratorPanel(); //ScreenWindow win = new ScreenWindow(pop,"","","",false); dp.setStyleName("ErrorWindow"); dp.add(errorPanel); dp.setVisible(true); pop.setWidget(dp); int left = ((Widget) event.getSource()).getAbsoluteLeft() + ((Widget) event.getSource()).getOffsetWidth(); if (left > controller.view.cellView.getAbsoluteLeft() + controller.view.cellView.getOffsetWidth()) left = controller.view.cellView.getAbsoluteLeft() + controller.view.cellView.getOffsetWidth(); pop.setPopupPosition(left, ((Widget) event.getSource()).getAbsoluteTop()); pop.show(); Timer timer = new Timer() { public void run() { pop.hide(); } }; timer.schedule(5000); } // } }); mouseOut = ((HasMouseOutHandlers) wid).addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(MouseOutEvent event) { String styleName = ((Widget) event.getSource()).getStyleName(); //if(styleName.indexOf("InputError") > -1 || styleName.indexOf("InputWarning") > -1){ if (pop != null) { pop.hide(); } //} } }); }
From source file:org.opennms.features.dashboard.client.portlet.BasicPortlet.java
License:Open Source License
private void addResizeHandle(Widget w, DirectionConstant direction) { resizeDragController.makeDraggable(w, direction); w.addStyleName("Resize-" + direction.directionLetters); }
From source file:org.openremote.app.client.map.MapInfoPanel.java
License:Open Source License
public void setItems(List<MapInfoItem> infoItems) { contentPanel.clear();/*from w w w. jav a 2 s .c om*/ int itemLineHeightPixels = 20; int itemMarginPixels = 8; int itemHeightPixels = itemLineHeightPixels + (itemMarginPixels * 2); int totalMaxHeight = itemHeightPixels * MAX_ITEMS_BEFORE_SCROLLING; for (MapInfoItem infoItem : infoItems) { IconLabel itemIcon = new IconLabel(infoItem.getIcon()); itemIcon.addStyleName(style.infoItemIcon()); FormLabel itemLabel = new FormLabel(TextUtil.ellipsize(infoItem.getLabel(), 35)); itemLabel.addStyleName("flex"); itemLabel.addStyleName(style.infoItemLabel()); Widget itemValue = createItemValue(infoItem); itemValue.addStyleName(style.infoItemValue()); FlowPanel itemPanel = new FlowPanel(); itemPanel.addStyleName("flex-none layout horizontal center"); itemPanel.addStyleName(style.infoItem()); itemPanel.add(itemIcon); itemPanel.add(itemLabel); itemPanel.add(itemValue); contentPanel.add(itemPanel); } // Show up to 6 items, then start scrolling panel.setHeight(Math.min((infoItems.size() * itemHeightPixels), totalMaxHeight) + "px"); // If the panel is already shown, "blink" it so users know there is an update if (isOpen()) { contentPanel.addStyleName(widgetStyle.HighlightBackground()); Browser.getWindow().setTimeout(() -> { contentPanel.removeStyleName(widgetStyle.HighlightBackground()); }, 250); } }
From source file:org.openremote.app.client.widget.SecondaryNavigation.java
License:Open Source License
@Override public void add(Widget w) { super.add(w); w.addStyleName("or-SecondaryNavItem"); }
From source file:org.openxdata.designer.client.controller.FormDesignerDragController.java
/** * Called by {@link PickupDragController#dragStart()} to allow subclasses to * provide their own drag proxies.//from www .j a v a 2 s . c o m * * @param context the current drag context * @return a new drag proxy */ protected Widget newDragProxy(DragContext context) { AbsolutePanel container = new AbsolutePanel(); container.getElement().getStyle().setProperty("overflow", "visible"); WidgetArea draggableArea = new WidgetArea(context.draggable, null); for (Widget widget : context.selectedWidgets) { WidgetArea widgetArea = new WidgetArea(widget, null); Widget proxy = new SimplePanel(); proxy.setPixelSize(widget.getOffsetWidth(), widget.getOffsetHeight()); proxy.addStyleName(PRIVATE_CSS_PROXY); container.add(proxy, widgetArea.getLeft() - draggableArea.getLeft(), widgetArea.getTop() - draggableArea.getTop()); } return container; }
From source file:org.openxdata.designer.client.controller.FormDesignerDragController.java
public void selectWidget(Widget draggable) { assert draggable != null; if (!context.selectedWidgets.contains(draggable)) { context.selectedWidgets.add(draggable); draggable.addStyleName("dragdrop-selected"); }//from ww w .ja va 2 s .c om }
From source file:org.orwell.widgets.RoundedPanel.java
License:Apache License
@Override public void addStyleName(String style) { Widget w = getWidget(); if (w != null) { w.addStyleName(style); setCornerStyleName(w.getStyleName()); } else {/* w ww . j a v a 2 s . c om*/ setCornerStyleName(style); } }