Java 类com.vaadin.ui.Tree 实例源码

项目:opennmszh    文件:NCSViewContribution.java   
@Override
public Component getView(final WidgetContext widgetContext) {

    Tree tree = new Tree("Services", new FilterableHierarchicalContainer(new NCSServiceContainer(m_ncsComponentRepository)));
    tree.setMultiSelect(true);
    tree.setImmediate(true);
    tree.setItemCaptionMode(Tree.ITEM_CAPTION_MODE_PROPERTY);
    tree.setItemCaptionPropertyId("name");
    tree.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            Collection<Long> selectedIds = (Collection<Long>) event.getProperty().getValue();

            Criteria criteria = NCSEdgeProvider.createCriteria(selectedIds);

            widgetContext.getGraphContainer().setCriteria(criteria);
        }
    });

    return tree;
}
项目:konekti    文件:OrganizationView.java   
private Tree createOrganizationTree(Organization organization) {                
    Tree organizationTree = new Tree(); 
    organizationTree.setImmediate(false);
    organizationTree.setWidth("100.0%");
    organizationTree.setHeight("100.0%");
    organizationTree.setContainerDataSource(createDataSource(organization));
    organizationTree.setItemIconPropertyId("icon");
    organizationTree.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
    organizationTree.setItemCaptionPropertyId("description");

    // Expand all items that can be
       for (Object itemId: organizationTree.getItemIds())
        organizationTree.expandItem(itemId);

       organizationTree.setData(organization);
       organizationTree.addActionHandler(this);

    return organizationTree;
}
项目:konekti    文件:OrganizationView.java   
private Tab getTabByOrganization(Organization organization) {
    @SuppressWarnings("rawtypes")
    Iterator itr = tabSheetOrganization.getComponentIterator();

    while(itr.hasNext()) {
        Component cmp = (Component) itr.next();
        Tree treeSelected = (Tree) cmp;
        Organization organizationSelected = (Organization)treeSelected.getData();

        if (organizationSelected.equals(organization))
            return tabSheetOrganization.getTab(cmp);

    } 

    return null;
}
项目:VaadinUtils    文件:TreeContextMenu.java   
@Override
public void setAsTreeContextMenu(final Tree tree)
{
    this.tree = tree;
    extend(tree);
    setOpenAutomatically(false);

    tree.addContextClickListener(new ContextClickListener()
    {
        private static final long serialVersionUID = 1L;

        @Override
        public void contextClick(ContextClickEvent event)
        {
            if (event.getButton() == MouseButton.RIGHT)
            {
                openContext((TreeContextClickEvent) event);
                open(event.getClientX(), event.getClientY());
            }
        }
    });

}
项目:cuba    文件:WebWidgetsTree.java   
public WebWidgetsTree() {
    component = new CubaWidgetsTree();
    component.setSelectable(false);
    component.setImmediate(true);
    component.setBeforePaintListener(() -> {
        Tree.ItemStyleGenerator generator = component.getItemStyleGenerator();
        if (generator instanceof WebAbstractTree.StyleGeneratorAdapter) {
            //noinspection unchecked
            ((StyleGeneratorAdapter) generator).resetExceptionHandledFlag();
        }
    });

    initComponent(component);
}
项目:incubator-openaz    文件:ExpressionEditorWindow.java   
@AutoGenerated
private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth("-1px");
    mainLayout.setHeight("-1px");
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("-1px");
    setHeight("-1px");

    // comboBox
    comboBox = new ComboBox();
    comboBox.setImmediate(false);
    comboBox.setWidth("-1px");
    comboBox.setHeight("-1px");
    mainLayout.addComponent(comboBox);

    // treeExpression
    treeExpression = new Tree();
    treeExpression.setImmediate(false);
    treeExpression.setWidth("100.0%");
    treeExpression.setHeight("-1px");
    mainLayout.addComponent(treeExpression);
    mainLayout.setExpandRatio(treeExpression, 1.0f);

    return mainLayout;
}
项目:mondo-collab-framework    文件:StartNewSessionPage.java   
private void initView() {
    this.loadingSign = new ProgressBar();
    this.loadingSign.setIndeterminate(true);
    this.loadingSign.setId("loadingSign");
    Label title = new Label("Available models");
    title.setId("label_availableModels");
    addComponent(title);

    this.availableModelsTree = new Tree();
    this.availableModelsTree.setId("tree_availableModels");
    this.availableModelsTree.setWidth(30, Unit.EM);
    Tree tree = availableModelsTree;
       tree.addContainerProperty(CAPTION_PROPERTY, String.class, "");
       tree.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
       tree.setItemCaptionPropertyId(CAPTION_PROPERTY);
    this.buttonStartSession = new Button("Start");
    this.buttonStartSession.setId("button_start");
    this.buttonStartSession.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            String selectedModelPath = (String) tree.getValue();
            if(selectedModelPath.endsWith(".wtspec4m")) {
                startSession(selectedModelPath);
            } 
        }
    });
    addComponent(this.buttonStartSession);
    addComponent(this.loadingSign);

    Panel treeViewContainer = new Panel();
    treeViewContainer.setId("panel_treeViewContainer");
    treeViewContainer.setContent(this.availableModelsTree);
    addComponent(treeViewContainer);
}
项目:XACML    文件:ExpressionEditorWindow.java   
@AutoGenerated
private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth("-1px");
    mainLayout.setHeight("-1px");
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("-1px");
    setHeight("-1px");

    // comboBox
    comboBox = new ComboBox();
    comboBox.setImmediate(false);
    comboBox.setWidth("-1px");
    comboBox.setHeight("-1px");
    mainLayout.addComponent(comboBox);

    // treeExpression
    treeExpression = new Tree();
    treeExpression.setImmediate(false);
    treeExpression.setWidth("100.0%");
    treeExpression.setHeight("-1px");
    mainLayout.addComponent(treeExpression);
    mainLayout.setExpandRatio(treeExpression, 1.0f);

    return mainLayout;
}
项目:opennmszh    文件:TopologyWidgetTestApplication.java   
private Tree createTree() {

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

    tree.setImmediate(true);

    for (Iterator<?> it = tree.rootItemIds().iterator(); it.hasNext();) {
        tree.expandItemsRecursively(it.next());
    }
    return tree;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
@SuppressWarnings("unchecked")
@Override
public default THIS withDataProvider(DataProvider<ITEM, ?> dataProvider) {
    ((Tree<ITEM>) this).setDataProvider(dataProvider);
    return (THIS) this;
}
项目:dungeonstory-java    文件:ClassFeatureList.java   
public ClassFeatureList(Character character) {

    // class features
    FHorizontalLayout classFeatureLayout = new FHorizontalLayout().withFullWidth();
    Panel classFeaturePanel = new Panel("Dons de classe", classFeatureLayout);

    Tree<ClassFeature> classfeatureTree = new Tree<ClassFeature>();
    classfeatureTree.setItems(ClassUtil.getAllRootCharacterClassFeatures(character), ClassFeature::getChildren);
    classFeatureLayout.addComponent(classfeatureTree);

    DSLabel classFeatureDescription = new DSLabel();
    classFeatureLayout.addComponent(classFeatureDescription);
    classfeatureTree.addItemClickListener(event -> {
        if (event.getItem() != null) {
            classFeatureDescription.setValue(event.getItem().getDescription());
        } else {
            classFeatureDescription.setValue("");
        }
    });
    addComponent(classFeaturePanel);

    // feats
    if (!character.getFeats().isEmpty()) {
        FHorizontalLayout featLayout = new FHorizontalLayout().withFullWidth();
        Panel featPanel = new Panel("Dons", featLayout);
        Tree<Feat> featTree = new Tree<Feat>();
        featTree.setItems(character.getFeats());
        featLayout.addComponent(featTree);

        DSLabel featDescription = new DSLabel();
        featLayout.addComponent(featDescription);
        featTree.addItemClickListener(event -> {
            if (event.getItem() != null) {
                featDescription.setValue(event.getItem().getDescription());
            } else {
                featDescription.setValue("");
            }
        });
        addComponent(featPanel);
    }

}
项目:SecureBPMN    文件:AbstractTreePage.java   
@Override
protected AbstractSelect createSelectComponent() {
  Tree tree = createTree();
  tree.setSizeFull();
  return tree;
}
项目:zklogtool    文件:SnapshotView.java   
@AutoGenerated
private VerticalLayout buildVerticalLayout_1() {
    // common part: create layout
    verticalLayout_1 = new VerticalLayout();
    verticalLayout_1.setImmediate(false);
    verticalLayout_1.setWidth("100.0%");
    verticalLayout_1.setHeight("-1px");
    verticalLayout_1.setMargin(true);
    verticalLayout_1.setSpacing(true);

    // label_4
    label_4 = new Label();
    label_4.setImmediate(false);
    label_4.setWidth("-1px");
    label_4.setHeight("-1px");
    label_4.setValue("Data Tree:");
    verticalLayout_1.addComponent(label_4);

    // dataTree
    dataTree = new Tree();
    dataTree.setImmediate(false);
    dataTree.setWidth("-1px");
    dataTree.setHeight("-1px");
    verticalLayout_1.addComponent(dataTree);

    // label_5
    label_5 = new Label();
    label_5.setImmediate(false);
    label_5.setWidth("-1px");
    label_5.setHeight("-1px");
    label_5.setValue("Sessions:");
    verticalLayout_1.addComponent(label_5);

    // sessionTree
    sessionTree = new Tree();
    sessionTree.setImmediate(false);
    sessionTree.setWidth("-1px");
    sessionTree.setHeight("-1px");
    verticalLayout_1.addComponent(sessionTree);

    return verticalLayout_1;
}
项目:FiWare-Template-Handler    文件:AbstractTreePage.java   
@Override
protected AbstractSelect createSelectComponent() {
  Tree tree = createTree();
  tree.setSizeFull();
  return tree;
}
项目:opennmszh    文件:MibCompilerPanel.java   
/**
 * Instantiates a new MIB tree panel.
 *
 * @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) {
        public void uploadHandler(String filename) {
            addTreeItem(filename, PENDING);
        }
    };
    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(Label.CONTENT_XHTML);
    addComponent(label);
    addComponent(mibsTree);

    // Panel Setup

    setSizeFull();
    addStyleName(Runo.PANEL_LIGHT);
    ((VerticalLayout) getContent()).setComponentAlignment(upload, Alignment.TOP_RIGHT);
    ((VerticalLayout) getContent()).setExpandRatio(mibsTree, 1);
}
项目:chipster    文件:TreeToolEditor.java   
private void initTree() {
    this.setSizeFull();
    this.setImmediate(true);
    this.setSelectable(true);
    this.addItemClickListener(this);
    this.addContainerProperty("", String.class, null);
    this.addContainerProperty(ACTIONS, HorizontalLayout.class, null );
    this.addItem(new Object[] {TOOL, getActionLayout(false, false, TOOL)}, TOOL);
    this.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
        private static final long serialVersionUID = -1913286695570843896L;

        @Override
        public String generateDescription(Component source, Object itemId,
                Object propertyId) {
            String description = "Show all ";
            if(itemId.equals(TOOL))
                description += "elements";
            else if (itemId.equals(INPUTS))
                description += "inputs";
            else if (itemId.equals(OUTPUTS))
                description += "outputs";
            else if (itemId.equals(PARAMETERS))
                description += "parameters";
            else
                return null;
            return description;
        }
    });
    this.setCollapsed(TOOL, false);
    String[] rootToolElements = new String[] {INPUTS, OUTPUTS, PARAMETERS};
    for(String element : rootToolElements) {
        this.addItem(new Object[] {element, getActionLayout(true, false, element)}, element);
        this.setParent(element, TOOL);
        this.setCollapsed(element, false);
    }
    this.setDragMode(TableDragMode.ROW);
    this.setDropHandler(new DropHandler() {
        private static final long serialVersionUID = -4415321436294383112L;

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Or(Tree.TargetItemAllowsChildren.get(), new Not(VerticalLocationIs.MIDDLE));
        }

        @Override
        public void drop(DragAndDropEvent event) {
            final Transferable t = event.getTransferable();
            if (t.getSourceComponent() != TreeToolEditor.this
                    || !(t instanceof DataBoundTransferable)) {
                return;
            }

            final AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event.getTargetDetails());

            final Object sourceItemId = ((DataBoundTransferable) t).getItemId();
            final Object targetItemId = dropData.getItemIdOver();
            final VerticalDropLocation location = dropData.getDropLocation();

            moveNode(sourceItemId, targetItemId, location);
        }
    });

}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Adds a CollapseListener to this Tree.
 *
 * @see CollapseEvent
 *
 * @param listener
 *            the listener to add
 * @return this for method chaining
 * @see Tree#addCollapseListener(CollapseEvent.CollapseListener)
 */
@SuppressWarnings("unchecked")
public default THIS withCollapseListener(CollapseListener<ITEM> listener) {
    ((Tree<ITEM>) this).addCollapseListener(listener);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Adds an ExpandListener to this Tree.
 *
 * @see ExpandEvent
 *
 * @param listener
 *            the listener to add
 * @return this for method chaining
 * @see Tree#addExpandListener(ExpandEvent.ExpandListener)
 */
@SuppressWarnings("unchecked")
public default THIS withExpandListener(ExpandListener<ITEM> listener) {
    ((Tree<ITEM>) this).addExpandListener(listener);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Adds an item click listener. The listener is called when an item of this
 * {@code Tree} is clicked.
 *
 * @param listener
 *            the item click listener, not null
 * @return this for method chaining
 * @see Tree#addItemClickListener(ItemClickListener)
 */
@SuppressWarnings("unchecked")
public default THIS withItemClickListener(ItemClickListener<ITEM> listener) {
    ((Tree<ITEM>) this).addItemClickListener(listener);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Adds a selection listener to the current selection model.
 * <p>
 * <strong>NOTE:</strong> If selection mode is switched with
 * {@link Tree#setSelectionMode(Grid.SelectionMode)}, then this listener is not
 * triggered anymore when selection changes!
 *
 * @param listener
 *            the listener to add
 * @return this for method chaining
 * @see Tree#addSelectionListener(SelectionListener)
 *
 * @throws UnsupportedOperationException
 *             if selection has been disabled with
 *             {@link SelectionMode#NONE}
 */
@SuppressWarnings("unchecked")
public default THIS withSelectionListener(SelectionListener<ITEM> listener) throws UnsupportedOperationException {
    ((Tree<ITEM>) this).addSelectionListener(listener);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the automatic width recalculation on or off. This feature is on by
 * default.
 * 
 * @param autoRecalculateWidth
 *            {@code true} to enable recalculation; {@code false} to turn it
 *            off
 * 
 * @return this for method chaining
 * @see Tree#setAutoRecalculateWidth(boolean)
 */
@SuppressWarnings("unchecked")
public default THIS withAutoRecalculateWidth(boolean autoRecalculateWidth) {
    ((Tree<ITEM>) this).setAutoRecalculateWidth(autoRecalculateWidth);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the content mode of the item caption.
 *
 * @param contentMode
 *            the content mode
 *            
 * @return this for method chaining
 * @see Tree#setContentMode(ContentMode)
 */
@SuppressWarnings("unchecked")
public default THIS withContentMode(ContentMode contentMode) {
    ((Tree<ITEM>) this).setContentMode(contentMode);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the item caption generator that is used to produce the strings shown
 * as the text for each item. By default, {@link String#valueOf(Object)} is
 * used.
 *
 * @param captionGenerator
 *            the item caption provider to use, not <code>null</code>
 *            
 * @return this for method chaining
 * @see Tree#setItemCaptionGenerator(ItemCaptionGenerator)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<ITEM> captionGenerator) {
    ((Tree<ITEM>) this).setItemCaptionGenerator(captionGenerator);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the item collapse allowed provider for this Tree. The provider
 * should return {@code true} for any item that the user can collapse.
 * <p>
 * <strong>Note:</strong> This callback will be accessed often when sending
 * data to the client. The callback should not do any costly operations.
 *
 * @param provider
 *            the item collapse allowed provider, not {@code null}
 *            
 * @return this for method chaining
 * @see Tree#setItemCollapseAllowedProvider(ItemCollapseAllowedProvider)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCollapseAllowedProvider(ItemCollapseAllowedProvider<ITEM> provider) {
    ((Tree<ITEM>) this).setItemCollapseAllowedProvider(provider);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the item icon generator that is used to produce custom icons for
 * items. The generator can return <code>null</code> for items with no icon.
 *
 * @see IconGenerator
 *
 * @param iconGenerator
 *            the item icon generator to set, not <code>null</code>
 * @return this for method chaining
 * @see Tree#setItemIconGenerator(IconGenerator)
 * @throws NullPointerException
 *             if {@code itemIconGenerator} is {@code null}
 */
@SuppressWarnings("unchecked")
public default THIS withItemIconGenerator(IconGenerator<ITEM> iconGenerator) {
    ((Tree<ITEM>) this).setItemIconGenerator(iconGenerator);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the height of a row. If -1 (default), the row height is calculated
 * based on the theme for an empty row before the Tree is displayed.
 *
 * @param rowHeight
 *            The height of a row in pixels or -1 for automatic calculation
 * @return this for method chaining
 * @see Tree#setRowHeight(double)
 */
@SuppressWarnings("unchecked")
public default THIS withRowHeight(double rowHeight) {
    ((Tree<ITEM>) this).setRowHeight(rowHeight);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the tree's selection mode.
 * <p>
 * The built-in selection modes are:
 * <ul>
 * <li>{@link SelectionMode#SINGLE} <b>the default model</b></li>
 * <li>{@link SelectionMode#MULTI}</li>
 * <li>{@link SelectionMode#NONE} preventing selection</li>
 * </ul>
 *
 * @param selectionMode
 *            the selection mode to switch to, not {@code null}
 * @return this for method chaining
 * @see Tree#setSelectionMode(Grid.SelectionMode)
 *
 * @see SelectionMode
 */
@SuppressWarnings("unchecked")
public default THIS withSelectionMode(SelectionMode selectionMode) {
    ((Tree<ITEM>) this).setSelectionMode(selectionMode);
    return (THIS) this;
}
项目:vaadin-fluent-api    文件:FluentTree.java   
/**
 * Sets the style generator that is used for generating class names for
 * items in this tree. Returning null from the generator results in no
 * custom style name being set.
 *
 * @see StyleGenerator
 *
 * @param styleGenerator
 *            the item style generator to set, not {@code null}
 * @return this for method chaining
 * @see Tree#setStyleGenerator(StyleGenerator)
 * @throws NullPointerException
 *             if {@code styleGenerator} is {@code null}
 */
@SuppressWarnings("unchecked")
public default THIS withStyleGenerator(StyleGenerator<ITEM> styleGenerator) {
    ((Tree<ITEM>) this).setStyleGenerator(styleGenerator);
    return (THIS) this;
}
项目:SecureBPMN    文件:AbstractTreePage.java   
protected abstract Tree createTree();
项目:FiWare-Template-Handler    文件:AbstractTreePage.java   
protected abstract Tree createTree();