List of usage examples for com.google.gwt.user.client.ui Widget setStyleName
public void setStyleName(String style)
From source file:org.ednovo.gooru.client.util.ImageUtil.java
License:Open Source License
public static void renderResourceImage(Widget widget, String category) { category = category.toLowerCase();/*from ww w. ja v a 2s . c om*/ ShelfCBundle.INSTANCE.css().ensureInjected(); if (category == null || category.equalsIgnoreCase(QUESTION) || category.startsWith(ASSESSMENT)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().questionSmall()); } else if (category.equalsIgnoreCase(EXAM)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().websiteSmall()); } else if (category.equalsIgnoreCase(HANDOUT)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().textbookSmall()); } else if (category.equalsIgnoreCase(SLIDE)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().imageSmall()); } else if (category.equalsIgnoreCase(INTERACTIVE)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().interactiveSmall()); } else if (category.equalsIgnoreCase(WEBSITE) || category.equalsIgnoreCase(WEBPAGE)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().websiteSmall()); } else if (category.equalsIgnoreCase(TEXTBOOK) || category.equalsIgnoreCase(TEXT)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().textbookSmall()); } else if (category.equalsIgnoreCase(LESSON)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().textbookSmall()); } else if (category.equalsIgnoreCase(VIDEO)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().videoSmall()); } else if (category.equalsIgnoreCase(CHALLENGE)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().websiteSmall()); } else if (category.equalsIgnoreCase(IMAGE)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().imageSmall()); } else if (category.equalsIgnoreCase(OTHER)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().otherSmall()); } else if (category.equalsIgnoreCase(AUDIO)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().audioSmall()); } else if (category.equalsIgnoreCase(DRAG_TYPE.COLLECTION.getName())) { widget.setStyleName(ShelfCBundle.INSTANCE.css().collectionSmall()); } else if (category.equalsIgnoreCase(FOLDER)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().myFoldersIcon()); } else if (category.equalsIgnoreCase(COLLECTION)) { widget.setStyleName(ShelfCBundle.INSTANCE.css().myScollectionsIcon()); } }
From source file:org.freemedsoftware.gwt.client.widget.SimpleUIBuilder.java
License:Open Source License
/** * Add widget to display//from w w w . j av a 2s .c om * * @param name * Variable name to be associated with this widget. * @param title * Caption for display to the user. * @param type * Widget type, textual. * @param options * Optional, to describe additional options. * @param value * Default value. */ public void addWidget(String name, String title, WidgetType type, String options, String value, String help) { Widget w; if (type.equals(WidgetType.TEXT)) { w = new CustomTextBox(); try { Integer len = new Integer(options); if (len > 0) { JsonUtil.debug("addWidget " + name + " has length of " + len); ((CustomTextBox) w).setVisibleLength(len.intValue() + 1); ((CustomTextBox) w).setMaxLength(len.intValue()); } } catch (Exception ex) { } } else if (type.equals(WidgetType.MODULE)) { w = new SupportModuleWidget(options); } else if (type.equals(WidgetType.MODULE_MULTIPLE)) { w = new SupportModuleMultipleChoiceWidget(options); } else if (type.equals(WidgetType.USER_MULTIPLE)) { w = new UserMultipleChoiceWidget(); } else if (type.equals(WidgetType.SELECT)) { w = new CustomListBox(); // Push in all "options" values String[] o = options.split(","); for (int iter = 0; iter < o.length; iter++) { // Check for "description" pairs if (o[iter].contains("|")) { String[] i = o[iter].split("\\|"); ((CustomListBox) w).addItem(i[0], i[1]); } else { if (o[iter].length() > 0) { ((CustomListBox) w).addItem(o[iter]); } } } } else if (type.equals(WidgetType.PATIENT)) { w = new PatientWidget(); } else if (type.equals(WidgetType.DATE)) { w = new CustomDatePicker(); } else if (type.equals(WidgetType.COLOR)) { w = new CustomColorPicker(); } else if (type.equals(WidgetType.DRUG)) { w = new DrugWidget(); } else if (type.equals(WidgetType.DELIMITER)) { w = new Label(_(title)); w.setStyleName("freemed-SimpleUIBuilder-Delimiter"); } else if (type.equals(WidgetType.MULTILIST)) { w = new CustomMulltiSelectListBox(options, true); } else if (type.equals(WidgetType.SINGLELIST)) { w = new CustomMulltiSelectListBox(options, false); } else if (type.equals(WidgetType.CHECKBOX)) { w = new CheckBox(); } else { // Unimplemented, use text box as fallback w = new CustomTextBox(); JsonUtil.debug("SimpleUIBuilder: Unimplemented type '" + type + "' found. Fallback to TextBox."); } // Add to indices and display widgets.put(name, w); if (type.equals(WidgetType.DELIMITER)) { table.setWidget(widgets.size() - 1, 0, w); table.getFlexCellFormatter().setColSpan(widgets.size() - 1, 0, 2); } else { table.setText(widgets.size() - 1, 0, _(title)); table.setWidget(widgets.size() - 1, 1, w); if (help != null) { final Image image = new Image(); image.setUrl("resources/images/q_help.16x16.png"); Util.attachHelp(image, helpprefix + " " + _(title), help, false); table.setWidget(widgets.size() - 1, 2, image); } } // Set widget value after it is added. this.setWidgetValue(name, value); }
From source file:org.glom.web.client.ui.details.SingleLineText.java
License:Open Source License
public SingleLineText(final String text) { Widget dataWidget; if (text.startsWith("http://") || text.startsWith("ftp://")) { dataWidget = new Anchor(text, text, "_blank"); dataWidget.setStyleName("dataLink"); } else if (text.startsWith("www.")) { dataWidget = new Anchor(text, "http://" + text, "_blank"); dataWidget.setStyleName("dataLink"); } else {/*from ww w .j av a 2 s . c o m*/ final Label dataLabel = new Label(); dataLabel.setText(text); dataWidget = dataLabel; } final Style style = dataWidget.getElement().getStyle(); style.setOverflow(Overflow.HIDDEN); style.setProperty("textOverflow", "ellipsis"); initWidget(dataWidget); }
From source file:org.gwtportlets.portlet.client.edit.DefaultWidgetEditor.java
License:Open Source License
/** * Change the style of the widget. Includes undo support. *///from w ww. j a v a 2 s . co m protected void changeStyleName(PageEditor manager, Widget widget, String styleName) { String c = widget.getStyleName(); if (styleName.equals(c)) { return; } manager.beginUndo(styleName.length() == 0 ? "Remove Style " + c : "Set Style " + styleName); widget.setStyleName(styleName); Widget p = widget.getParent(); if (p instanceof Container) { ((Container) p).layout(); // border or padding of widget may have changed } }
From source file:org.jbpm.form.builder.ng.model.client.form.items.TabbedLayoutFormItem.java
License:Apache License
@Override public Widget cloneDisplay(Map<String, Object> data) { TabLayoutPanel panel = new MyTabLayoutPanel(25, Unit.PX); panel.getElement().setId(this.id); panel.getElement().setClassName(this.cssClassName); for (int index = 0; index < this.titles.size() && index < this.tabs.size(); index++) { FlowLayoutFormItem flow = this.tabs.get(index); TabLabelFormItem label = this.titles.get(index); if (flow != null && label != null) { Widget newFlow = flow.cloneDisplay(data); if (this.cssClassName != null && !"".equals(this.cssClassName)) { newFlow.setStyleName(this.cssClassName); }// w ww. j a va 2s . co m panel.add(newFlow, label.cloneDisplay(data)); } } super.populateActions(panel.getElement()); return panel; }
From source file:org.nightcode.gwt.selectio.client.ui.ItemSelector.java
License:Apache License
public ItemSelector(final SelectorRequestFactory requestFactory, int height) { this.height = height; final CellList.Resources cellListResources = GWT.create(CellListResources.class); final SelectorMessages messages = Selector.MESSAGES; display = new CellList<ItemProxy>(new ItemCell(), cellListResources); display.setStyleName("slt-items"); Widget noDataWidget = new Label(messages.noData()); noDataWidget.setStyleName("slt-nodata"); display.setEmptyListWidget(noDataWidget); Widget loadingWidget = new Label(messages.loading()); loadingWidget.setStyleName("slt-loading"); display.setLoadingIndicator(loadingWidget); display.setSelectionModel(selectionModel); display.setValueUpdater(new ValueUpdater<ItemProxy>() { @Override/* ww w . jav a2s. co m*/ public void update(ItemProxy value) { selectionModel.setSelected(value, !selectionModel.isSelected(value)); } }); dataProvider = new AsyncDataProvider<ItemProxy>() { @Override protected void onRangeChanged(HasData<ItemProxy> itemHasData) { Range searchRange = itemHasData.getVisibleRange(); requestFactory.itemRequest() .getItems(queryField.getText(), searchRange.getStart(), searchRange.getLength() + 1) .fire(itemsReceiver); // ask one more item to examine should we enable next button } }; dataProvider.addDataDisplay(display); final VerticalPanel mainPanel = createVerticalPanel("slt-container"); initWidget(mainPanel); mainPanel.setSpacing(7); final Timer requestTimer = new Timer() { @Override public void run() { selectionModel.setSearch(queryField.getText()); Range[] searchRanges = dataProvider.getRanges(); if (searchRanges == null || searchRanges.length == 0) { return; } display.setPageStart(0); requestFactory.itemRequest().getItems(queryField.getText(), 0, searchRanges[0].getLength() + 1) .fire(itemsReceiver); // ask one more item to examine should we enable next button } }; queryField.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { requestTimer.schedule(300); } }); Anchor search = createAnchor(ItemSelectionModel.Type.SEARCH, messages.search()); all = createAnchor(ItemSelectionModel.Type.ALL, messages.all()); none = createAnchor(ItemSelectionModel.Type.NONE, messages.none()); FlowPanel selectionPanel = new FlowPanel(); selectionPanel.setStyleName("btn-group"); selectionPanel.add(search); selectionPanel.add(all); selectionPanel.add(none); FlowPanel itemsPanel = new FlowPanel(); itemsPanel.setStyleName("slt-frame slt-items-box"); itemsPanel.add(display); final ItemPager pager = new ItemPager(messages); pager.setDisplay(display); mainPanel.setCellHorizontalAlignment(pager, HasHorizontalAlignment.ALIGN_RIGHT); selectedDescription.setStyleName("slt-frame slt-selected"); Element selectedUl = DOM.createElement("ul"); selectedUl.setClassName("slt-selected-box"); appendItem(selectedUl, ItemSelectionModel.Type.ALL, messages.none()); insertTitle(selectedUl, messages.selected()); DOM.appendChild(selectedDescription.getElement(), selectedUl); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { selectedDescription.clear(); Element selectedUl = DOM.createElement("ul"); selectedUl.setClassName("slt-selected-box"); Element deselectedUl = DOM.createElement("ul"); deselectedUl.setClassName("slt-selected-box"); Map<ItemProxy, Boolean> exceptions = selectionModel.getExceptions(); if (ItemSelectionModel.Type.ALL.equals(selectionModel.getType())) { appendItem(selectedUl, ItemSelectionModel.Type.NONE, messages.all()); } List<String> searchQueries = selectionModel.getSearchQueries(); for (int i = searchQueries.size() - 1; i >= 0; i--) { appendItem(selectedUl, searchQueries.get(i)); } for (Map.Entry<ItemProxy, Boolean> entry : exceptions.entrySet()) { Element parent = (entry.getValue()) ? selectedUl : deselectedUl; appendItem(parent, entry.getKey()); } if (selectedUl.getChildCount() == 0) { appendItem(selectedUl, ItemSelectionModel.Type.ALL, messages.none()); } insertTitle(selectedUl, messages.selected()); DOM.appendChild(selectedDescription.getElement(), selectedUl); if (deselectedUl.getChildCount() != 0) { insertTitle(deselectedUl, messages.except()); DOM.appendChild(selectedDescription.getElement(), deselectedUl); } updateButtonsStyle(); } }); attachPanel(mainPanel, queryField, 5); attachPanel(mainPanel, selectionPanel, 5); attachPanel(mainPanel, itemsPanel, 50); attachPanel(mainPanel, pager, 5); attachPanel(mainPanel, selectedDescription, 25); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.screen.ci.NewCIScreen.java
License:Open Source License
protected void update(String objectType) { this.templateAlias = objectType; input.setStyleName("one-new-screen-panel"); attributePanel = new CIValueInputPanel(); Widget buttonPanel = getButtonPanel(); buttonPanel.setStyleName("one-button-panel"); input.add(attributePanel);/* w w w.j a va 2 s . c om*/ input.add(buttonPanel); input.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_CENTER); input.setCellVerticalAlignment(buttonPanel, VerticalPanel.ALIGN_TOP); System.out.println("NewCIScreen.Load(" + objectType + ")"); // Create a new Render every time, since it holds mapping between widget and values! render = new AttributeRender(); render.setIsNew(isNew()); attributePanel.setAttributeRender(render); /* if (this.templateAlias == objectType) { this.attributePanel.clear(); } else { */ control = getControl(); control.setAttributeFilter(getAttributeFilter()); this.attributePanel.setAttributeValueControl(control); this.attributePanel.addLoadListener(this); this.attributePanel.load(); //} }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.screen.OneCMDBBaseScreen.java
License:Open Source License
protected void setHeaderStyle(String style) { // Need to fetch the header panel from dockpanel. for (int i = 0; i < dockPanel.getWidgetCount(); i++) { Widget w = dockPanel.getWidget(i); DockLayoutConstant direction = dockPanel.getWidgetDirection(w); if (direction.equals(DockPanel.NORTH)) { w.setStyleName(style); }//ww w .j a va 2 s.com } }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.table.CITablePanel.java
License:Open Source License
public void addHeader(int column, Widget header) { //hasHeader=true; RowFormatter rowFormatter = getRowFormatter(); rowFormatter.setStyleName(0, STYLE_HEADER); header.setStyleName(STYLE_HEADER_CELL); setWidget(0, column, header);//from w w w . j av a2 s .c om }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.table.CITablePanel.java
License:Open Source License
protected void reload() { loadListenerCollection.fireOnLoadStart(this); this.control.getRows(new AsyncCallback() { public void onFailure(Throwable caught) { loadListenerCollection.fireOnLoadFailure(CITablePanel.this, caught); }//from w w w.j a v a 2 s.c om public void onSuccess(Object result) { if (result instanceof List) { List rows = (List) result; Integer firstItem = control.getFirstItem(); int rowIndex = 1; if (firstItem != null) { rowIndex = firstItem.intValue(); rowIndex++; } System.out.println("ROW COUNT=" + rows.size()); for (int row = 0; row < rows.size(); row++) { Object rowData = rows.get(row); setText(row + 1, 0, "" + rowIndex); rowIndex++; if (((row + 1) % 2) == 0) { getRowFormatter().setStyleName(row + 1, STYLE_ROW_EVEN); } else { getRowFormatter().setStyleName(row + 1, STYLE_ROW_ODD); } getCellFormatter().setStyleName(row + 1, 0, STYLE_HEADER); if (rowData instanceof List) { List cols = (List) rowData; for (int col = 1; col < (cols.size() + 1); col++) { Object colObject = cols.get(col - 1); Widget widget = render.getColumnWidget(colObject); if (widget != null) { widget.setWidth("100%"); widget.setStyleName(STYLE_CELL); if (widget instanceof IBaseField) { setWidget(row + 1, col, ((IBaseField) widget).getBaseField()); } else { setWidget(row + 1, col, widget); } } else { setText(row + 1, col, ""); } } } } // Remove not visible rows. for (int row = (control.getMaxResult().intValue() + 1); row > rows.size(); row--) { if (getRowCount() > row) { removeRow(row); } } } loadListenerCollection.fireOnLoadComplete(CITablePanel.this); } }); }