Package com.tensegrity.wpalo.client.ui.model

Examples of com.tensegrity.wpalo.client.ui.model.TreeNode


      XNode root = new XNode(xuser, XConstants.TYPE_ROOT_NODE);
      root.setName("DummyRoot");
      root.setId("0");
      root.setHasChildren(true);
      Dispatcher.forwardEvent(WPaloEvent.EXPANDED_SERVER_SECTION,
          new TreeNode(null, root));
      break;
    case WPaloEvent.EXPANDED_SERVER_SECTION: //load tree data
      TreeNode node = (TreeNode) event.data;
      if (node != null) {
        treeLoader.load(node);
      }
      break;
    }
View Full Code Here


    binder.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
      public void selectionChanged(SelectionChangedEvent<ModelData> se) {
        if (!navigator.isExpanded()) {
          return;
        }
        TreeNode node = (TreeNode) se.getSelectedItem(); // single selection
        String type = node.getXObject().getType();
        int eventType = -1;
       
        if(type.equals(XDimension.TYPE))
          eventType = WPaloEvent.EDIT_DIMENSION_ITEM;
        else if(type.equals(XServer.TYPE))
View Full Code Here

        return icon;
      }
    });
    binder.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
      public void selectionChanged(SelectionChangedEvent<ModelData> se) {
        TreeNode node = (TreeNode) se.getSelectedItem(); // single selection
        if (node != null && node.getXObject() != null) {
          String type = node.getXObject().getType();
          int eventType = -1;

          if (type.equals(XUser.TYPE))
            eventType = WPaloEvent.EDIT_USER_ITEM;
          else if (type.equals(XGroup.TYPE))
            eventType = WPaloEvent.EDIT_GROUP_ITEM;
          else if (type.equals(XRole.TYPE))
            eventType = WPaloEvent.EDIT_ROLE_ITEM;

          if (eventType > -1) {
            del.setEnabled(true);
            return;
          }
        }
        del.setEnabled(false);
      }
    });
    tree.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() {
      public void handleEvent(BaseEvent be) {     
        TreeNode node = (TreeNode) tree.getSelectedItem().getModel(); // single selection
        if (node != null && node.getXObject() != null) {
          String type = node.getXObject().getType();
          int eventType = -1;

          if (type.equals(XUser.TYPE))
            eventType = WPaloEvent.EDIT_USER_ITEM;
          else if (type.equals(XGroup.TYPE))
View Full Code Here

    del.addSelectionListener(new SelectionListener<ComponentEvent>() {
      public final void componentSelected(ComponentEvent ce) {
      }
      public final void handleEvent(ComponentEvent be) {
        TreeItem item = navTree.getSelectedItem();
        final TreeNode node = (TreeNode) item.getModel();
        if(node == null)
          return;
       
        String confirmMsg = null;
        String impossibleMsg = null;
        XObject xObj = node.getXObject();
        String type = xObj.getType();
        if (type.equals(XUser.TYPE)) {
          XUser user = (XUser) node.getXObject();
          if (user != null && user.getLogin() != null &&
              user.getLogin().equalsIgnoreCase("admin")) {
            impossibleMsg = messages.impossibleToDeleteUser(user.getLogin());
          } else {
            confirmMsg = messages.deleteUser(user.getLogin());
          }
        } else if (type.equals(XGroup.TYPE)) {
          XGroup group = (XGroup) node.getXObject();
          if (group != null && group.getName() != null &&
              group.getName().equalsIgnoreCase("admin")) {
            impossibleMsg = messages.impossibleToDeleteGroup(group.getName());
          } else {
            confirmMsg = messages.deleteGroup(group.getName());
          }
        } else if (type.equals(XRole.TYPE)) {
          XRole role = (XRole) node.getXObject();
          if (role != null && role.getName() != null && (role.getName().equals("ADMIN") ||
            role.getName().equals("EDITOR") ||
            role.getName().equals("VIEWER") ||
            role.getName().equals("OWNER"))) {
            impossibleMsg = messages.impossibleToDeleteRole(role.getName());
View Full Code Here

    rootNode.addChild(users);
    rootNode.addChild(groups);
    rootNode.addChild(roles);
    rootNode.setHasChildren(true);
   
    root = new TreeNode(null, rootNode);
  }
View Full Code Here

    rootNode.setId("AccountNavigatorView#RootNode");
    rootNode.addChild(connections);
    rootNode.addChild(accounts);   
    rootNode.setHasChildren(true);
   
    root = new TreeNode(null, rootNode);
  }
View Full Code Here

                  LoadEvent le = new LoadEvent(null, parentNode);
//                  ((Workbench) Registry.get(Workbench.ID)).hideWaitCursor();
                  tree.loaded(le);
                  return false;
                }
                TreeNode tn = kids.get(index);
                XObject xObj = tn.getXObject();

                String name;
                String image = "";
                if (xObj instanceof XElementNode) {
                  int count = ((XElementNode) xObj)
                      .getChildCount();
                  image = "<img paddingTop=\"2px\" width=\"16\" height=\"14\" src=\"icons/element_";
                  XElementType xElemType =     
                    ((XElementNode) xObj).getElement().getElementType();
                  if (XElementType.CONSOLIDATED.equals(xElemType)) {
                    image += "con2.png\">&nbsp;";
                  } else if (XElementType.NUMERIC.equals(xElemType)) {
                    image += "num2.png\">&nbsp;";
                  } else if (XElementType.STRING.equals(xElemType)) {
                    image += "str2.png\">&nbsp;";
                  } else {
                    image = "";
                  }
                  name = count == 0 ? xObj.getName() : xObj
                      .getName()
                      + " <i><font color=\"gray\">("
                      + count + ")</i></font>";
                } else {
                  name = xObj.getName();
                }

                SelectingFastMSTreeItem item = new SelectingFastMSTreeItem(image + name, tree);
               
                if (tn.hasChildren()) {
                  item.becomeInteriorNode();
                  parents.put(tn, item);
                }
                item.setModel(tn);
                HasFastMSTreeItems parentItem = tree;
                if (tn.getParent() != null) {
                  FastMSTreeItem pItem = parents.get(tn.getParent());
                  if (pItem != null) {
                    parentItem = pItem;
                  }
                }
                parentItem.fastAddItem(item);
View Full Code Here

          }         
        }
      }
      break;
    case WPaloEvent.EXPANDED_ACCOUNT_SECTION: //load tree data
      TreeNode node = (TreeNode) event.data;
      if (node != null) {
        treeLoader.load(node);
      }
     
      break;
    case WPaloEvent.SAVED_ACCOUNT_ITEM:
    case WPaloEvent.SAVED_CONNECTION_ITEM:
      if (treeStore == null) {
        return;
      }
      TreeNode nd = (TreeNode) event.data;
      if (nd != null) {
        if(nd.getParent() != null)
          treeStore.update(nd);
        else  {
          int index = event.type == WPaloEvent.SAVED_ACCOUNT_ITEM ? 1 : 0;
          treeStore.add(root.getChild(index), nd, false);
          root.getChild(index).add(nd);
          //shouldn't the store take care of this???
          if(nd.getParent() == null)
            nd.setParent(root.getChild(index));
        }
      }
      if (event.type == WPaloEvent.SAVED_CONNECTION_ITEM) {
        lastCreatedConnection = (XConnection) nd.getXObject();
        final XUser admin = ((Workbench)Registry.get(Workbench.ID)).getUser()
        final String adminUserId = admin.getId();
        WPaloAdminServiceProvider.getInstance().hasAccount(admin.getSessionId(), lastCreatedConnection, new AsyncCallback<Boolean>(){
          public void onFailure(Throwable arg0) {
          }

          public void onSuccess(Boolean result) {
            if (!result) {
              AdminHelpDialog dia = new AdminHelpDialog(
                constants.adminHintAccountCreation(), adminUserId);
              dia.showDialog();
            }
          }
        });
      }
      break;
    case WPaloEvent.DELETED_ITEM:
      if (event.data instanceof TreeNode) {
        XObject target = ((TreeNode) event.data).getXObject();
        if (target != null && target instanceof XUser) {
          HashSet <String> allIds = new HashSet<String>();
          for (String accountId: ((XUser) target).getAccountIDs()) {
            allIds.add(accountId);
          }
          ArrayList <TreeNode> toBeRemoved = new ArrayList<TreeNode>();
          for (TreeNode nod: treeStore.getAllItems()) {           
            if (nod.getXObject() != null && nod.getXObject() instanceof XAccount) {
              XAccount acc = (XAccount) nod.getXObject();
              if (acc.getId() != null && allIds.contains(acc.getId())) {
                toBeRemoved.add(nod);
              }
            }                   
          }
          for (TreeNode n: toBeRemoved) {
            TreeNode parent = n.getParent();
            treeStore.remove(parent, n);         
          }
          treeStore.update(root);
        } else if (target != null && target instanceof XConnection) {
          ArrayList <TreeNode> toBeRemoved = new ArrayList<TreeNode>();
          for (TreeNode nod: treeStore.getAllItems()) {           
            if (nod.getXObject() != null && nod.getXObject() instanceof XAccount) {
              XAccount acc = (XAccount) nod.getXObject();
              if (acc.getConnection().getId().equals(((XConnection) target).getId())) {
                toBeRemoved.add(nod);
              }
            }                   
          }
          for (TreeNode n: toBeRemoved) {
            TreeNode parent = n.getParent();
            treeStore.remove(parent, n);         
          }
          treeStore.update(root);         
        }
      }
View Full Code Here

        return icon;
      }
    });
    binder.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
      public void selectionChanged(SelectionChangedEvent<ModelData> se) {
        TreeNode node = (TreeNode) se.getSelectedItem();
        if (node != null && node.getXObject() != null) {
          String type = node.getXObject().getType();
          int eventType = -1;
          if (type.equals(XAccount.class.getName()))
            eventType = WPaloEvent.EDIT_ACCOUNT_ITEM;
          else if (type.equals(XConnection.class.getName()))
            eventType = WPaloEvent.EDIT_CONNECTION_ITEM;

          if (eventType > -1) {
            del.setEnabled(true);
            return;
          }
        }
        del.setEnabled(false);               
      }
    });
    tree.addListener(Events.OnDoubleClick, new Listener<BaseEvent>() {
      public void handleEvent(BaseEvent be) {     
        TreeNode node = (TreeNode) tree.getSelectedItem().getModel(); // single selection
        if (node != null && node.getXObject() != null) {
          String type = node.getXObject().getType();
          int eventType = -1;
          if (type.equals(XAccount.class.getName()))
            eventType = WPaloEvent.EDIT_ACCOUNT_ITEM;
          else if (type.equals(XConnection.class.getName()))
            eventType = WPaloEvent.EDIT_CONNECTION_ITEM;
View Full Code Here

    del.addSelectionListener(new SelectionListener<ComponentEvent>() {
      public final void componentSelected(ComponentEvent ce) {
      }
      public final void handleEvent(ComponentEvent be) {
        TreeItem item = navTree.getSelectedItem();
        final TreeNode node = (TreeNode) item.getModel();
        if(node == null)
          return;
       
        String confirmMsg = constants.deleteMessageHeader();
        XObject xObj = node.getXObject();
        String type = xObj.getType();
        if (type.equals(XAccount.class.getName())) {
          XAccount acc = (XAccount) xObj;
          XUser usr = acc.getUser();
          String name;
View Full Code Here

TOP

Related Classes of com.tensegrity.wpalo.client.ui.model.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.