public ImageResource getImageResource() {
   if (type == null) {
     return COCerResources.IMAGES.page_white();
   }
   if (type.getIconRefId() == null) {
     return COCerResources.IMAGES.page_white();
   }
   String iconRefID = type.getIconRefId();
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FLAG_BLUE)) {
     return COCerResources.IMAGES.flag_blue();
   }
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FLAG_GREEN)) {
     return COCerResources.IMAGES.flag_green();
   }
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FLAG_GREY)) {
     return COCerResources.IMAGES.flag_grey();
   }
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FLAG_ORANGE)) {
     return COCerResources.IMAGES.flag_orange();
   }
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FLAG_RED)) {
     return COCerResources.IMAGES.flag_red();
   }
   if (iconRefID.equals(CurriculumNodeTypeIconRefID.FORM_BLANK_YELLOW)) {
     return COCerResources.IMAGES.form_blank_yellow();
   }
   return COCerResources.IMAGES.page_white();
 }
  /**
   * Class constructor
   *
   * @param binder
   */
  @Inject
  public CurriculumNodeTreeView(final Binder binder) {

    // tree comes pre sorted from server
    tree =
        new Tree<CurriculumNodeProxy, String>(
            store,
            new ValueProvider<CurriculumNodeProxy, String>() {
              @Override
              public String getValue(CurriculumNodeProxy object) {
                return object.getName();
              }

              @Override
              public void setValue(CurriculumNodeProxy object, String value) {}

              @Override
              public String getPath() {
                return "name";
              }
            });
    tree.setIconProvider(
        new IconProvider<CurriculumNodeProxy>() {
          @Override
          public ImageResource getIcon(CurriculumNodeProxy model) {
            CurriculumNodeTypeIcon icon = new CurriculumNodeTypeIcon(model.getType());
            return icon.getImageResource();
          }
        });

    // checkbox tree configuration
    tree.setCheckable(true);
    tree.setCheckNodes(CheckNodes.BOTH);
    tree.setCheckStyle(CheckCascade.NONE);
    tree.setAutoLoad(true);

    // expanding context menu in tree, events should be handled in presenter
    // (UI-Handler Class)
    Menu contextMenu = new Menu();
    MenuItem expandAll = new MenuItem(COCerResources.TEXT.expandAll());
    expandAll.setIcon(COCerResources.IMAGES.arrow_out());
    expandAll.addSelectionHandler(
        new SelectionHandler<Item>() {
          @Override
          public void onSelection(SelectionEvent<Item> event) {
            if (tree.getSelectionModel().getSelectedItem().equals(store.getRootItems().get(0))) {
              tree.expandAll();
            } else {
              for (CurriculumNodeProxy node : tree.getSelectionModel().getSelectedItems()) {
                tree.setExpanded(node, true, true);
              }
            }
          }
        });
    contextMenu.add(expandAll);
    MenuItem collapseAll = new MenuItem(COCerResources.TEXT.collapseAll());
    collapseAll.setIcon(COCerResources.IMAGES.arrow_in());
    collapseAll.addSelectionHandler(
        new SelectionHandler<Item>() {
          @Override
          public void onSelection(SelectionEvent<Item> event) {
            if (tree.getSelectionModel().getSelectedItem().equals(store.getRootItems().get(0))) {
              tree.collapseAll();
            } else {
              for (CurriculumNodeProxy node : tree.getSelectionModel().getSelectedItems()) {
                tree.setExpanded(node, false, true);
              }
            }
          }
        });
    contextMenu.add(collapseAll);
    tree.setContextMenu(contextMenu);

    widget = binder.createAndBindUi(this);

    panel.add(tree);
  }