@Override public void prepareToAdoptChildren() { if (!this.hasChildren()) { // BEFORE the item is prepared to adopt children, it's just like: // <li> // <input type="checkbox" class="expander" disabled> <!-- input.expander DISABLED = no child --> // <span class="expander"></span> // <input type="checkbox" class="selection"> // <!-- the widget --> <!-- if it's a text item: <label>Child Node 1</label> --> // <!-- there's NO child items container --> // </li> // // AFTER the item is prepared to adopt children, it's: // <li> // <input type="checkbox" class="expander"> <!-- input.expander ENABLED = has child --> // <span class="expander"></span> // <input type="checkbox" class="selection"> // <!-- the widget --> <!-- if it's a text item: <label>Child Node 1</label> --> // <ul class='childContainer'> <!-- child items container is present --> // ... here will come the child items // </ul> // </li> // // [1] - Create a child items container UL by cloning the BASE_INTERNAL_ELEM UListElement childContainerULElem = DOM.clone(BASE_CHILD_CONTAINER_ELEM,// an UL true) // deep cloning .cast(); // [2] - set the new UL as a child of the item (the LI) LIElement parentLI = this.getElement().cast(); parentLI.appendChild(childContainerULElem); // [3] - Change the <input type="checkbox" class="expander"> status from DISABLED to ENABLED InputElement expanderINPUT = parentLI.getFirstChild().cast(); // from Node to Element expanderINPUT.setDisabled(false); } else { throw new IllegalStateException(); } }
public final void appendList(ArrayList<String> choices, boolean ordered, String additionalStyle) { if (choices == null || choices.size() == 0) { return; } FlowPanel htmlList = new FlowPanel(ordered? OListElement.TAG : UListElement.TAG); if (additionalStyle != null && additionalStyle.length() > 0) { _promptChar.getElement().setAttribute("style", additionalStyle); } for (String choice : choices) { FlowPanel item = new FlowPanel(LIElement.TAG); item.getElement().setInnerText(choice); htmlList.add(item); } appendAndScrollOrFocusAsAppropriate(htmlList); }
public static LIElement findTreeViewItemLIElement(final Element element) { LIElement outLIElement = null; Element currElement = element; while (currElement != null) { if (LIElement.is(currElement)) { Element parentElement = currElement.getParentElement(); if (UListElement.is(parentElement) && CONTAINER_UL_CSS_CLASS_NAME.equals(parentElement.getClassName())) { outLIElement = currElement.cast(); } else { currElement = parentElement.getParentElement(); } } else { currElement = currElement.getParentElement(); } if (outLIElement != null) break; } return outLIElement; }
private void setActive(final AnchorElement element, final UListElement active, final List<UListElement> allElements) { $(element).click(new Function() { @Override public boolean f(Event e) { $("a.inline").removeClass("selected"); $(element).addClass("selected"); for (UListElement otherElement : allElements) { if (otherElement != active) { $(otherElement).hide(); } } $(active).show(); return false; } }); }
@Override public Element createDomImpl(Renderable element) { UListElement e = Document.get().createULElement(); // Be careful if you want to move these into CSS - they might affect rendering // of email notifications in gmail. Find a nicer way to deal with this. e.getStyle().setPadding(0, Unit.PX); e.getStyle().setMargin(0, Unit.PX); e.getStyle().setProperty(LIST_STYLE_POSITION, POSITION_INSIDE); return element.setAutoAppendContainer(e); }
@Override public void allChildrenGone() { UListElement childContainerULElement = _childrenContainerULElement(); assert(childContainerULElement != null && childContainerULElement.getChildCount() == 0); LIElement containerLI = this.getElement().cast(); containerLI.removeChild(childContainerULElement); }
/** * Builds the element structure: * <pre class='brush:html'> * <ul class='treeview'> * <li> * <input type="checkbox" class="expander" disabled> <!-- input.expander DISABLED = no child --> * <span class="expander"></span> * * <!-- The root node widget --> <!-- usually is a the tree caption --> * * <ul class='childContainer'>..</ul> <!-- the child items container --> * </li> * </ul> * </pre> */ private void _initDOM() { // [1] - Create a main UL UListElement mainULEl = DOM.createElement("ul").cast(); mainULEl.addClassName(TreeViewUtils.TREEVIEW_CSS_CLASS_NAME); // [2] - Create a single LI for the tree label and append it to the UL LIElement mainLIEl = DOM.createElement("li").cast(); mainULEl.appendChild(mainLIEl); // [3] - Create an UL to contain the root nodes and append it to the title's LI _rootNodesContainerElement = DOM.createElement("ul").cast(); _rootNodesContainerElement.addClassName(TreeViewUtils.CONTAINER_UL_CSS_CLASS_NAME); mainLIEl.appendChild(_rootNodesContainerElement); // [4] - set the widget DOM element this.setElement(mainULEl); // Capture events this.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS); // = DOM.sinkEvents(this.getElement(),Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS) DOM.sinkEvents(this.getElement(), // main UL Event.FOCUSEVENTS); // Add area role "tree" Roles.getTreeRole() .set(this.getElement()); }
@Override public Element createDomImpl(Renderable element) { UListElement e = Document.get().createULElement(); // Be careful if you want to move these into CSS - they might affect rendering // of email notifications in gmail. Find a nicer way to deal with this. e.getStyle().setPadding(0, Unit.PX); e.getStyle().setMargin(0, Unit.PX); return element.setAutoAppendContainer(e); }
private void loadApp() { // Show login links Element userLinks = Document.get().getElementById(AppStyles.ID_USER_LINKS); UListElement ul = Document.get().createULElement(); LIElement liSignedIn = Document.get().createLIElement(); LIElement liSignOut = Document.get().createLIElement(); User me = App.getAppModel().getMe(); String firstName = me.firstName; String lastName = me.lastName; liSignedIn.setInnerHTML("Signed in as <span class=\"nameText\">" + firstName + " " + lastName + "</span>"); liSignOut.setInnerHTML("<span class=\"listmaker-userEmail\">" + me.emailAddress + "</span>"); liSignOut.setInnerHTML("<a href=\"" + LOGOUT_URL + "\">Sign out</a>"); ul.appendChild(liSignedIn); ul.appendChild(liSignOut); userLinks.appendChild(ul); //gwt-activities-and-places ActivityMapper userActivityMapper = new UserActivityMapper(); ActivityManager userActivityManager = new ActivityManager(userActivityMapper, App.getEventBus()); userActivityManager.setDisplay(userDisplay); ActivityMapper addNoteActivityMapper = new AddNoteActivityMapper(); ActivityManager addNoteActivityManager = new ActivityManager(addNoteActivityMapper, App.getEventBus()); addNoteActivityManager.setDisplay(addNote); ActivityMapper navActivityMapper = new NavActivityMapper(); ActivityManager navActivityManager = new ActivityManager(navActivityMapper, App.getEventBus()); navActivityManager.setDisplay(nav); ActivityMapper mainActivityMapper = new AppActivityMapper(); ActivityManager noteDisplayActivityManager = new ActivityManager(mainActivityMapper, App.getEventBus()); noteDisplayActivityManager.setDisplay(mainDisplay); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(App.getPlaceHistoryMapper()); historyHandler.register(App.getClientFactory().getPlaceController(), App.getEventBus(), defaultPlace); DOM.removeChild(RootPanel.getBodyElement(), DOM.getElementById(AppStyles.ID_SPLASH)); RootPanel.get(AppStyles.BODY_PANEL_USER_ID).add(userDisplay); RootPanel.get(AppStyles.BODY_PANEL_TOP_ID).add(addNote); RootPanel.get(AppStyles.BODY_PANEL_CONTENT_ID).add(mainDisplay); RootPanel.get(AppStyles.BODY_PANEL_NAV_ID).add(nav); historyHandler.handleCurrentHistory(); }
public void setDir(String dir) { // Set an attribute specific to this tag ((UListElement) getElement().cast()).setDir(dir); }
private static UListElement _createBaseChildContainerElement() { UListElement ulElem = DOM.createElement("ul").cast(); ulElem.addClassName(TreeViewUtils.CONTAINER_UL_CSS_CLASS_NAME); return ulElem; }
UListElement _childrenContainerULElement() { UListElement containerLI = this.getElement().cast(); if (containerLI.getChildCount() < 4) return null; UListElement childContainerULElem = containerLI.getChild(4).cast(); return childContainerULElem; }
/** * Creates a single tree node from the given trace node. * @param node */ protected LIElement createTreeNode(TraceNodeBean node) { String nodeId = String.valueOf(nodeIdCounter++); nodeMap.put(nodeId, node); boolean isCall = "Call".equals(node.getType()); //$NON-NLS-1$ boolean hasChildren = !node.getTasks().isEmpty(); LIElement li = Document.get().createLIElement(); li.setClassName(hasChildren ? "parent_li" : "leaf_li"); //$NON-NLS-1$ //$NON-NLS-2$ if (hasChildren) li.setAttribute("role", "treeitem"); //$NON-NLS-1$ //$NON-NLS-2$ SpanElement span = Document.get().createSpanElement(); span.setAttribute("data-nodeid", nodeId); //$NON-NLS-1$ Element icon = Document.get().createElement("i"); //$NON-NLS-1$ span.appendChild(icon); span.appendChild(Document.get().createTextNode(" ")); //$NON-NLS-1$ if (isCall) { span.setClassName(node.getStatus()); icon.setClassName("icon-minus-sign"); //$NON-NLS-1$ span.appendChild(Document.get().createTextNode(node.getOperation())); span.appendChild(Document.get().createTextNode(":")); //$NON-NLS-1$ span.appendChild(Document.get().createTextNode(node.getComponent())); } else { span.appendChild(Document.get().createTextNode(node.getDescription())); span.setClassName("Info"); //$NON-NLS-1$ icon.setClassName("icon-info-sign"); //$NON-NLS-1$ } li.appendChild(span); if (node.getDuration() != -1) { li.appendChild(Document.get().createTextNode(" [")); //$NON-NLS-1$ li.appendChild(Document.get().createTextNode(String.valueOf(node.getDuration()))); li.appendChild(Document.get().createTextNode("ms]")); //$NON-NLS-1$ } if (node.getPercentage() != -1) { li.appendChild(Document.get().createTextNode(" (")); //$NON-NLS-1$ li.appendChild(Document.get().createTextNode(String.valueOf(node.getPercentage()))); li.appendChild(Document.get().createTextNode("%)")); //$NON-NLS-1$ } if (hasChildren) { UListElement ul = Document.get().createULElement(); ul.setAttribute("role", "group"); //$NON-NLS-1$ //$NON-NLS-2$ li.appendChild(ul); List<TraceNodeBean> tasks = node.getTasks(); for (TraceNodeBean task : tasks) { LIElement tn = createTreeNode(task); ul.appendChild(tn); } } return li; }
public Nav() { super(UListElement.TAG); StyleUtils.addStyle(this, Nav.STYLE_NAV); }
public List() { this(UListElement.TAG); }
@UiConstructor public List(String tag) { super(OListElement.TAG.equals(tag) || UListElement.TAG.equals(tag) ? tag : UListElement.TAG); this.setType(this.type); }
public ErrorGroup() { super(UListElement.TAG); this.setColor(this.color); }
DropdownMenu() { super(UListElement.TAG); StyleUtils.addStyle(this, ContentAssistAspect.STYLE_MENU); StyleUtils.addStyle(this, ContentAssistAspect.STYLE_SCROLLABLE); }
/** * Builds the element structure: * <pre class='brush:html'> * <ul class='tags'> * <li><span><img />Tag1</span></li> * <li><span><img />Tag1</span></li> * <li><span><img />Tag1</span></li> * </ul> * </pre> */ private static UListElement _createContainerULElement() { UListElement outULElement = DOM.createElement("ul").cast(); outULElement.addClassName("tags"); return outULElement; }