Example usage for com.vaadin.ui Tree Tree

List of usage examples for com.vaadin.ui Tree Tree

Introduction

In this page you can find the example usage for com.vaadin.ui Tree Tree.

Prototype

public Tree(HierarchicalDataProvider<T, ?> dataProvider) 

Source Link

Document

Constructs a new Tree Component with given HierarchicalDataProvider .

Usage

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component getSettingTab() {
    VerticalLayout sl = new VerticalLayout();
    HorizontalSplitPanel split1 = new HorizontalSplitPanel();
    sl.addComponent(split1);/*from w  ww . j a v a  2  s .c o  m*/
    Tree sTree = new Tree(TRANSLATOR.translate("general.settings"));
    split1.setFirstComponent(sTree);
    sTree.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (sTree.getValue() instanceof VmSetting) {
            split1.setSecondComponent(displaySetting((VmSetting) sTree.getValue()));
        }
    });
    VMSettingServer.getSettings().forEach(s -> {
        if (!s.getSetting().startsWith("mail")) {
            sTree.addItem(s);
            sTree.setChildrenAllowed(s, false);
            sTree.setItemCaption(s, TRANSLATOR.translate(s.getSetting()));
        }
    });
    return sl;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.RiskManagementComponent.java

License:Apache License

public RiskManagementComponent(Project p) {
    setSplitPosition(25, Unit.PERCENTAGE);
    setLocked(true);//from  w  ww  .ja  v a  2  s  .c o m
    Tree tree = new Tree("Test");
    tree.setSizeFull();
    tree.addItem(p);
    tree.setItemCaption(p, p.getName());
    p.getFmeaList().forEach(fmea -> {
        tree.addItem(fmea);
        tree.setItemCaption(fmea, fmea.getName());
        tree.setParent(fmea, p);
    });
    TreeTable ttable = new TreeTable("FMEA");
    ttable.addContainerProperty("Name", String.class, null);
    ttable.addContainerProperty("Hazard", String.class, null);
    ttable.addContainerProperty("Failure Mode", String.class, null);
    ttable.addContainerProperty("Cause", String.class, null);
    ttable.setSizeFull();
    tree.addItemClickListener(event -> {
        if (event.getItem() != null) {
            Item clicked = event.getItem();
            tree.select(event.getItemId());
        }
        if (tree.getValue() != null && tree.getValue() instanceof Fmea) {
            Fmea fmea = (Fmea) tree.getValue();
            fmea.getRiskCategoryList().forEach(rc -> {
                ttable.addGeneratedColumn(rc.getName(), (Table source, Object itemId, Object columnId) -> {
                    if (itemId instanceof String) {
                        String id = (String) itemId;
                        if (id.startsWith("hazard")) {
                            //We have one of our entries
                            StringTokenizer st = new StringTokenizer(id.substring(id.indexOf("-") + 1), "-");
                            FailureModeHasCauseHasRiskCategoryJpaController c = new FailureModeHasCauseHasRiskCategoryJpaController(
                                    DataBaseManager.getEntityManagerFactory());
                            FailureModeHasCauseHasRiskCategory fmhchrc = c
                                    .findFailureModeHasCauseHasRiskCategory(
                                            new FailureModeHasCauseHasRiskCategoryPK(
                                                    Integer.parseInt(st.nextToken()),
                                                    Integer.parseInt(st.nextToken()),
                                                    Integer.parseInt(st.nextToken()),
                                                    Integer.parseInt(st.nextToken()),
                                                    Integer.parseInt(st.nextToken()),
                                                    Integer.parseInt(st.nextToken()), rc.getId()));
                            if (fmhchrc != null) {
                                RiskCategory cat = fmhchrc.getRiskCategory();
                                if (cat.getCategoryEquation() != null
                                        && !cat.getCategoryEquation().trim().isEmpty()) {
                                    //Calculate based on equation
                                    Double result = Tool.evaluateEquation(fmhchrc);
                                    //Update record if result changed
                                    LOG.log(Level.FINE, "Result: {0}", result);
                                    if (result != fmhchrc.getCategoryValue()) {
                                        try {
                                            fmhchrc.setCategoryValue(result);
                                            c.edit(fmhchrc);
                                        } catch (Exception ex) {
                                            Exceptions.printStackTrace(ex);
                                            return new Label("Error!");
                                        }
                                    }
                                }
                                //Return result in label.
                                return new Label("" + fmhchrc.getCategoryValue());
                            }
                        }
                    }
                    return new Label();
                });
            });
            ttable.removeAllItems();
            fmea.getRiskItemList().forEach(item -> {
                ttable.addItem(new Object[] { item.getDescription(), null, null, null },
                        item.getRiskItemPK().getId());
                item.getRiskItemHasHazardList().forEach(rihh -> {
                    rihh.getHazardHasFailureModeList().forEach(hhfm -> {
                        hhfm.getFailureModeHasCauseList().forEach(fmhc -> {
                            String hkey = "hazard-" + item.getRiskItemPK().getId() + "-"
                                    + fmea.getFmeaPK().getId() + "-" + fmea.getFmeaPK().getProjectId() + "-"
                                    + rihh.getHazard().getId() + "-" + hhfm.getFailureMode().getId() + "-"
                                    + fmhc.getCause().getId();
                            ttable.addItem(
                                    new Object[] { null, rihh.getHazard().getName(),
                                            hhfm.getFailureMode().getName(), fmhc.getCause().getDescription() },
                                    hkey);
                            ttable.setParent(hkey, item.getRiskItemPK().getId());
                            //No children
                            ttable.setChildrenAllowed(hkey, false);
                        });
                    });
                });
            });
        }
    });
    ContextMenu contextMenu = new ContextMenu(tree, true);
    tree.addItemClickListener((ItemClickEvent event) -> {
        if (event.getButton() == MouseButton.RIGHT) {
            contextMenu.removeItems();
        }
    });
    setFirstComponent(tree);
    setSecondComponent(ttable);
    setSizeFull();
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.UserComponent.java

License:Apache License

private void init() {
    FormLayout layout = new FormLayout();
    setContent(layout);/*  w w w  .j  a v  a  2s.  c  o m*/
    addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    BeanFieldGroup binder = new BeanFieldGroup(user.getClass());
    binder.setItemDataSource(user);
    Field<?> fn = binder.buildAndBind(TRANSLATOR.translate("general.first.name"), "firstName", TextField.class);
    layout.addComponent(fn);
    Field<?> ln = binder.buildAndBind(TRANSLATOR.translate("general.last.name"), "lastName", TextField.class);
    layout.addComponent(ln);
    Field<?> username = binder.buildAndBind(TRANSLATOR.translate("general.username"), "username",
            TextField.class);
    layout.addComponent(username);
    PasswordField pw = (PasswordField) binder.buildAndBind(TRANSLATOR.translate("general.password"), "password",
            PasswordField.class);
    PasswordChangeListener listener = new PasswordChangeListener();
    pw.addTextChangeListener(listener);
    pw.setConverter(new UserPasswordConverter());
    layout.addComponent(pw);
    Field<?> email = binder.buildAndBind(TRANSLATOR.translate("general.email"), "email", TextField.class);
    layout.addComponent(email);
    ComboBox locale = new ComboBox(TRANSLATOR.translate("general.locale"));
    locale.setTextInputAllowed(false);
    ValidationManagerUI.getAvailableLocales().forEach(l -> {
        locale.addItem(l.toString());
    });
    if (user.getLocale() != null) {
        locale.setValue(user.getLocale());
    }
    binder.bind(locale, "locale");
    layout.addComponent(locale);
    //Status
    ComboBox status = new ComboBox(TRANSLATOR.translate("general.status"));
    new UserStatusJpaController(DataBaseManager.getEntityManagerFactory()).findUserStatusEntities()
            .forEach(us -> {
                status.addItem(us);
                status.setItemCaption(us, TRANSLATOR.translate(us.getStatus()));
            });
    binder.bind(status, "userStatusId");
    status.setTextInputAllowed(false);
    layout.addComponent(status);
    List<UserHasRole> userRoles = new ArrayList<>();
    //Project specific roles
    if (!user.getUserHasRoleList().isEmpty()) {
        Tree roles = new Tree(TRANSLATOR.translate("project.specific.role"));
        user.getUserHasRoleList().forEach(uhr -> {
            if (uhr.getProjectId() != null) {
                Project p = uhr.getProjectId();
                if (!roles.containsId(p)) {
                    roles.addItem(p);
                    roles.setItemCaption(p, p.getName());
                    roles.setItemIcon(p, VMUI.PROJECT_ICON);
                }
                roles.addItem(uhr);
                roles.setItemCaption(uhr, TRANSLATOR.translate(uhr.getRole().getRoleName()));
                roles.setChildrenAllowed(uhr, false);
                roles.setItemIcon(uhr, VaadinIcons.USER_CARD);
                roles.setParent(uhr, p);
            }
        });
        if (!roles.getItemIds().isEmpty()) {
            layout.addComponent(roles);
        }
    }
    //Roles
    if (edit && ((VMUI) UI.getCurrent()).checkRight("system.configuration")) {
        Button projectRole = new Button(TRANSLATOR.translate("manage.project.role"));
        projectRole.addClickListener(l -> {
            VMWindow w = new VMWindow(TRANSLATOR.translate("manage.project.role"));
            w.setContent(getProjectRoleManager());
            ((VMUI) UI.getCurrent()).addWindow(w);
        });
        layout.addComponent(projectRole);
        List<Role> list = new RoleJpaController(DataBaseManager.getEntityManagerFactory()).findRoleEntities();
        Collections.sort(list, (Role r1, Role r2) -> TRANSLATOR.translate(r1.getRoleName())
                .compareTo(TRANSLATOR.translate(r2.getRoleName())));
        BeanItemContainer<Role> roleContainer = new BeanItemContainer<>(Role.class, list);
        TwinColSelect roles = new TwinColSelect(TRANSLATOR.translate("general.role"));
        roles.setContainerDataSource(roleContainer);
        roles.setRows(5);
        roles.setLeftColumnCaption(TRANSLATOR.translate("available.roles"));
        roles.setRightColumnCaption(TRANSLATOR.translate("current.roles"));
        roles.setImmediate(true);
        list.forEach(r -> {
            roles.setItemCaption(r, TRANSLATOR.translate(r.getDescription()));
        });
        if (user.getUserHasRoleList() != null) {
            Set<Role> rs = new HashSet<>();
            user.getUserHasRoleList().forEach(uhr -> {
                if (uhr.getProjectId() == null) {
                    rs.add(uhr.getRole());
                }
            });
            roles.setValue(rs);
        }
        roles.addValueChangeListener(event -> {
            Set<Role> selected = (Set<Role>) event.getProperty().getValue();
            selected.forEach(r -> {
                UserHasRole temp = new UserHasRole();
                temp.setRole(r);
                temp.setVmUser(user);
                userRoles.add(temp);
            });
        });
        layout.addComponent(roles);
    } else {
        if (!user.getUserHasRoleList().isEmpty()) {
            Table roles = new Table(TRANSLATOR.translate("general.role"));
            user.getUserHasRoleList().forEach(role -> {
                roles.addItem(role.getRole());
                roles.setItemCaption(role.getRole(), TRANSLATOR.translate(role.getRole().getRoleName()));
                roles.setItemIcon(role.getRole(), VaadinIcons.USER_STAR);
            });
            layout.addComponent(roles);
        }
    }
    Button update = new Button(user.getId() == null ? TRANSLATOR.translate("general.create")
            : TRANSLATOR.translate("general.update"));
    update.addClickListener((Button.ClickEvent event) -> {
        try {
            VMUserServer us;
            String password = (String) pw.getValue();
            if (user.getId() == null) {
                us = new VMUserServer((String) username.getValue(), password, (String) fn.getValue(),
                        (String) ln.getValue(), (String) email.getValue());
            } else {
                us = new VMUserServer(user);
                us.setFirstName((String) fn.getValue());
                us.setLastName((String) ln.getValue());
                us.setEmail((String) email.getValue());
                us.setUsername((String) username.getValue());
            }
            us.setLocale((String) locale.getValue());
            if (user.getUserHasRoleList() == null) {
                user.setUserHasRoleList(new ArrayList<>());
            }
            user.getUserHasRoleList().clear();
            userRoles.forEach(uhr -> {
                UserHasRoleJpaController c = new UserHasRoleJpaController(
                        DataBaseManager.getEntityManagerFactory());
                try {
                    c.create(uhr);
                    user.getUserHasRoleList().add(uhr);
                } catch (Exception ex) {
                    LOG.log(Level.SEVERE, null, ex);
                }
            });
            if (listener.isChanged() && !password.equals(user.getPassword())) {
                //Different password. Prompt for confirmation
                MessageBox mb = MessageBox.create();
                VerticalLayout vl = new VerticalLayout();
                Label l = new Label(TRANSLATOR.translate("password.confirm.pw.message"));
                vl.addComponent(l);
                PasswordField np = new PasswordField(Lookup.getDefault()
                        .lookup(InternationalizationProvider.class).translate("general.password"));
                vl.addComponent(np);
                mb.asModal(true)
                        .withCaption(Lookup.getDefault().lookup(InternationalizationProvider.class)
                                .translate("password.confirm.pw"))
                        .withMessage(vl).withButtonAlignment(Alignment.MIDDLE_CENTER).withOkButton(() -> {
                            try {
                                if (password.equals(MD5.encrypt(np.getValue()))) {
                                    us.setHashPassword(true);
                                    us.setPassword(np.getValue());
                                    us.write2DB();
                                    Notification.show(
                                            TRANSLATOR.translate("audit.user.account.password.change"),
                                            Notification.Type.ASSISTIVE_NOTIFICATION);
                                    ((VMUI) UI.getCurrent()).updateScreen();
                                } else {
                                    Notification.show(TRANSLATOR.translate("password.does.not.match"),
                                            Notification.Type.WARNING_MESSAGE);
                                }
                                mb.close();
                            } catch (VMException ex) {
                                Exceptions.printStackTrace(ex);
                            }
                        }, ButtonOption.focus(), ButtonOption.closeOnClick(false),
                                ButtonOption.icon(VaadinIcons.CHECK))
                        .withCancelButton(ButtonOption.icon(VaadinIcons.CLOSE)).getWindow()
                        .setIcon(ValidationManagerUI.SMALL_APP_ICON);
                mb.open();
            } else {
                us.write2DB();
            }
            ((VMUI) UI.getCurrent()).getUser().update();
            ((VMUI) UI.getCurrent()).setLocale(new Locale(us.getLocale()));
            ((VMUI) UI.getCurrent()).updateScreen();
        } catch (Exception ex) {
            LOG.log(Level.SEVERE, null, ex);
            Notification.show(TRANSLATOR.translate("general.error.record.update"), ex.getLocalizedMessage(),
                    Notification.Type.ERROR_MESSAGE);
        }
    });
    Button cancel = new Button(
            Lookup.getDefault().lookup(InternationalizationProvider.class).translate("general.cancel"));
    cancel.addClickListener((Button.ClickEvent event) -> {
        binder.discard();
        ((VMUI) UI.getCurrent()).updateScreen();
    });
    binder.setReadOnly(!edit);
    binder.setBuffered(true);
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(update);
    hl.addComponent(cancel);
    layout.addComponent(hl);
}

From source file:org.opennms.features.vaadin.app.TopologyWidgetTestApplication.java

License:Open Source License

private Tree createTree() {

    Tree tree = new Tree("Vertices");
    tree.setContainerDataSource(m_graphContainer.getVertexContainer());

    tree.setImmediate(true);/*from  w  w  w . j a v a 2  s . com*/

    for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
        tree.expandItemsRecursively(it.next());
    }
    return tree;
}

From source file:org.opennms.features.vaadin.mibcompiler.MibCompilerPanel.java

License:Open Source License

/**
 * Instantiates a new MIB tree panel.//from   w w w  .ja va  2  s. c  o m
 *
 * @param dataCollectionDao the OpenNMS Data Collection Configuration DAO 
 * @param eventsDao the OpenNMS Events Configuration DAO
 * @param eventsProxy the OpenNMS Events Proxy
 * @param mibParser the MIB parser
 * @param logger the logger
 */
public MibCompilerPanel(final DataCollectionConfigDao dataCollectionDao, final EventConfDao eventsDao,
        final EventProxy eventsProxy, final MibParser mibParser, final Logger logger) {
    super("MIB Compiler");

    if (dataCollectionDao == null)
        throw new RuntimeException("dataCollectionDao cannot be null.");
    if (eventsProxy == null)
        throw new RuntimeException("eventProxy cannot be null.");
    if (eventsDao == null)
        throw new RuntimeException("eventsDao cannot be null.");

    this.eventsDao = eventsDao;
    this.eventsProxy = eventsProxy;
    this.dataCollectionDao = dataCollectionDao;

    logger.info("Reading MIBs from " + MIBS_ROOT_DIR);

    // Make sure MIB directories exist

    if (!MIBS_COMPILED_DIR.exists()) {
        if (!MIBS_COMPILED_DIR.mkdirs()) {
            throw new RuntimeException(
                    "Unable to create directory for compiled MIBs (" + MIBS_COMPILED_DIR + ")");
        }
    }
    if (!MIBS_PENDING_DIR.exists()) {
        if (!MIBS_PENDING_DIR.mkdirs()) {
            throw new RuntimeException(
                    "Unable to create directory for pending MIBs (" + MIBS_PENDING_DIR + ")");
        }
    }

    // Parser Configuration

    this.mibParser = mibParser;
    mibParser.setMibDirectory(MIBS_COMPILED_DIR);

    // Initialize Toolbar

    MibUploadButton upload = new MibUploadButton(MIBS_PENDING_DIR, MIBS_COMPILED_DIR, logger) {
        @Override
        public void uploadHandler(String filename) {
            addTreeItem(filename, PENDING);
        }
    };

    VerticalLayout layout = new VerticalLayout();
    layout.addComponent(upload);

    // Initialize MIB Tree

    mibsTree = new Tree("MIB Tree");
    initMibTree(logger);
    final Label label = new Label(
            "<p>Use the right-click context menu over the MIB tree files, to display the compiler operations.</p>");
    label.setContentMode(ContentMode.HTML);

    layout.addComponent(label);
    layout.addComponent(mibsTree);

    // Panel Setup
    setSizeFull();
    addStyleName("light");
    layout.setComponentAlignment(upload, Alignment.TOP_RIGHT);
    layout.setExpandRatio(mibsTree, 1);

    setContent(layout);
}

From source file:org.ow2.sirocco.cloudmanager.MyUI.java

License:Open Source License

Tree createLeftMenu() {
    final Tree resourceTree = new Tree("Root");
    resourceTree.setStyleName("myTree");
    resourceTree.setImmediate(true);//from  w w  w .j  av  a 2 s .  co  m
    resourceTree.setSizeFull();
    resourceTree.addItem(MyUI.PROVIDERS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.PROVIDERS_MENU_ITEM_ID, new ThemeResource("img/cloud.png"));
    resourceTree.setChildrenAllowed(MyUI.PROVIDERS_MENU_ITEM_ID, false);

    // resourceTree.addItem(MyUI.COMPUTE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.INSTANCES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.INSTANCES_MENU_ITEM_ID, new ThemeResource("img/server.png"));
    resourceTree.setChildrenAllowed(MyUI.INSTANCES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.INSTANCES_MENU_ITEM_ID, MyUI.COMPUTE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.IMAGES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.IMAGES_MENU_ITEM_ID, new ThemeResource("img/image.png"));
    resourceTree.setItemCaption(MyUI.IMAGES_MENU_ITEM_ID, "  Images");
    resourceTree.setChildrenAllowed(MyUI.IMAGES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.IMAGES_MENU_ITEM_ID, MyUI.COMPUTE_MENU_ITEM_ID);

    // resourceTree.addItem(MyUI.STORAGE_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.VOLUMES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.VOLUMES_MENU_ITEM_ID, new ThemeResource("img/disk.png"));
    resourceTree.setItemCaption(MyUI.VOLUMES_MENU_ITEM_ID, "  Volumes");
    resourceTree.setChildrenAllowed(MyUI.VOLUMES_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.VOLUMES_MENU_ITEM_ID, MyUI.STORAGE_MENU_ITEM_ID);

    // resourceTree.addItem(MyUI.NETWORKING_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.NETWORKS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.NETWORKS_MENU_ITEM_ID, new ThemeResource("img/network.png"));
    resourceTree.setChildrenAllowed(MyUI.NETWORKS_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.NETWORKS_MENU_ITEM_ID, MyUI.NETWORKING_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.ADDRESSES_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.ADDRESSES_MENU_ITEM_ID, new ThemeResource("img/ip-icon.png"));
    resourceTree.setChildrenAllowed(MyUI.ADDRESSES_MENU_ITEM_ID, false);

    resourceTree.addItem(MyUI.SECURITY_GROUP_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.SECURITY_GROUP_MENU_ITEM_ID, new ThemeResource("img/secgroup.png"));
    resourceTree.setChildrenAllowed(MyUI.SECURITY_GROUP_MENU_ITEM_ID, false);

    // resourceTree.addItem(MyUI.SECURITY_MENU_ITEM_ID);

    resourceTree.addItem(MyUI.KEYPAIRS_MENU_ITEM_ID);
    resourceTree.setItemIcon(MyUI.KEYPAIRS_MENU_ITEM_ID, new ThemeResource("img/key.png"));
    resourceTree.setChildrenAllowed(MyUI.KEYPAIRS_MENU_ITEM_ID, false);
    // resourceTree.setParent(MyUI.KEYPAIRS_MENU_ITEM_ID, MyUI.SECURITY_MENU_ITEM_ID);

    // resourceTree.expandItemsRecursively(MyUI.COMPUTE_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.STORAGE_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.NETWORKING_MENU_ITEM_ID);
    // resourceTree.expandItemsRecursively(MyUI.SECURITY_MENU_ITEM_ID);

    resourceTree.select(MyUI.INSTANCES_MENU_ITEM_ID);

    resourceTree.addValueChangeListener(new ValueChangeListener() {
        Object previous = null;

        @Override
        public void valueChange(final ValueChangeEvent event) {
            if (resourceTree.getValue() != null) {
                if (resourceTree.hasChildren(resourceTree.getValue())) {
                    resourceTree.setValue(this.previous);
                } else {
                    this.previous = resourceTree.getValue();
                    switch ((String) resourceTree.getValue()) {
                    case PROVIDERS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.providerView);
                        break;
                    case INSTANCES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.machineView);
                        break;
                    case IMAGES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.machineImageView);
                        break;
                    case VOLUMES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.volumeView);
                        break;
                    case NETWORKS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.networkView);
                        break;
                    case ADDRESSES_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.addressView);
                        break;
                    case SECURITY_GROUP_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.secGroupView);
                        break;
                    case KEYPAIRS_MENU_ITEM_ID:
                        MyUI.this.inventoryContainer.replaceComponent(
                                MyUI.this.inventoryContainer.getComponent(0), MyUI.this.keyPairView);
                        break;
                    }
                }
            }
        }
    });
    return resourceTree;
}

From source file:org.ripla.web.demo.widgets.views.TreeWidgetsView.java

License:Open Source License

/**
 * @param inCountryContainer/*from   ww  w . jav a2  s. com*/
 */
public TreeWidgetsView(final CountryTree inCountries) {
    super();

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.tree"); //$NON-NLS-1$

    final Tree lTree = new Tree(lMessages.getMessage("widgets.view.tree.title")); //$NON-NLS-1$
    lTree.setContainerDataSource(inCountries);
    lTree.setImmediate(true);
    lTree.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(final ItemClickEvent inEvent) {
            final Object lItem = inEvent.getItemId();
            if (lItem instanceof CountryBean) {
                Popup.displayPopup(lMessages.getMessage("widgets.view.tree.popup"), //$NON-NLS-1$
                        createCountryPopup((CountryBean) lItem), 260, 685);
            } else {
                if (lTree.isExpanded(lItem)) {
                    lTree.collapseItem(lItem);
                } else {
                    lTree.expandItem(lItem);
                }
            }
        }
    });

    lLayout.addComponent(lTree);
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java

License:Mozilla Public License

private Tree buildContainmentTree() {
    final Tree tree = new Tree("");
    tree.setImmediate(true);/*from   w  w  w. j a  va  2s . c  o  m*/
    tree.setSelectable(true);
    tree.setDragMode(TreeDragMode.NODE);
    tree.setItemCaptionPropertyId(TreeContainer.NAME);
    tree.addActionHandler(new TreeActionHandler(application));

    tree.addListener(new ItemClickEvent.ItemClickListener() {
        public void itemClick(final ItemClickEvent event) {
            final TreeNode node = (TreeNode) event.getItemId();
            final DetailsData detailsData = new DetailsData(node.getSet());
            final BeanItem<DetailsData> detailsItem = new BeanItem<DetailsData>(detailsData);
            application.getDetailsForm().setItemDataSource(detailsItem);
            application.getDetailsForm().setVisibleItemProperties(DetailsData.getDisplayOrder());
        }
    });

    tree.setItemStyleGenerator(new Tree.ItemStyleGenerator() {
        public String getStyle(final Object itemId) {
            final TreeNode node = (TreeNode) itemId;
            if (isEditMode && !isInScope(node.getUrr())) {
                return "disabled";
            }
            return null;
        }

        private boolean isInScope(final String uuid) {
            return scopeMap.containsKey(uuid);
        }
    });

    return tree;
}

From source file:rs.pupin.jpo.esta_ld.DSDRepoComponent.java

private void refreshContentFindDSDs(DataSet ds) {
    if (ds == null) {
        getWindow().showNotification("No dataset selected", Window.Notification.TYPE_ERROR_MESSAGE);
        return;/*from  w  w  w .ja  v a 2s. com*/
    }
    Structure struct = ds.getStructure();
    if (struct != null) {
        contentLayout.addComponent(new Label("The dataset already has a DSD!"));
        return;
    }

    dataset = ds.getUri();
    contentLayout.removeAllComponents();
    ;
    dataTree = new Tree("Dataset");
    dataTree.setWidth("500px");
    dataTree.setNullSelectionAllowed(true);
    dataTree.setImmediate(true);
    populateDataTree();
    addDataTreeListenersFind();
    contentLayout.addComponent(dataTree);
    contentLayout.setExpandRatio(dataTree, 0.0f);
    repoTree = new Tree("Matching Structures");
    repoTree.setNullSelectionAllowed(true);
    repoTree.setImmediate(true);
    populateRepoTree();
    VerticalLayout v = new VerticalLayout();
    contentLayout.addComponent(v);
    contentLayout.setExpandRatio(v, 2.0f);
    v.addComponent(repoTree);
    v.setExpandRatio(repoTree, 2.0f);
}

From source file:rs.pupin.jpo.esta_ld.DSDRepoComponent.java

private void refreshContentStoreDSD(DataSet ds) {
    if (ds == null) {
        getWindow().showNotification("No dataset selected", Window.Notification.TYPE_ERROR_MESSAGE);
        return;//  ww  w  .j  av  a2 s.c o m
    }
    Structure struct = ds.getStructure();
    if (struct == null) {
        contentLayout.addComponent(new Label("The dataset doesn't contain a DSD!"));
        return;
    }

    dataset = ds.getUri();
    contentLayout.removeAllComponents();
    ;
    dataTree = new Tree("Dataset");
    dataTree.setWidth("500px");
    dataTree.setNullSelectionAllowed(true);
    dataTree.setImmediate(true);
    populateStoreTree();
    addDataTreeListenersStore();
    contentLayout.addComponent(dataTree);
    contentLayout.setExpandRatio(dataTree, 0.0f);
    repoTree = new Tree("Matching Structures");
    repoTree.setNullSelectionAllowed(true);
    repoTree.setImmediate(true);
}