List of usage examples for com.google.gwt.user.client Element getId
@Override
public String getId()
From source file:ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestUtil.java
License:Apache License
/** * Returns the ID of the specified widget. * /*from w w w. j a v a2s . c om*/ * @return <code>null</code> if there is no ID. */ public static String tryToGetWidgetID(final Widget widgetOrNull) { if (widgetOrNull == null) { return null; } if (widgetOrNull instanceof Component) { return ((Component) widgetOrNull).getId(); } final Element element = widgetOrNull.getElement(); if (element == null) { return null; } return element.getId(); }
From source file:ch.unifr.pai.twice.dragndrop.client.configuration.DragConfiguration.java
License:Apache License
/** * @param dragProxy//from ww w.j a va 2 s. co m */ public void setDragProxy(Element dragProxy) { if (dragProxy.getId() != null && !dragProxy.getId().equals("")) dragProxy.setId(dragProxy.getId() + "PROXY"); this.dragProxy = dragProxy; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** @Returns a list of IDs that get put into the template */ public static Vector<String> inject(String elementName, String token, Widget w, boolean inFront) { boolean incrementIDCounter = false; Vector<String> convertedIDs = new Vector<String>(); Vector<Element> nodeTree = new Vector<Element>(); String elementID;/*from w ww . j a v a 2 s .c o m*/ Element e; int indexOfToken = -1; nodeTree.add(w.getElement()); while (nodeTree.size() > 0) { e = nodeTree.remove(0); for (int x = 0; x < e.getChildCount(); x++) { if (e.getChild(x).getNodeType() == Node.ELEMENT_NODE) nodeTree.add((Element) e.getChild(x)); } elementID = e.getId(); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { incrementIDCounter = true; e.setId(elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); convertedIDs.add(e.getId()); } else if (e.getId() != "") convertedIDs.add(e.getId()); // Also update the "for" attribute so that checkbox and radio button labels will behave correctly elementID = e.getAttribute("for"); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { e.setAttribute("for", elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); } } if (incrementIDCounter) iDCounter++; RootPanel.get(elementName).remove(w); if (inFront) RootPanel.get(elementName).insert(w, 0); else RootPanel.get(elementName).add(w); return convertedIDs; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** @Returns a list of IDs that get put into the template */ public static Vector<String> inject(Element element, String token, Widget w, boolean inFront) { boolean incrementIDCounter = false; Vector<String> convertedIDs = new Vector<String>(); Vector<Element> nodeTree = new Vector<Element>(); String elementID;//from w w w. jav a 2 s . com Element e; int indexOfToken = -1; nodeTree.add(w.getElement()); while (nodeTree.size() > 0) { e = nodeTree.remove(0); for (int x = 0; x < e.getChildCount(); x++) { if (e.getChild(x).getNodeType() == Node.ELEMENT_NODE) nodeTree.add((Element) e.getChild(x)); } elementID = e.getId(); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { incrementIDCounter = true; e.setId(elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); convertedIDs.add(e.getId()); } else if (e.getId() != "") convertedIDs.add(e.getId()); } if (incrementIDCounter) iDCounter++; if (DOM.isOrHasChild(element, w.getElement())) DOM.removeChild(element, w.getElement()); if (inFront) DOM.insertChild(element, w.getElement(), 0); else DOM.appendChild(element, w.getElement()); return convertedIDs; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
/** @Returns a list of IDs that get put into the template */ public static Vector<String> inject(String elementName, String token, com.google.gwt.dom.client.Element w, boolean inFront) { boolean incrementIDCounter = false; Vector<String> convertedIDs = new Vector<String>(); Vector<com.google.gwt.dom.client.Element> nodeTree = new Vector<com.google.gwt.dom.client.Element>(); String elementID;/*from w ww .j av a 2s . c o m*/ Element element = DOM.getElementById(elementName); com.google.gwt.dom.client.Element e; int indexOfToken = -1; nodeTree.add(w); while (nodeTree.size() > 0) { e = nodeTree.remove(0); for (int x = 0; x < e.getChildCount(); x++) { if (e.getChild(x).getNodeType() == Node.ELEMENT_NODE) nodeTree.add((Element) e.getChild(x)); } elementID = e.getId(); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { incrementIDCounter = true; e.setId(elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); convertedIDs.add(e.getId()); } else if (e.getId() != "") convertedIDs.add(e.getId()); } if (incrementIDCounter) iDCounter++; if (element.isOrHasChild(w)) element.removeChild(w); if (inFront) element.insertFirst(w); else element.appendChild(w); return convertedIDs; }
From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java
License:Apache License
public static Vector<String> merge(String elementName, String token, Element incomingE) { boolean incrementIDCounter = false; Vector<String> convertedIDs = new Vector<String>(); Vector<Element> nodeTree = new Vector<Element>(); String elementID;// w w w . jav a 2 s. c o m Element e; int indexOfToken = -1; nodeTree.add(incomingE); while (nodeTree.size() > 0) { e = nodeTree.remove(0); for (int x = 0; x < e.getChildCount(); x++) { if (e.getChild(x).getNodeType() == Node.ELEMENT_NODE) nodeTree.add((Element) e.getChild(x)); } elementID = e.getId(); if (elementID != null) indexOfToken = elementID.indexOf(token); if (indexOfToken != -1) { incrementIDCounter = true; e.setId(elementID.substring(0, indexOfToken) + iDCounter + elementID.substring(indexOfToken + token.length())); convertedIDs.add(e.getId()); } else if (e.getId() != "") convertedIDs.add(e.getId()); } if (incrementIDCounter) iDCounter++; RootPanel.get(elementName).getElement().appendChild(incomingE); return convertedIDs; }
From source file:com.eduworks.russel.ds.client.handler.ESBSearchHandler.java
License:Apache License
/** * buildTile0 Initiates a tile in the Alfresco results panel. * @param searchTermPacket ESBPacket Alfresco search results * @param index int Index in the search results for the tile to be created * @param objPanel String Name of target panel for the tile * @param td Element Container for the tile *//*from w w w . j av a2 s .co m*/ protected void buildTile0(Record r, int index, int screenPosition, String objPanel, Element td) { FileRecord fr = (FileRecord) r; Vector<String> iDs = null; if ((td != null) && (searchType.equals(RECENT_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getObjectPanelWidget().getText()), false); else if (searchType.equals(COLLECTION_TYPE) || searchType.equals(FLR_TYPE) || searchType.equals(SEARCH_TYPE)) iDs = PageAssembler.inject(objPanel, "x", new HTML(templates.getSearchPanelWidget().getText()), false); else if (searchType.equals(PROJECT_TYPE)) iDs = PageAssembler.inject(objPanel, "x", new HTML(templates.getEPSSProjectObjectPanelWidget().getText()), false); else if ((td != null) && (searchType.equals(ASSET_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false); else if ((td != null) && (searchType.equals(NOTES_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSNoteAssetObjectWidget().getText()), false); else if ((td != null) && (searchType.equals(STRATEGY_TYPE))) { Window.alert("handling a strategy search"); iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false); } String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-")); tileHandlers.add(new TileHandler(this, idPrefix, searchType, fr)); }
From source file:com.eduworks.russel.ds.client.handler.ESBSearchHandler.java
License:Apache License
/** * hook Launches appropriate Alfresco query and assigns handlers for the response * @param seachbarID String Name of the search bar that informs the Alfresco query * @param objectPanel String Name of the target panel for Alfresco results * @param type String Name of the type of Alfresco search *///from w w w.j a v a2s. c o m public void hook(final String seachbarID, final String objectPanel, final String type) { searchType = type; customQuery = null; pendingEdits = new Vector<FileRecord>(); t = new Timer() { @Override public void run() { String rawSearchText = ((TextBox) PageAssembler.elementToWidget(seachbarID, PageAssembler.TEXT)) .getText().trim(); final ESBPacket ap = new ESBPacket(); final String searchText = cleanQuery(rawSearchText); if (customQuery != null && !searchType.equals(ASSET_TYPE)) ap.put("sq", customQuery + " "); else if (searchType.equals(ASSET_TYPE)) ap.put("sq", EPSSEditScreen.buildQueryString() + " "); else if (searchText == "") ap.put("sq", ""); else ap.put("sq", searchText + " "); ap.put("rows", "100"); ap.put("sort", ""); ap.put("pages", "0"); if (searchType.equals(PROJECT_TYPE)) { ap.put("sort", "cm:modified|false"); if (searchText == "") ap.put("sq", "cm:name:rpf "); else ap.put("sq", searchText + " cm:name:rpf "); } if (searchType.equals(SEARCH_TYPE)) { if (searchText == "") ap.put("sq", "" + util.buildSearchQueryString()); else ap.put("sq", searchText + " " + util.buildSearchQueryString()); ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(COLLECTION_TYPE)) { if (searchText == "") ap.put("sq", "creator:" + ESBApi.username + " " + util.buildSearchQueryString()); else ap.put("sq", searchText + " creator:" + ESBApi.username + " " + util.buildSearchQueryString()); ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(FLR_TYPE)) { if (searchText == "") ap.put("sq", "cm:name:rlr " + util.buildSearchQueryString()); else ap.put("sq", searchText + " cm:name:rlr " + util.buildSearchQueryString()); ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(STRATEGY_TYPE)) { if (searchText == "") ap.put("sq", "" + util.buildSearchQueryString()); else ap.put("sq", searchText + " " + util.buildSearchQueryString()); ap.put("sort", util.buildSearchSortString()); } if (searchText == "" && searchType.equals(RECENT_TYPE)) { Date currentDate = new Date(); Date pastDate = new Date(); pastDate.setDate(pastDate.getDate() - 10); String currentMonthPadded = ((currentDate.getMonth() + 1) < 10) ? "0" + (currentDate.getMonth() + 1) : "" + (currentDate.getMonth() + 1); String currentDayPadded = ((currentDate.getDate()) < 10) ? "0" + (currentDate.getDate()) : "" + (currentDate.getDate()); String pastMonthPadded = ((pastDate.getMonth() + 1) < 10) ? "0" + (pastDate.getMonth() + 1) : "" + (pastDate.getMonth() + 1); String pastDayPadded = ((pastDate.getDate()) < 10) ? "0" + (pastDate.getDate()) : "" + (pastDate.getDate()); ap.put("sq", "modified:[\"" + pastDate.getYear() + "-" + pastMonthPadded + "-" + pastDayPadded + "\" to \"" + currentDate.getYear() + "-" + currentMonthPadded + "-" + currentDayPadded + "\"] "); ap.put("sort", "cm:modified|false"); } ESBApi.search(ap, new ESBCallback<ESBPacket>() { public void onFailure(Throwable caught) { if (retries > 1) { retries = 0; tileHandlers.clear(); RootPanel rp = RootPanel.get(objectPanel); rp.clear(); int childCount = rp.getElement().getChildCount(); int grabIndex = 0; for (int childIndex = 0; childIndex < childCount - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) { Element removeCursor = null; while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null) && removeCursor.getId().equals("r-newEntity")) grabIndex++; if (removeCursor != null) rp.getElement().removeChild(removeCursor); } //StatusWindowHandler.createMessage(StatusWindowHandler.getSearchMessageError(searchText), StatusRecord.ALERT_ERROR); } else { // t.schedule(500); retries++; } pendingSearch = false; customQuery = null; } public void onSuccess(final ESBPacket SearchTermPacket) { tileHandlers.clear(); RootPanel rp = RootPanel.get(objectPanel); rp.clear(); int childCount = rp.getElement().getChildCount(); int grabIndex = 0; for (int childIndex = 0; childIndex < childCount - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) { Element removeCursor = null; while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null) && removeCursor.getId().equals("r-newEntity")) grabIndex++; if (removeCursor != null) rp.getElement().removeChild(removeCursor); } //TODO Thumbnails buildThumbnails(objectPanel, SearchTermPacket); setWorkflowStates(); pendingSearch = false; customQuery = null; } }); } }; PageAssembler.attachHandler(seachbarID, Event.ONKEYUP, new EventCallback() { @Override public void onEvent(Event event) { if (event.getKeyCode() == KeyCodes.KEY_ENTER && type != ASSET_TYPE && type != PROJECT_TYPE && type != STRATEGY_TYPE && type != SEARCH_TYPE) { if (searchType == RECENT_TYPE) searchType = SEARCH_TYPE; view.loadResultsScreen(searchType); } else if (type != EDIT_TYPE) { if (!pendingSearch) { pendingSearch = true; t.schedule(600); } else { t.cancel(); t.schedule(600); } } } }); PageAssembler.attachHandler("r-objectEditSelected", Event.ONCLICK, new EventCallback() { @Override public void onEvent(Event event) { //TODO FIX THIS //view.loadEditScreen(pendingEdits); } }); if (type != EDIT_TYPE && type != ASSET_TYPE) t.schedule(250); }
From source file:com.eduworks.russel.ui.client.handler.ESBSearchHandler.java
License:Apache License
/** * buildTile0 Initiates a tile in the Alfresco results panel. * @param searchTermPacket ESBPacket Alfresco search results * @param index int Index in the search results for the tile to be created * @param objPanel String Name of target panel for the tile * @param td Element Container for the tile * @return TileHandler/*from www . ja v a 2 s . c o m*/ */ protected TileHandler buildTile0(final RUSSELFileRecord r, int screenPosition, String objPanel, Element td) { Vector<String> iDs = null; if ((td != null) && (searchType.equals(RECENT_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getObjectPanelWidget().getText()), false); else if (searchType.equals(COLLECTION_TYPE) || searchType.equals(SEARCH_TYPE) || searchType.equals(RusselApi.FLR_TYPE)) iDs = PageAssembler.inject(objPanel, "x", new HTML(templates.getSearchPanelWidget().getText()), false); else if (searchType.equals(PROJECT_TYPE)) iDs = PageAssembler.inject(objPanel, "x", new HTML(templates.getEPSSProjectObjectPanelWidget().getText()), false); else if ((td != null) && (searchType.equals(ASSET_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false); else if ((td != null) && (searchType.equals(NOTES_TYPE))) iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSNoteAssetObjectWidget().getText()), false); else if ((td != null) && (searchType.equals(STRATEGY_TYPE))) { Window.alert("handling a strategy search"); iDs = PageAssembler.inject(td.getId(), "x", new HTML(templates.getEPSSAssetObjectPanelWidget().getText()), false); } String idPrefix = iDs.firstElement().substring(0, iDs.firstElement().indexOf("-")); TileHandler th = new TileHandler(this, idPrefix, searchType, r); tileHandlers.add(th); return th; }
From source file:com.eduworks.russel.ui.client.handler.ESBSearchHandler.java
License:Apache License
/** * hook Launches appropriate Alfresco query and assigns handlers for the response * @param seachbarID String Name of the search bar that informs the Alfresco query * @param objectPanel String Name of the target panel for Alfresco results * @param type String Name of the type of Alfresco search *//*from w ww . ja v a2 s .c o m*/ public void hook(final String seachbarID, final String objectPanel, final String type) { searchType = type; customQuery = null; pendingEdits = new Vector<RUSSELFileRecord>(); t = new Timer() { @Override public void run() { String rawSearchText = ((TextBox) PageAssembler.elementToWidget(seachbarID, PageAssembler.TEXT)) .getText().trim(); final ESBPacket ap = new ESBPacket(); final String searchText = cleanQuery(rawSearchText); ESBPacket sortPack = new ESBPacket(); sortPack.put("field", "updatedDate_l"); sortPack.put("order", "desc"); ap.put("sort", sortPack); if (customQuery != null && !searchType.equals(ASSET_TYPE)) ap.put("sq", customQuery); else if (searchType.equals(ASSET_TYPE)) ap.put("sq", EPSSEditScreen.buildQueryString()); else if (searchText == "") ap.put("sq", ""); else ap.put("sq", searchText); ap.put("rows", 100); if (searchType.equals(PROJECT_TYPE)) { if (searchText == "") ap.put("sq", "mimeType_t:russel/project"); else ap.put("sq", searchText + " AND mimeType_t:russel/project"); } if (searchType.equals(SEARCH_TYPE) || searchType.equals(EDIT_TYPE)) { if (searchText == "") ap.put("sq", util.buildSearchQueryString()); else ap.put("sq", searchText + util.buildSearchQueryString()); //TODO fix sorting //ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(COLLECTION_TYPE)) { if (searchText == "") ap.put("sq", "uploadedBy_t:" + RusselApi.username + " " + util.buildSearchQueryString()); else ap.put("sq", searchText + " uploadedBy_t:" + RusselApi.username + util.buildSearchQueryString()); //ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(RusselApi.FLR_TYPE)) { if (searchText == "") ap.put("sq", "*"); else ap.put("sq", searchText); //ap.put("sort", util.buildSearchSortString()); } if (searchType.equals(STRATEGY_TYPE)) { if (searchText == "") ap.put("sq", util.buildSearchQueryString()); else ap.put("sq", searchText + util.buildSearchQueryString()); //ap.put("sort", util.buildSearchSortString()); } if (searchText == "" && searchType.equals(RECENT_TYPE)) { Date currentDate = new Date(); Date pastDate = new Date(); pastDate.setDate(pastDate.getDate() - 10); ap.put("sq", "updatedDate_l:[" + pastDate.getTime() + " TO " + currentDate.getTime() + "]"); } if (lastQuery != ap.getString("sq")) pagingTokens.clear(); lastQuery = ap.getString("sq"); if (pagingTokens.size() != 0 && flipSearchPage) { flipSearchPage = false; if (!searchType.equals(RusselApi.FLR_TYPE)) ap.put("cursor", pagingTokens.get(0)); else ap.put("cursor", pagingTokens.size()); } ap.put("fields", new RUSSELFileRecord().getFieldList()); RusselApi.search(ap, searchType, new ESBCallback<ESBPacket>() { public void onFailure(Throwable caught) { if (retries > 2) { retries = 0; tileHandlers.clear(); RootPanel rp = RootPanel.get(objectPanel); if (rp != null) { rp.clear(); int childCount = rp.getElement().getChildCount(); int grabIndex = 0; for (int childIndex = 0; childIndex < childCount - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) { Element removeCursor = null; while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null) && removeCursor.getId().equals("r-newEntity")) grabIndex++; if (removeCursor != null) rp.getElement().removeChild(removeCursor); } } StatusWindowHandler.createMessage(StatusWindowHandler.getSearchMessageError(searchText), StatusRecord.ALERT_ERROR); } else { t.schedule(500); retries++; } pendingSearch = false; customQuery = null; } public void onSuccess(final ESBPacket searchTermPacket) { tileHandlers.clear(); RootPanel rp = RootPanel.get(objectPanel); if (searchType.equals("solr")) pagingTokens.add(0, searchTermPacket.getObject("obj").getString("cursor")); else pagingTokens.add(0, "p"); if (rp != null) { rp.clear(); int childCount = rp.getElement().getChildCount(); int grabIndex = 0; for (int childIndex = 0; childIndex < childCount - ((searchType.equals(PROJECT_TYPE)) ? 1 : 0); childIndex++) { Element removeCursor = null; while (((removeCursor = (Element) rp.getElement().getChild(grabIndex)) != null) && removeCursor.getId().equals("r-newEntity")) grabIndex++; if (removeCursor != null) rp.getElement().removeChild(removeCursor); } buildThumbnails(objectPanel, searchTermPacket); setWorkflowStates(); } pendingSearch = false; customQuery = null; } }); } }; PageAssembler.attachHandler(seachbarID, Event.ONKEYUP, new EventCallback() { @Override public void onEvent(Event event) { if (event.getKeyCode() == KeyCodes.KEY_ENTER && type != ASSET_TYPE && type != PROJECT_TYPE && type != STRATEGY_TYPE && type != SEARCH_TYPE) { if (searchType == RECENT_TYPE || searchType == EDIT_TYPE) searchType = SEARCH_TYPE; Constants.dispatcher.loadResultsScreen(searchType); } else if (type != EDIT_TYPE) { if (!pendingSearch) { pendingSearch = true; t.schedule(600); } else { t.cancel(); t.schedule(600); } } } }); PageAssembler.attachHandler("r-objectEditSelected", Event.ONCLICK, new EventCallback() { @Override public void onEvent(Event event) { Constants.dispatcher.loadEditScreen(pendingEdits); } }); if (type != EDIT_TYPE && type != ASSET_TYPE) t.schedule(250); }