summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebContent/VAADIN/themes/base/menubar/menubar.css25
-rw-r--r--WebContent/VAADIN/themes/base/styles.css44
-rw-r--r--WebContent/VAADIN/themes/reindeer/menubar/menubar.css15
-rw-r--r--WebContent/VAADIN/themes/reindeer/styles.css62
-rw-r--r--WebContent/VAADIN/themes/runo/menubar/menubar.css14
-rw-r--r--WebContent/VAADIN/themes/runo/styles.css58
-rw-r--r--WebContent/VAADIN/themes/sampler/sampler/styles.css1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java112
-rw-r--r--src/com/vaadin/ui/MenuBar.java21
9 files changed, 241 insertions, 111 deletions
diff --git a/WebContent/VAADIN/themes/base/menubar/menubar.css b/WebContent/VAADIN/themes/base/menubar/menubar.css
index 610fb4d9b4..909d714f13 100644
--- a/WebContent/VAADIN/themes/base/menubar/menubar.css
+++ b/WebContent/VAADIN/themes/base/menubar/menubar.css
@@ -3,12 +3,12 @@
padding: 0;
margin: 0;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar .menuitem * {
+.v-menubar .v-menubar-menuitem * {
vertical-align: middle;
}
.v-menubar-submenu {
@@ -24,25 +24,36 @@
padding: 0;
margin: 0;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-menuitem-selected{
background: #333;
color: #fff;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar-submenu .menuitem * {
+.v-menubar-submenu .v-menubar-menuitem * {
vertical-align: middle;
}
-.v-menubar .v-menubar-submenu-indicator {
+.v-menubar-submenu-indicator {
display: none;
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
}
.v-menubar-submenu .v-menubar-submenu-indicator {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
margin-left: 1em;
float: right;
height: 100%;
font-size: 0.9em;
+}
+.v-menubar-menuitem-disabled {
+ color: #999;
+}
+.v-menubar-more-menuitem {
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
} \ No newline at end of file
diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css
index 6fbb87bf51..27afc8c299 100644
--- a/WebContent/VAADIN/themes/base/styles.css
+++ b/WebContent/VAADIN/themes/base/styles.css
@@ -626,12 +626,12 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar .menuitem * {
+.v-menubar .v-menubar-menuitem * {
vertical-align: middle;
}
.v-menubar-submenu {
@@ -647,28 +647,39 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-menuitem-selected{
background: #333;
color: #fff;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar-submenu .menuitem * {
+.v-menubar-submenu .v-menubar-menuitem * {
vertical-align: middle;
}
-.v-menubar .v-menubar-submenu-indicator {
+.v-menubar-submenu-indicator {
display: none;
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
}
.v-menubar-submenu .v-menubar-submenu-indicator {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
margin-left: 1em;
float: right;
height: 100%;
font-size: 0.9em;
}
+.v-menubar-menuitem-disabled {
+ color: #999;
+}
+.v-menubar-more-menuitem {
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
+}
.v-Notification {
background: #999;
@@ -1377,6 +1388,19 @@ div.v-progressindicator-indeterminate-disabled {
.v-tabsheet-tabs .v-caption span {
white-space: nowrap;
}
+.v-tabsheet-caption-close {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
+ width: 16px;
+ height: 16px;
+ background: url(common/img/close.png) no-repeat;
+ cursor: pointer;
+ vertical-align: middle;
+}
+.v-disabled .v-tabsheet-caption-close {
+ cursor: default;
+}
.v-tabsheet-tabitem {
border: 1px solid #aaa;
border-right: none;
@@ -1600,9 +1624,9 @@ div.v-tree-node-leaf {
position: absolute;
top: 0;
right: 0;
- width: 1em;
- height: 1em;
- background: red;
+ width: 16px;
+ height: 16px;
+ background: url(common/img/close.png) no-repeat;
cursor: pointer;
overflow: hidden;
}
diff --git a/WebContent/VAADIN/themes/reindeer/menubar/menubar.css b/WebContent/VAADIN/themes/reindeer/menubar/menubar.css
index ae156fa596..787453d15c 100644
--- a/WebContent/VAADIN/themes/reindeer/menubar/menubar.css
+++ b/WebContent/VAADIN/themes/reindeer/menubar/menubar.css
@@ -10,7 +10,7 @@
margin: 0 8px;
height: 23px;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
padding: 3px 8px;
height: 17px;
line-height: 16px;
@@ -25,31 +25,28 @@
overflow: hidden;
padding: 4px 0;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
padding: 1px 15px 1px 10px;
height: 16px;
line-height: 16px;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected,
+.v-menubar-submenu .v-menubar-menuitem-selected {
background: #4d749f repeat-x;
background-image: url(../common/img/sel-bg.png); /** sprite-ref: verticals; sprite-alignment: repeat */
color: #fff;
text-shadow: #3b5a7a 0 1px 0;
}
-.v-menubar .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected {
background-image: url(img/menu-sel-bg.png); /** sprite-ref: verticals; sprite-alignment: repeat */
}
.v-menubar-submenu .v-menubar-submenu-indicator {
background: transparent url(img/submenu-icon.png) no-repeat right 50%;
- display: inline;
- display: inline-block;
- zoom: 1;
width: 16px;
margin: 0 -15px 0 5px;
text-indent: -999px;
vertical-align: middle;
}
-.v-menubar-submenu .menuitem-selected .v-menubar-submenu-indicator {
+.v-menubar-submenu .v-menubar-menuitem-selected .v-menubar-submenu-indicator {
background-image: url(img/submenu-icon-hover.png);
} \ No newline at end of file
diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css
index ad09f5b1e5..02fbb27d08 100644
--- a/WebContent/VAADIN/themes/reindeer/styles.css
+++ b/WebContent/VAADIN/themes/reindeer/styles.css
@@ -626,12 +626,12 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar .menuitem * {
+.v-menubar .v-menubar-menuitem * {
vertical-align: middle;
}
.v-menubar-submenu {
@@ -647,28 +647,39 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-menuitem-selected{
background: #333;
color: #fff;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar-submenu .menuitem * {
+.v-menubar-submenu .v-menubar-menuitem * {
vertical-align: middle;
}
-.v-menubar .v-menubar-submenu-indicator {
+.v-menubar-submenu-indicator {
display: none;
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
}
.v-menubar-submenu .v-menubar-submenu-indicator {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
margin-left: 1em;
float: right;
height: 100%;
font-size: 0.9em;
}
+.v-menubar-menuitem-disabled {
+ color: #999;
+}
+.v-menubar-more-menuitem {
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
+}
.v-Notification {
background: #999;
@@ -1377,6 +1388,19 @@ div.v-progressindicator-indeterminate-disabled {
.v-tabsheet-tabs .v-caption span {
white-space: nowrap;
}
+.v-tabsheet-caption-close {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
+ width: 16px;
+ height: 16px;
+ background: url(../base/common/img/close.png) no-repeat;
+ cursor: pointer;
+ vertical-align: middle;
+}
+.v-disabled .v-tabsheet-caption-close {
+ cursor: default;
+}
.v-tabsheet-tabitem {
border: 1px solid #aaa;
border-right: none;
@@ -1600,9 +1624,9 @@ div.v-tree-node-leaf {
position: absolute;
top: 0;
right: 0;
- width: 1em;
- height: 1em;
- background: red;
+ width: 16px;
+ height: 16px;
+ background: url(../base/common/img/close.png) no-repeat;
cursor: pointer;
overflow: hidden;
}
@@ -2993,7 +3017,7 @@ td.v-datefield-calendarpanel-nextyear {
margin: 0 8px;
height: 23px;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
padding: 3px 8px;
height: 17px;
line-height: 16px;
@@ -3008,13 +3032,13 @@ td.v-datefield-calendarpanel-nextyear {
overflow: hidden;
padding: 4px 0;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
padding: 1px 15px 1px 10px;
height: 16px;
line-height: 16px;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected,
+.v-menubar-submenu .v-menubar-menuitem-selected {
background: #4d749f repeat-x;
background-image: url(common/img/vertical-sprites.png);
-background-image: url(common/img/vertical-sprites-ie6.png);
@@ -3022,22 +3046,19 @@ td.v-datefield-calendarpanel-nextyear {
color: #fff;
text-shadow: #3b5a7a 0 1px 0;
}
-.v-menubar .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected {
background-image: url(common/img/vertical-sprites.png);
-background-image: url(common/img/vertical-sprites-ie6.png);
background-position: left -423px;
}
.v-menubar-submenu .v-menubar-submenu-indicator {
background: transparent url(menubar/img/submenu-icon.png) no-repeat right 50%;
- display: inline;
- display: inline-block;
- zoom: 1;
width: 16px;
margin: 0 -15px 0 5px;
text-indent: -999px;
vertical-align: middle;
}
-.v-menubar-submenu .menuitem-selected .v-menubar-submenu-indicator {
+.v-menubar-submenu .v-menubar-menuitem-selected .v-menubar-submenu-indicator {
background-image: url(menubar/img/submenu-icon-hover.png);
}
@@ -3965,6 +3986,9 @@ td.v-datefield-calendarpanel-nextyear {
height: 16px;
line-height: 16px;
}
+.v-tabsheet-caption-close {
+
+}
.v-tabsheet-tabitemcell-selected {
background-image: url(common/img/vertical-sprites.png);
-background-image: url(common/img/vertical-sprites-ie6.png);
diff --git a/WebContent/VAADIN/themes/runo/menubar/menubar.css b/WebContent/VAADIN/themes/runo/menubar/menubar.css
index 6ef4b93fc6..55890d686f 100644
--- a/WebContent/VAADIN/themes/runo/menubar/menubar.css
+++ b/WebContent/VAADIN/themes/runo/menubar/menubar.css
@@ -1,14 +1,14 @@
.v-menubar {
color: #464f52;
- border: 1px solid #c6cbcc;
- border-right: none;
+ border-left: 1px solid #c6cbcc;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
padding: 0 10px;
margin: 0 10px;
- border-right: 1px solid #c6cbcc;
+ border: 1px solid #c6cbcc;
+ border-left: none;
}
-.v-menubar .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected {
color: #fff;
background: #5daee8;
}
@@ -23,10 +23,10 @@
border-top: 1px solid #d0d4d5;
border-left: 1px solid #d0d4d5;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
padding: 2px 10px;
}
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-submenu .v-menubar-menuitem-selected {
color: #fff;
background: #5daee8;
}
diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css
index 815d09cdc3..cb949ff131 100644
--- a/WebContent/VAADIN/themes/runo/styles.css
+++ b/WebContent/VAADIN/themes/runo/styles.css
@@ -626,12 +626,12 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar .menuitem * {
+.v-menubar .v-menubar-menuitem * {
vertical-align: middle;
}
.v-menubar-submenu {
@@ -647,28 +647,39 @@ div.v-app-loading {
padding: 0;
margin: 0;
}
-.v-menubar .menuitem-selected,
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-menuitem-selected{
background: #333;
color: #fff;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
cursor: default;
vertical-align: middle;
white-space: nowrap;
}
-.v-menubar-submenu .menuitem * {
+.v-menubar-submenu .v-menubar-menuitem * {
vertical-align: middle;
}
-.v-menubar .v-menubar-submenu-indicator {
+.v-menubar-submenu-indicator {
display: none;
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
}
.v-menubar-submenu .v-menubar-submenu-indicator {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
margin-left: 1em;
float: right;
height: 100%;
font-size: 0.9em;
}
+.v-menubar-menuitem-disabled {
+ color: #999;
+}
+.v-menubar-more-menuitem {
+ /* Arial has the most coverage for geometric entity characters */
+ font-family: arial, helvetica, sans-serif;
+}
.v-Notification {
background: #999;
@@ -1377,6 +1388,19 @@ div.v-progressindicator-indeterminate-disabled {
.v-tabsheet-tabs .v-caption span {
white-space: nowrap;
}
+.v-tabsheet-caption-close {
+ display: inline;
+ display: inline-block;
+ zoom: 1;
+ width: 16px;
+ height: 16px;
+ background: url(../base/common/img/close.png) no-repeat;
+ cursor: pointer;
+ vertical-align: middle;
+}
+.v-disabled .v-tabsheet-caption-close {
+ cursor: default;
+}
.v-tabsheet-tabitem {
border: 1px solid #aaa;
border-right: none;
@@ -1600,9 +1624,9 @@ div.v-tree-node-leaf {
position: absolute;
top: 0;
right: 0;
- width: 1em;
- height: 1em;
- background: red;
+ width: 16px;
+ height: 16px;
+ background: url(../base/common/img/close.png) no-repeat;
cursor: pointer;
overflow: hidden;
}
@@ -2123,15 +2147,15 @@ div.v-tree-node-leaf {
.v-menubar {
color: #464f52;
- border: 1px solid #c6cbcc;
- border-right: none;
+ border-left: 1px solid #c6cbcc;
}
-.v-menubar .menuitem {
+.v-menubar .v-menubar-menuitem {
padding: 0 10px;
margin: 0 10px;
- border-right: 1px solid #c6cbcc;
+ border: 1px solid #c6cbcc;
+ border-left: none;
}
-.v-menubar .menuitem-selected {
+.v-menubar .v-menubar-menuitem-selected {
color: #fff;
background: #5daee8;
}
@@ -2146,10 +2170,10 @@ div.v-tree-node-leaf {
border-top: 1px solid #d0d4d5;
border-left: 1px solid #d0d4d5;
}
-.v-menubar-submenu .menuitem {
+.v-menubar-submenu .v-menubar-menuitem {
padding: 2px 10px;
}
-.v-menubar-submenu .menuitem-selected {
+.v-menubar-submenu .v-menubar-menuitem-selected {
color: #fff;
background: #5daee8;
}
diff --git a/WebContent/VAADIN/themes/sampler/sampler/styles.css b/WebContent/VAADIN/themes/sampler/sampler/styles.css
index a60db36a75..3eb778ab2d 100644
--- a/WebContent/VAADIN/themes/sampler/sampler/styles.css
+++ b/WebContent/VAADIN/themes/sampler/sampler/styles.css
@@ -304,6 +304,7 @@
line-height: 16px;
color: #787b7e;
float: left;
+ clear: left;
width: 155px;
height: 131px;
padding: 15px 175px 0 15px;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 1a9216c4c8..c3a9c89884 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -47,6 +47,7 @@ public class VMenuBar extends Widget implements Paintable,
protected Element containerElement;
protected VOverlay popup;
protected VMenuBar visibleChildMenu;
+ protected boolean menuVisible = false;
protected VMenuBar parentMenu;
protected CustomMenuItem selected;
@@ -125,7 +126,12 @@ public class VMenuBar extends Widget implements Paintable,
.getStringAttribute("icon")) + "\" class=\""
+ Icon.CLASSNAME + "\" alt=\"\" />");
}
- itemHTML.append(moreItemUIDL.getStringAttribute("text"));
+
+ String moreItemText = moreItemUIDL.getStringAttribute("text");
+ if ("".equals(moreItemText)) {
+ moreItemText = "▶";
+ }
+ itemHTML.append(moreItemText);
moreItem = new CustomMenuItem(itemHTML.toString(), emptyCommand);
collapsedRootItems = new VMenuBar(true);
@@ -151,15 +157,6 @@ public class VMenuBar extends Widget implements Paintable,
// Construct html from the text and the optional icon
StringBuffer itemHTML = new StringBuffer();
- if (item.hasAttribute("icon")) {
- itemHTML.append("<img src=\""
- + client.translateVaadinUri(item
- .getStringAttribute("icon")) + "\" class=\""
- + Icon.CLASSNAME + "\" alt=\"\" />");
- }
-
- itemHTML.append(itemText);
-
// Add submenu indicator
if (item.getChildCount() > 0) {
// FIXME For compatibility reasons: remove in version 7
@@ -174,6 +171,15 @@ public class VMenuBar extends Widget implements Paintable,
+ ">&#x25B6;</span>");
}
+ if (item.hasAttribute("icon")) {
+ itemHTML.append("<img src=\""
+ + client.translateVaadinUri(item
+ .getStringAttribute("icon")) + "\" class=\""
+ + Icon.CLASSNAME + "\" alt=\"\" />");
+ }
+
+ itemHTML.append(itemText);
+
Command cmd = null;
if (itemHasCommand) {
@@ -187,6 +193,7 @@ public class VMenuBar extends Widget implements Paintable,
}
currentItem = currentMenu.addItem(itemHTML.toString(), cmd);
+ currentItem.setEnabled(!item.hasAttribute("disabled"));
if (item.getChildCount() > 0) {
menuStack.push(currentMenu);
@@ -348,7 +355,6 @@ public class VMenuBar extends Widget implements Paintable,
*/
@Override
public void onBrowserEvent(Event e) {
- super.onBrowserEvent(e);
Element targetElement = DOM.eventGetTarget(e);
CustomMenuItem targetItem = null;
@@ -363,11 +369,15 @@ public class VMenuBar extends Widget implements Paintable,
switch (DOM.eventGetType(e)) {
case Event.ONCLICK:
- itemClick(targetItem);
+ if (targetItem.isEnabled()) {
+ itemClick(targetItem);
+ }
break;
case Event.ONMOUSEOVER:
- itemOver(targetItem);
+ if (targetItem.isEnabled()) {
+ itemOver(targetItem);
+ }
break;
case Event.ONMOUSEOUT:
@@ -375,6 +385,8 @@ public class VMenuBar extends Widget implements Paintable,
break;
}
}
+
+ super.onBrowserEvent(e);
}
/**
@@ -390,7 +402,8 @@ public class VMenuBar extends Widget implements Paintable,
visibleChildMenu.hideChildren();
}
- hideParents();
+ hideParents(true);
+ menuVisible = false;
DeferredCommand.addCommand(item.getCommand());
} else {
@@ -398,6 +411,11 @@ public class VMenuBar extends Widget implements Paintable,
&& item.getSubMenu() != visibleChildMenu) {
setSelected(item);
showChildMenu(item);
+ menuVisible = true;
+ } else if (!subMenu) {
+ setSelected(null);
+ hideChildren();
+ menuVisible = false;
}
}
}
@@ -408,15 +426,16 @@ public class VMenuBar extends Widget implements Paintable,
* @param item
*/
public void itemOver(CustomMenuItem item) {
- setSelected(item);
-
- boolean menuWasVisible = visibleChildMenu != null;
+ if (subMenu || menuVisible) {
+ setSelected(item);
+ }
- if (menuWasVisible && visibleChildMenu != item.getSubMenu()) {
+ if (menuVisible && visibleChildMenu != item.getSubMenu()
+ && popup != null) {
popup.hide();
}
- if (item.getSubMenu() != null && (parentMenu != null || menuWasVisible)
+ if (menuVisible && item.getSubMenu() != null
&& visibleChildMenu != item.getSubMenu()) {
showChildMenu(item);
}
@@ -428,9 +447,11 @@ public class VMenuBar extends Widget implements Paintable,
* @param item
*/
public void itemOut(CustomMenuItem item) {
- if (visibleChildMenu != item.getSubMenu() || visibleChildMenu == null) {
+ if (visibleChildMenu != item.getSubMenu()) {
hideChildMenu(item);
setSelected(null);
+ } else if (visibleChildMenu == null) {
+ setSelected(null);
}
}
@@ -444,6 +465,8 @@ public class VMenuBar extends Widget implements Paintable,
popup = new VOverlay(true, false, true);
popup.setWidget(item.getSubMenu());
popup.addCloseHandler(this);
+ popup.addAutoHidePartner(item.getElement());
+
int left = 0;
int top = 0;
if (subMenu) {
@@ -486,7 +509,6 @@ public class VMenuBar extends Widget implements Paintable,
if (visibleChildMenu != null
&& !(visibleChildMenu == item.getSubMenu())) {
popup.hide();
-
}
}
@@ -499,6 +521,20 @@ public class VMenuBar extends Widget implements Paintable,
selected.setSelected(false);
selected = null;
}
+ menuVisible = true;
+ }
+
+ /**
+ * Listener method, fired when this menu is closed
+ */
+ public void onClose(CloseEvent<PopupPanel> event) {
+ hideChildren();
+ if (event.isAutoClosed()) {
+ hideParents(true);
+ menuVisible = false;
+ }
+ visibleChildMenu = null;
+ popup = null;
}
/**
@@ -514,15 +550,15 @@ public class VMenuBar extends Widget implements Paintable,
/**
* Recursively hide all parent menus
*/
- public void hideParents() {
-
+ public void hideParents(boolean autoClosed) {
if (visibleChildMenu != null) {
popup.hide();
setSelected(null);
+ menuVisible = !autoClosed;
}
if (getParentMenu() != null) {
- getParentMenu().hideParents();
+ getParentMenu().hideParents(autoClosed);
}
}
@@ -574,19 +610,6 @@ public class VMenuBar extends Widget implements Paintable,
}
/**
- * Listener method, fired when this menu is closed
- */
- public void onClose(CloseEvent<PopupPanel> event) {
- hideChildren();
- if (event.isAutoClosed()) {
- hideParents();
- }
- visibleChildMenu = null;
- popup = null;
-
- }
-
- /**
*
* A class to hold information on menu items
*
@@ -597,6 +620,7 @@ public class VMenuBar extends Widget implements Paintable,
protected Command command = null;
protected VMenuBar subMenu = null;
protected VMenuBar parentMenu = null;
+ protected boolean enabled = true;
public CustomMenuItem(String html, Command cmd) {
setElement(DOM.createTD());
@@ -605,7 +629,7 @@ public class VMenuBar extends Widget implements Paintable,
setCommand(cmd);
setSelected(false);
- addStyleName("menuitem");
+ setStylePrimaryName(CLASSNAME + "-menuitem");
}
public void setSelected(boolean selected) {
@@ -659,7 +683,19 @@ public class VMenuBar extends Widget implements Paintable,
public void setText(String text) {
setHTML(text);
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ if (enabled) {
+ removeStyleDependentName("disabled");
+ } else {
+ addStyleDependentName("disabled");
+ }
+ }
+ public boolean isEnabled() {
+ return enabled;
}
}
diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java
index c0939d23ed..77523f9680 100644
--- a/src/com/vaadin/ui/MenuBar.java
+++ b/src/com/vaadin/ui/MenuBar.java
@@ -97,6 +97,10 @@ public class MenuBar extends AbstractComponent {
target.addAttribute("icon", icon);
}
+ if (!item.isEnabled()) {
+ target.addAttribute("disabled", true);
+ }
+
if (item.hasChildren()) {
iteratorStack.push(itr); // For later use
@@ -148,7 +152,7 @@ public class MenuBar extends AbstractComponent {
}// while
// If we got the clicked item, launch the command.
- if (found) {
+ if (found && tmpItem.isEnabled()) {
tmpItem.getCommand().menuSelected(tmpItem);
}
}// if
@@ -327,8 +331,7 @@ public class MenuBar extends AbstractComponent {
/**
* Set the item that is used when collapsing the top level menu. All
* "overflowing" items will be added below this. The item command will be
- * ignored. If set to null, the default item with the "More..." text is be
- * used.
+ * ignored. If set to null, the default item with a downwards arrow is used.
*
* The item command (if specified) is ignored.
*
@@ -338,7 +341,7 @@ public class MenuBar extends AbstractComponent {
if (item != null) {
moreItem = item;
} else {
- moreItem = new MenuItem("More...", null, null);
+ moreItem = new MenuItem("", null, null);
}
requestRepaint();
}
@@ -378,6 +381,7 @@ public class MenuBar extends AbstractComponent {
private List<MenuItem> itsChildren;
private Resource itsIcon;
private MenuItem itsParent;
+ private boolean enabled = true;
/**
* Constructs a new menu item that can optionally have an icon and a
@@ -625,6 +629,15 @@ public class MenuBar extends AbstractComponent {
itsParent = parent;
}
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ requestRepaint();
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
}// class MenuItem
}// class MenuBar