public void render(final Comboitem item, final Object data, final int index) { final Combobox cb = (Combobox) item.getParent(); final Template tm = cb.getTemplate("model"); if (tm == null) { item.setLabel(Objects.toString(data)); item.setValue(data); } else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(item.getParent(), item, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) { if (nci.getValue() == null) //template might set it nci.setValue(data); item.setAttribute(Attributes.MODEL_RENDERAS, nci); item.detach();
private void enableResultItems(String... labels) { List<String> enable = Arrays.asList(labels); Comboitem firstVisible = null; for (Object object : cboResults.getItems()) { Comboitem item = (Comboitem) object; boolean visible = enable.contains(item.getLabel()); item.setVisible(visible); if (visible && firstVisible == null) { firstVisible = item; } } cboResults.setSelectedItem(firstVisible); }
/** Creates an new and unloaded Comboitem. */ private Comboitem newUnloadedItem(ComboitemRenderer<?> renderer) { Comboitem item = null; if (renderer instanceof ComboitemRendererExt) item = ((ComboitemRendererExt) renderer).newComboitem(this); if (item == null) { item = new Comboitem(); item.applyProperties(); } return item; }
private ProblemFilter getFilter() { return (ProblemFilter) cboFilter.getSelectedItem().getValue(); }
/** * @see org.carewebframework.ui.FrameworkController#doAfterCompose(org.zkoss.zk.ui.Component) */ @Override public void doAfterCompose(final Component comp) throws Exception { super.doAfterCompose(comp); bgoSecurity = BgoUtil.initSecurity("BGO DISABLE PROB LIST EDITING", "BGOZ PROBLEM LIST EDIT"); lbProblems.setItemRenderer(problemRenderer); RowComparator.autowireColumnComparators(lbProblems.getListhead().getChildren()); m_bPersHistAndAct = SecurityUtil.isGranted("BGO PL INCLUDE PERS HIST W ACT"); for (Object item : cboFilter.getItems()) { Comboitem ci = (Comboitem) item; ProblemFilter filter = ProblemFilter.valueOf(ci.getValue().toString()); ci.setValue(m_bPersHistAndAct && filter == ProblemFilter.ACTIVE ? ProblemFilter.ACTIVE_PERSONAL : filter); } setFilter(getDefaultFilter()); getAppFramework().registerObject(patientContextEventHandler); getAppFramework().registerObject(encounterContextEventHandler); patientContextEventHandler.committed(); log.trace("Controller composed"); }
/** * Initialize the dialog. */ @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); notification = (ScheduledNotification) arg.get("notification"); for (Priority priority : Priority.values()) { Comboitem item = new Comboitem(PriorityRenderer.getDisplayName(priority), PriorityRenderer.getImage(priority)); item.setValue(priority); cboPriority.appendChild(item); } if (notification == null) { notification = new ScheduledNotification(); notification.setPriority(Priority.LOW); notification.setDeliveryDate(new FMDate()); recipients.add(new Recipient(UserContext.getActiveUser())); } else { service.getScheduledNotificationRecipients(notification, recipients); } populateForm(); }
lstInpatient.setItemRenderer(encounterRenderer); lstOutpatient.setItemRenderer(encounterRenderer); rngDateRange.getItemAtIndex(0).setLabel("Default Date Range"); rngDateRange.setSelectedIndex(0); broker = VistAUtil.getBrokerSession(); String pcs[] = StrUtil.split(sc, "~", 3); Comboitem item = cboServiceCategory.appendItem(pcs[1]); item.setValue(pcs[0]); item.setTooltiptext(pcs[2]);
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Comboitem self = (Comboitem) comp; final String uuid = self.getUuid(); final String zcls = self.getZclass(); wh.write("<tr id=\"").write(uuid).write("\" z.type=\"Cmit\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()).writeln(">") .write("<td class=\"").write(zcls).write("-img\">").write(self.getImgTag()) .write("</td>\n<td class=\"").write(zcls).write("-text\">"); Out o = new Out(self.getLabel()); o.setPre(true); o.render(out); String s = self.getDescription(); if (!Strings.isBlank(s)) { wh.write("<br/>\n<span class=\"").write(zcls).write("-inner\">"); new Out(s).render(out); wh.write("</span>"); } s = self.getContent(); if (!Strings.isBlank(s)) wh.write("<span class=\"").write(zcls).write("-cnt\">").write(s).write("</span>"); //1. don't use Out to encode since content might contain HTML tags //2. Feature 1908524: no <br/> wh.writeln("</td></tr>"); } }
Comboitem cboitem = cboServiceCategory.getSelectedItem(); Date date = datEncounter.getDate(); CodeableConceptDt sc = EncounterUtil.createServiceCategory((String) cboitem.getValue(), cboitem.getLabel(), cboitem.getTooltiptext()); encounter = EncounterUtil.create(date, location, sc);
private static void addModifier(Combobox cbo, String modifier) { Comboitem item = cbo.appendItem(StrUtil.piece(modifier, StrUtil.U)); item.setValue(Integer.parseInt(StrUtil.piece(modifier, StrUtil.U, 3))); }
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); schedSyncValueToSelection(); if (_model != null) { initDataListener(); // Map#Entry cannot be serialized, we have to restore them if (_model instanceof ListModelMap) { for (final Comboitem item : getItems()) { item.setValue(getElementAt(item.getIndex())); } } } }
/** * Wire variables and events. */ @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); for (CodeableConceptDt cat : EncounterUtil.getServiceCategories()) { CodingDt coding = cat.getCodingFirstRep(); Comboitem item = cboServiceCategory.appendItem(coding.getDisplay()); item.setValue(coding.getCode()); item.setTooltiptext(cat.getText()); } List<String> data = broker.callRPCList("RGCWENCX CLINLOC", null, "", 1, 9999); for (String itm : data) { String[] pcs = StrUtil.split(itm, StrUtil.U, 3); Listitem item = lstLocation.appendItem(pcs[1], pcs[0]); item.setAttribute("sc", pcs[2]); } }
/** * Render the combo item for the specified document. * * @param item Combo item to render. * @param doc The document associated with the list item. */ @Override public void renderItem(final Comboitem item, final Document doc) { item.setLabel(doc.getTitle()); } }
/** Deselects the currently selected items and selects the given item. * <p>Note: if the label of comboitem has the same more than one, the first * comboitem will be selected at client side, it is a limitation of {@link Combobox} * and it is different from {@link Listbox}.</p> * @since 3.0.2 */ public void setSelectedItem(Comboitem item) { if (item != null && item.getParent() != this) throw new UiException("Not a child: " + item); if (item != _selItem) { _selItem = item; if (item != null) { setValue(item.getLabel()); smartUpdate("selectedItemUuid_", item.getUuid()); } else { //Bug#2919037: don't call setRawValue(), or the error message will be cleared if (_value != null && !"".equals(_value)) { _value = ""; smartUpdate("value", coerceToString(_value)); } } _lastCkVal = getValue(); } }
@SuppressWarnings("unchecked") private void render(Comboitem item, Object value, int index) throws Throwable { if (!_rendered && (_renderer instanceof RendererCtrl)) { ((RendererCtrl) _renderer).doTry(); _ctrled = true; } try { try { _renderer.render(item, value, index); } catch (AbstractMethodError ex) { final Method m = _renderer.getClass().getMethod("render", new Class<?>[] { Comboitem.class, Object.class }); m.setAccessible(true); m.invoke(_renderer, new Object[] { item, value }); } Object v = item.getAttribute(Attributes.MODEL_RENDERAS); if (v != null) //a new item is created to replace the existent one item = (Comboitem) v; } catch (Throwable ex) { try { item.setLabel(Exceptions.getMessage(ex)); } catch (Throwable t) { log.error("", t); } throw ex; } if (getSelectableModel().isSelected(value)) setSelectedItem(item); _rendered = true; }
/** Returns the index of this Comboitem. * @since 6.0.0 */ public int getIndex() { final Combobox cb = (Combobox) getParent(); if (cb != null) cb.syncItemIndices(); return _index; }
public void setLabel(String label) { final String old = getLabel(); if (!Objects.equals(old, label)) { final Combobox cb = (Combobox) getParent(); final boolean syncValueToSelection = cb != null && cb.getSelectedItemDirectly() == this; super.setLabel(label); if (syncValueToSelection) { final Constraint constr = cb.getConstraint(); if (constr != null && constr instanceof SimpleConstraint && (((SimpleConstraint) constr).getFlags() & SimpleConstraint.STRICT) != 0) { cb.setValue(label); } else { cb.schedSyncValueToSelection(); } } } }
public Comboitem newComboitem(Combobox combobox) { //clone from template final Comboitem clone = (Comboitem) _template.clone(); //TODO: see if databinder has this kind of Comboitem, if not, add new CollectionListItem //avoid duplicate id error, will set to new id when render() //Bug #1962153: Data binding generates duplicate id in some case add "_". if (clone.getId().length() > 0) { clone.setId(null); } //link cloned component with template //each Comboitem and and it descendants share the same templatemap Map<Object, Object> templatemap = new HashMap<Object, Object>(8); BindingRendererUtil.linkTemplates(clone, _template, templatemap, _binder); //link this template map to parent templatemap (Combobox in Combobox) Map parenttemplatemap = (Map) combobox.getAttribute(DataBinder.TEMPLATEMAP); if (parenttemplatemap != null) { templatemap.put(DataBinder.TEMPLATEMAP, parenttemplatemap); } //kept clone kids somewhere to avoid create too many components in browser final List<Component> kids = new ArrayList<Component>(clone.getChildren()); clone.setAttribute(KIDS, kids); clone.getChildren().clear(); return clone; } }