diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-10-27 07:57:12 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-10-27 07:57:12 +0000 |
commit | 6a3c715dae922edd723c9423b4308d5d7948b74e (patch) | |
tree | 46a007274681a9803afccf135ace5554f3e01e3a /src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java | |
parent | 931d75fef69deb9b738fad97001cf5621de9f43e (diff) | |
download | vaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.tar.gz vaadin-framework-6a3c715dae922edd723c9423b4308d5d7948b74e.zip |
Split demo and tests files to own source folders, for #3298
svn changeset:9390/svn branch:6.2
Diffstat (limited to 'src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java')
-rw-r--r-- | src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java b/src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java deleted file mode 100644 index 7b84ce16ee..0000000000 --- a/src/com/vaadin/demo/sampler/features/trees/TreeMouseEventsExample.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.vaadin.demo.sampler.features.trees;
-
-import com.vaadin.data.Item;
-import com.vaadin.demo.sampler.ExampleUtil;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.ui.AbstractSelect;
-import com.vaadin.ui.Tree;
-import com.vaadin.ui.VerticalLayout;
-
-@SuppressWarnings("serial")
-public class TreeMouseEventsExample extends VerticalLayout implements
- ItemClickListener {
-
- private Tree t;
- private int itemId;
-
- public TreeMouseEventsExample() {
- setSpacing(true);
-
- // Create new Tree object using a hierarchical container from
- // ExampleUtil class
- t = new Tree("Hardware Inventory", ExampleUtil.getHardwareContainer());
-
- // Add ItemClickListener to the tree
- t.addListener(this);
-
- t.setImmediate(true);
-
- // Set tree to show the 'name' property as caption for items
- t.setItemCaptionPropertyId(ExampleUtil.hw_PROPERTY_NAME);
- t.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
-
- // Starting itemId # for new items
- itemId = t.getContainerDataSource().size();
-
- // Expand whole tree
- for (int i = 0; i < itemId; i++) {
- t.expandItemsRecursively(i);
- }
-
- // Disallow selecting items from the tree
- t.setSelectable(false);
-
- addComponent(t);
- }
-
- public void itemClick(ItemClickEvent event) {
- // Indicate which modifier keys are pressed
- String modifiers = "";
- if (event.isAltKey()) {
- modifiers += "Alt ";
- }
- if (event.isCtrlKey()) {
- modifiers += "Ctrl ";
- }
- if (event.isMetaKey()) {
- modifiers += "Meta ";
- }
- if (event.isShiftKey()) {
- modifiers += "Shift ";
- }
- if (modifiers.length() > 0) {
- modifiers = "Modifiers: " + modifiers;
- } else {
- modifiers = "Modifiers: none";
- }
- switch (event.getButton()) {
- case ItemClickEvent.BUTTON_LEFT:
- // Left button click updates the 'selected' Label
- getWindow().showNotification("Selected item: " + event.getItem(),
- modifiers);
- break;
- case ItemClickEvent.BUTTON_MIDDLE:
- // Middle button click removes the item
- Object parent = t.getParent(event.getItemId());
- getWindow().showNotification("Removed item: " + event.getItem(),
- modifiers);
- t.removeItem(event.getItemId());
- if (parent != null && t.getChildren(parent).size() == 0) {
- t.setChildrenAllowed(parent, false);
- }
- break;
- case ItemClickEvent.BUTTON_RIGHT:
- // Right button click creates a new child item
- getWindow().showNotification("Added item: New Item # " + itemId,
- modifiers);
- t.setChildrenAllowed(event.getItemId(), true);
- Item i = t.addItem(itemId);
- t.setChildrenAllowed(itemId, false);
- String newItemName = "New Item # " + itemId;
- i.getItemProperty(ExampleUtil.hw_PROPERTY_NAME).setValue(
- newItemName);
- t.setParent(itemId, event.getItemId());
- t.expandItem(event.getItemId());
- itemId++;
- break;
- }
- }
-}
|