List of usage examples for com.google.gwt.cell.client ValueUpdater update
void update(C value);
From source file:cc.alcina.framework.gwt.client.cell.EditTextCell.java
License:Apache License
/** * Commit the current value./*from w w w . j a v a2 s. c o m*/ * * @param context * the context of the cell * @param parent * the parent Element * @param viewData * the {@link ViewData} object * @param valueUpdater * the {@link ValueUpdater} */ private void commit(Context context, Element parent, ViewData viewData, ValueUpdater<String> valueUpdater) { String value = updateViewData(parent, viewData, false); clearInput(getInputElement(parent)); setValue(context, parent, viewData.getOriginal()); if (valueUpdater != null) { valueUpdater.update(value); } }
From source file:com.anritsu.mcrepositorymanager.client.utils.DynamicSelectionCell.java
License:Apache License
@Override public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); String type = event.getType(); if ("change".equals(type)) { Object key = context.getKey(); SelectElement select = parent.getFirstChild().cast(); String newValue = options.get(select.getSelectedIndex()); setViewData(key, newValue);// w w w . j a va2s . co m finishEditing(parent, newValue, key, valueUpdater); valueUpdater.update(newValue); } }
From source file:com.anritsu.mcrepositorymanager.client.utils.TextAreaInputCell.java
@Override protected void finishEditing(Element parent, String value, Object key, ValueUpdater<String> valueUpdater) { String newValue = getInputElement(parent).getValue(); // Get the view data. ViewData vd = getViewData(key);/*w ww. j ava 2 s . c om*/ if (vd == null) { vd = new ViewData(value); setViewData(key, vd); } vd.setCurrentValue(newValue); // Fire the value updater if the value has changed. if (valueUpdater != null && !vd.getCurrentValue().equals(vd.getLastValue())) { vd.setLastValue(newValue); valueUpdater.update(newValue); } // Blur the element. super.finishEditing(parent, newValue, key, valueUpdater); }
From source file:com.chinarewards.gwt.license.client.ui.HyperLinkCell.java
@Override protected void onEnterKeyDown(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) { if (valueUpdater != null) { valueUpdater.update(value); }/* w ww . j av a 2s .co m*/ }
From source file:com.colinalworth.xmlview.client.ElementCell.java
License:Apache License
@Override public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, Node value, NativeEvent event, ValueUpdater<Node> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); com.google.gwt.dom.client.Element target = event.getEventTarget().cast(); String eventType = event.getType(); // if the user clicked on the context menu, show it if ("click".equals(eventType) && target.getClassName().equals("actions")) { menu.setPopupPosition(event.getClientX(), event.getClientY()); menu.show(value);/*w ww . jav a 2 s . co m*/ return; } // otherwise, if the user is currently editing, interpret their commands as edit comands if (isEditing(context, parent, value)) { // Ignore events that don't target the input. if (!"INPUT".equals(target.getTagName()) && !target.getTagName().equals("TEXTAREA")) { return; } if ("keyup".equals(eventType)) { updateViewState(context.getKey(), value, target); } else if ("focus".equals(eventType)) { lastKey = context.getKey(); updateViewState(context.getKey(), value, target); } else if ("blur".equals(eventType)) { finishEdit(value, target); valueUpdater.update(value); lastKey = null; } } else {// last, if not context, and not editing, they are trying to edit, so focus if ("click".equals(eventType)) { lastKey = context.getKey(); updateViewState(context.getKey(), value, target); setValue(context, parent, value); getActiveInput(parent).focus(); } } }
From source file:com.colinalworth.xmlview.client.ElementCell.java
License:Apache License
@Override protected void onEnterKeyDown(Cell.Context context, com.google.gwt.dom.client.Element parent, Node value, NativeEvent event, ValueUpdater<Node> valueUpdater) { //if the event is directed at an input, finish editing, otherwise focus on first elt com.google.gwt.dom.client.Element target = event.getEventTarget().cast(); if (target.getTagName().equals("INPUT") || target.getTagName().equals("SELECT") || target.getTagName().equals("TEXTAREA")) { finishEdit(value, target);//from w w w . j a va2 s. com valueUpdater.update(value); // TODO move focus to next field (if attr name, then value, if has children, // then first child, if has next sibling, then it, if parent has sibling, then it, // recursively) } else { this.lastKey = context.getKey(); parent.getFirstChildElement().focus(); } }
From source file:com.colinalworth.xmlview.client.XmlTreeViewModel.java
License:Apache License
/** * Forces a redraw of the element, or its first visible ancestor * /* w w w.j a v a 2 s.c o m*/ * @param node * @param parent */ public void redrawChildren(Node node, Node parent) { ValueUpdater<Node> updater = refreshAccess.get(node); while (updater == null) { updater = refreshAccess.get(parent); parent = parent.getParentNode(); } updater.update(null); }
From source file:com.geocento.webapps.eobroker.customer.client.widgets.MaterialCheckBoxCell.java
License:Apache License
@Override public void onBrowserEvent(Context context, Element parent, Boolean value, NativeEvent event, ValueUpdater<Boolean> valueUpdater) { String type = event.getType(); boolean enterPressed = (BrowserEvents.KEYDOWN.equals(type) && event.getKeyCode() == KeyCodes.KEY_ENTER); if (BrowserEvents.CHANGE.equals(type) || enterPressed) { InputElement input = parent.getFirstChild().getFirstChild().cast(); Boolean isChecked = input.isChecked(); /*//from w w w . ja v a 2 s. co m * Toggle the value if the enter key was pressed and the cell handles selection or doesn't depend on selection. If the cell depends on selection but doesn't handle selection, then ignore * the enter key and let the SelectionEventManager determine which keys will trigger a change. */ if (enterPressed && (handlesSelection() || !dependsOnSelection())) { isChecked = !isChecked; input.setChecked(isChecked); } /* * Save the new value. However, if the cell depends on the selection, then do not save the value because we can get into an inconsistent state. */ if (value != isChecked && !dependsOnSelection()) { setViewData(context.getKey(), isChecked); } else { clearViewData(context.getKey()); } if (valueUpdater != null) { valueUpdater.update(isChecked); } } }
From source file:com.goodow.web.reader.client.TextAreaCell.java
License:Apache License
@Override protected void finishEditing(final Element parent, final String value, final Object key, final ValueUpdater<String> valueUpdater) { String newValue = getInputElement(parent).getValue(); // Get the view data. ViewData vd = getViewData(key);/*from ww w.j a v a 2s .c o m*/ if (vd == null) { vd = new ViewData(value); setViewData(key, vd); } vd.setCurrentValue(newValue); // Fire the value updater if the value has changed. if (valueUpdater != null && !vd.getCurrentValue().equals(vd.getLastValue())) { vd.setLastValue(newValue); valueUpdater.update(newValue); } // Blur the element. super.finishEditing(parent, newValue, key, valueUpdater); }
From source file:com.google.code.tree.client.CustomEditTextCell.java
License:Apache License
/** * Commit the current value.//from w ww. j a va 2 s.co m * * @param context * the context of the cell * @param parent * the parent Element * @param viewData * the {@link ViewData} object * @param valueUpdater * the {@link ValueUpdater} */ private void commit(UpdatableTreeNode node, Context context, Element parent, ViewData viewData, ValueUpdater<UpdatableTreeNode> valueUpdater) { String value = updateViewData(parent, viewData, false); clearInput(getInputElement(parent)); setValue(context, parent, node); if (!node.getLabel().equals(value)) { node.setLabel(value); if (valueUpdater != null) { valueUpdater.update(node); } } }