예제 #1
0
파일: TopBar.java 프로젝트: nublic/Nublic
 private void addToTab(
     String id,
     String image,
     String text,
     String link,
     HashMap<String, Element> map,
     HashMap<String, String> mapTexts,
     ArrayList<String> texts,
     Element nav) {
   // Find position
   texts.add(text);
   Collections.sort(texts);
   int index = texts.indexOf(text);
   // Create element
   Element e = createElement(image, text, link);
   // Insert element
   if (index >= nav.getChildCount()) {
     nav.appendChild(e);
   } else {
     Node after = nav.getChild(index);
     nav.insertBefore(e, after);
   }
   // Add to map
   mapTexts.put(id, text);
   map.put(id, e);
 }
예제 #2
0
  public void moveTab(int index, int delta) {
    // do no work if we haven't been asked to move anywhere
    if (delta == 0) return;

    Element tabHost = getTabBarElement();

    // ignore moving left if the tab is already the leftmost tab (same for
    // right)
    int dest = index + delta;
    if (dest < 0 || dest >= tabHost.getChildCount()) return;

    // rearrange the DOM
    Element tab = Element.as(tabHost.getChild(index));
    Element prev = Element.as(tabHost.getChild(dest));
    tabHost.removeChild(tab);
    if (delta > 0) tabHost.insertAfter(tab, prev);
    else tabHost.insertBefore(tab, prev);

    // fire the tab reorder event (this syncs the editor state)
    TabReorderEvent event = new TabReorderEvent(index, dest);
    fireEvent(event);
  }