List of usage examples for com.google.gwt.user.client.ui UIObject getElement
public Element getElement()
From source file:com.qualogy.qafe.gwt.client.component.QTableModel.java
License:Apache License
private void registerResultHandler(UIObject sender, String listenerType, ResultHandler resultHandler) { if ((sender != null) && (resultHandler != null)) { String senderId = DOM.getElementAttribute(sender.getElement(), "id"); ClientApplicationContext.getInstance().addResultHandler(senderId, listenerType, resultHandler); }//w ww . j av a 2s . co m }
From source file:com.qualogy.qafe.gwt.client.component.QTableModel.java
License:Apache License
protected EventListenerGVO lookupEvent(UIObject uiObject, String listenerType) { if (source.getSource() != null) { String uiObjectId = DOM.getElementAttribute(uiObject.getElement(), "id"); if (uiObjectId != null) { int pipeIndex = uiObjectId.indexOf("|"); if (pipeIndex > -1) { uiObjectId = uiObjectId.substring(0, pipeIndex); if (source.getSource().getEvents() != null) { for (EventListenerGVO eventGVO : source.getSource().getEvents()) { if ((eventGVO.getEventListenerType() != null) && eventGVO.getEventListenerType().equals(listenerType) && (eventGVO.getEventComponentId() != null) && eventGVO.getEventComponentId().equals(uiObjectId)) { return eventGVO; }/*w w w. j av a 2 s . c om*/ } } } } } return null; }
From source file:com.qualogy.qafe.gwt.client.component.Tiles.java
License:Apache License
/** * This method assigns index for the elements in the FlexTable. * Assigning index enables tracking events on specific element. * @param UIObject child/*from w w w. j a v a 2 s . c o m*/ */ private void assignIndex(UIObject child, int index) { String tileId = DOM.getElementAttribute((Element) child.getElement(), "id"); String tempTileId = ""; if (tileId != null && tileId.length() > 0) { tempTileId = tileId + QAMLConstants.TOKEN_INDEXING + index + QAMLConstants.TOKEN_INDEXING; DOM.setElementAttribute((Element) child.getElement(), "id", tempTileId); ComponentRepository.getInstance().putComponent(tempTileId, child); } if (child instanceof HasWidgets) { HasWidgets hasWidgets = (HasWidgets) child; Iterator<Widget> itr = hasWidgets.iterator(); while (itr.hasNext()) { Widget widget = itr.next(); if (widget instanceof HasWidgets) { assignIndex(widget, index); } String eleId = DOM.getElementAttribute((Element) widget.getElement(), "id"); String tempStr = ""; if (eleId != null && eleId.length() > 0) { int exist = eleId.indexOf(QAMLConstants.TOKEN_INDEXING); if (exist < 0) { tempStr = QAMLConstants.TOKEN_INDEXING + index + QAMLConstants.TOKEN_INDEXING + eleId; DOM.setElementAttribute((Element) widget.getElement(), "id", tempStr); ComponentRepository.getInstance().remove(eleId); ComponentRepository.getInstance().putComponent(tempStr, widget); } } } } ComponentRepository.getInstance().remove(tileId); }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.events.CallbackHandler.java
License:Apache License
final public static void createCallBack(final UIObject sender, final String listenerType, final EventListenerGVO eventGVO, List<InputVariableGVO> listOfInputVariables, Map<String, Object> internalVariables, Map<String, String> mouseInfo) { if (ClientApplicationContext.getInstance().isClientSideEventEnabled()) { EventHandler.getInstance().handleEvent(sender, listenerType, eventGVO, mouseInfo, internalVariables); ClientApplicationContext.getInstance().log("Sender: " + sender + " - " + listenerType); return;//from w ww . ja va 2s. c o m } if (eventGVO != null) { String senderUUID = DOM.getElementProperty(sender.getElement(), "uuid"); String senderId = DOM.getElementAttribute(sender.getElement(), "id"); if (senderId != null && senderId.length() > 0) { String context = RendererHelper.getComponentContext(sender); String parent = RendererHelper.getParentComponent(sender); String senderName = RendererHelper.getNamedComponentName(sender); ClientApplicationContext.getInstance().setBusy(true); AsyncCallback<?> callback = createCallBack(listenerType); EventDataGVO eventDataObject = new EventDataGVO(); eventDataObject.setUuid(senderUUID); eventDataObject.setEventId(eventGVO.getEventId()); eventDataObject.setListenerType(listenerType); eventDataObject.setSenderName(senderName); eventDataObject.setUserUID(ClientApplicationContext.getInstance().getAppUUID()); eventDataObject.setWindowSession(ClientApplicationContext.getInstance().getWindowSession()); eventDataObject.setInternalVariables(internalVariables); eventDataObject.setParameters(ClientApplicationContext.getInstance().getParameters()); eventDataObject.setSender(senderId); eventDataObject.setOriginalSenderId(senderId); // unmanipulated Mouse Coordinates if (senderId.startsWith(QAMLConstants.TOKEN_INDEXING)) { eventDataObject.setIndex(senderId.substring( senderId.indexOf(QAMLConstants.TOKEN_INDEXING) + QAMLConstants.TOKEN_INDEXING.length(), senderId.lastIndexOf(QAMLConstants.TOKEN_INDEXING))); } if (mouseInfo != null) { eventDataObject.setMouseCoordinates(mouseInfo.get(EventDataI.MOUSE_X), mouseInfo.get(EventDataI.MOUSE_Y)); } // sender id eventDataObject.setParent(parent); if (eventGVO.getSourceId() != null) { eventDataObject.setSourceId(eventGVO.getSourceId()); if (!senderId.startsWith("||") && !senderId.startsWith(QAMLConstants.TOKEN_INDEXING)) { if (senderId.indexOf('|') > 0) { eventDataObject.setSourceIdValue(senderId.substring(0, senderId.indexOf('|'))); } } } if (eventGVO.getSourceName() != null) { eventDataObject.setSourceName(eventGVO.getSourceName()); if (RendererHelper.isNamedComponent(sender)) { eventDataObject.setSourceNameValue(RendererHelper.getNamedComponentName(sender)); } } if (eventGVO.getSourceValue() != null) { eventDataObject.setSourceValue(eventGVO.getSourceValue()); Object o = getValue(sender, sender, true, null); if (o instanceof String) { eventDataObject.setSourceValueValue(o.toString()); } } if (eventGVO.getSourceListenerType() != null) { eventDataObject.setSourceListenerType(eventGVO.getSourceListenerType()); eventDataObject.setSourceListenerTypeValue(listenerType); } if (senderId.startsWith("||")) { // so this is a click from a table{ eventDataObject.setSender(senderId.substring(senderId.lastIndexOf("||") + 2)); } else if (senderId.startsWith(QAMLConstants.TOKEN_INDEXING)) { // so this is a click from a tile or an inner component in datagrid eventDataObject.setSender(senderId.substring(senderId.lastIndexOf(QAMLConstants.TOKEN_INDEXING) + QAMLConstants.TOKEN_INDEXING.length())); } boolean error = false; if (listOfInputVariables != null) { try { for (InputVariableGVO inputVariables : listOfInputVariables) { String value = null; DataContainerGVO dataContainerObject = null; String inputVariableReference = inputVariables.getReference(); if (hasAttribute(inputVariableReference)) { value = getAttributeValue(inputVariableReference, parent, context); } else if (inputVariableReference.contains(".$$")) { dataContainerObject = fetchDatagridRowValues(inputVariableReference, parent, context); } else if (inputVariableReference.contains("[")) { dataContainerObject = fetchDatagridCellValue(inputVariableReference, parent, context); } else { String key = RendererHelper.generateId(inputVariableReference, parent, context); // inputVariables[i][1] ClientApplicationContext.getInstance().log(key); List<UIObject> uiObjects = ComponentRepository.getInstance().getComponent(key); // since the parameter can be a complex object, we need to create a substitute for it. // This can only be used in the name variant though (namedcomponents) if (uiObjects != null) { for (UIObject uiObject : uiObjects) { Object o = getValue(uiObject, sender, false, null); if (o instanceof String) { value = o.toString(); } else if (o instanceof DataContainerGVO) { dataContainerObject = (DataContainerGVO) o; } if (uiObject instanceof HasDataModel) { // Get also the data model behind HasDataModel hasDataModel = (HasDataModel) uiObject; if (hasDataModel.getDataModel() != null) { Object dataModel = hasDataModel.getDataModel(); String newInputVariableReference = inputVariableReference + QAMLConstants.DATAMODEL_POSTFIX; if (eventDataObject.getInternalVariables() == null) { eventDataObject .setInternalVariables(new HashMap<String, Object>()); } eventDataObject.getInternalVariables() .put(newInputVariableReference, dataModel); } } } } else { // so the object could not be found in the ComponentRepository, maybe we try by name to find it. ClientApplicationContext.getInstance() .log("Reference" + inputVariables.getReference()); String[] keysSet = inputVariables.getReference().split("[.]"); if (keysSet != null) { String searchKey = null; if (keysSet.length == 1) {// so only the key searchKey = key; } else { searchKey = RendererHelper.generateId(keysSet[0], parent, context); } if (searchKey != null) { uiObjects = ComponentRepository.getInstance() .getNamedComponent(searchKey); if (uiObjects != null) { for (UIObject uiObject : uiObjects) { // Collect all the data from a list of named components DataContainerGVO dataContainer = createDataContainer( inputVariables.getReference(), uiObject, sender); if (dataContainerObject == null) { dataContainerObject = dataContainer; } else if (dataContainer != null) { if (dataContainer.getKind() == dataContainerObject .getKind()) { switch (dataContainer.getKind()) { case DataContainerGVO.KIND_MAP: { dataContainerObject.getDataMap() .putAll(dataContainer.getDataMap()); } break; } } } // Get value of a data member if (keysSet.length > 1) { if (dataContainerObject.getDataMap() .get(keysSet[1]) != null) { value = dataContainerObject.getDataMap().get(keysSet[1]) .getDataString(); } dataContainerObject = null; } } } else { // Apparently we have to search for the Group now. dataContainerObject = BuiltinHandlerHelper.getGroupedComponentValue( sender, inputVariables.getReference(), key); } } } } } String x = inputVariables.getComponentValue() != null ? inputVariables.getComponentValue() : value; if ((inputVariableReference != null) && inputVariableReference.startsWith("||")) { // so this is a click from a table inputVariableReference = (inputVariables.getReference() .substring(senderId.lastIndexOf("||") + 2)); } eventDataObject.getInputVariables() .add(new InputVariableGVO(inputVariables.getName(), inputVariableReference, inputVariables.getDefaultValue(), x, dataContainerObject)); } } catch (RequiredFieldException e) { ClientApplicationContext.getInstance().log(e.getTitle(), e.getMessage(), true, true, e); error = true; } catch (TypeValidationException e) { ClientApplicationContext.getInstance().log("Validation Error: ", e.getMessage(), true, true, e); error = true; } } if (!error) { service.executeEvent(EnrichEventUtil.enrichEvent(eventDataObject), callback); } } else { ClientApplicationContext.getInstance() .log("Callbackhander: Trying to call event while id is empty !!"); } } else { ClientApplicationContext.getInstance().log("Callbackhander: eventGVO cannot be null !!"); } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addAttributesRequiredByEventHandling(ComponentGVO vo, UIObject ui, String uuid, String parent, String context) { if (vo.getId() != null) { String id = generateId(vo.getId(), parent, context); DOM.setElementAttribute(ui.getElement(), "id", id); }/* w ww . j a v a 2 s. co m*/ if (vo.getFieldName() != null) { setNamedComponentName(ui, vo.getFieldName()); } addUUID(vo, ui, uuid); setParentComponent(ui, parent); setComponentContext(ui, context); }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addWindowID(ComponentGVO vo, UIObject ui, String uuid) { if (vo != null && ui != null && vo.getWindow() != null && vo.getWindow().length() > 0) { DOM.setElementProperty(ui.getElement(), "windowid", vo.getWindow()); }/*from w w w . j a v a2 s. co m*/ }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addUUID(ComponentGVO vo, UIObject ui, String uuid) { if (vo != null && ui != null) { DOM.setElementProperty(ui.getElement(), "uuid", uuid); }//from ww w . j a va2s . c o m }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static String getComponentId(UIObject sender) { if (sender != null) { return DOM.getElementProperty(sender.getElement(), "id"); } else {//from w w w . j a v a2 s . c o m return null; } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static Element getElement(UIObject uiObject) { if (uiObject != null) { if (uiObject instanceof LabeledTextFieldWidget) { UIObject textBox = ((LabeledTextFieldWidget) uiObject).getTextbox(); if (textBox != null) { return ((LabeledTextFieldWidget) uiObject).getTextbox().getElement(); }/*from w ww. j a v a 2s. c o m*/ } else if (uiObject instanceof LabeledPasswordFieldWidget) { return ((LabeledPasswordFieldWidget) uiObject).getDataComponent().getElement(); } return uiObject.getElement(); } return null; }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addStyle(ComponentGVO vo, UIObject ui) { if (vo != null) { String styles = vo.getStyleClass(); if (styles != null && !ui.getStyleName().contains(styles)) { ui.addStyleName(styles);// ww w. ja v a 2 s . c o m } if (ui != null) { setStyleForElement(ui.getElement(), vo.getStyleProperties()); } } }