PDA

View Full Version : [FIXED] Patch to add constructors to MenuItem



negge
27 Jun 2008, 1:38 PM
Here are some useful constructors to add to MenuItem.


--- user/src/com/extjs/gxt/ui/client/widget/menu/MenuItem.java (revision 531)
+++ user/src/com/extjs/gxt/ui/client/widget/menu/MenuItem.java (working copy)
@@ -9,6 +9,7 @@

import com.extjs.gxt.ui.client.GXT;
import com.extjs.gxt.ui.client.event.ComponentEvent;
+import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Format;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@@ -44,6 +45,40 @@
}

/**
+ * Creates a new item with the given text and icon style
+ *
+ * @param text the item's text
+ * @param iconStyle the icon style
+ */
+ public MenuItem(String text, String iconStyle) {
+ this(text);
+ setIconStyle(iconStyle);
+ }
+
+ /**
+ * Creates a new item with the given text and listener
+ *
+ * @param text the item's text
+ * @param listener the listener to add
+ */
+ public MenuItem(String text, SelectionListener listener) {
+ this(text);
+ addSelectionListener(listener);
+ }
+
+ /**
+ * Creates a new item with the given text, icon style and listener
+ *
+ * @param text the item's text
+ * @param iconStyle the icon style
+ * @param listener the listener to add
+ */
+ public MenuItem(String text, String iconStyle, SelectionListener listener) {
+ this(text,iconStyle);
+ addSelectionListener(listener);
+ }
+
+ /**
* Expands the item's sub menu.
*/
public void expandMenu() {
Nathan

darrellmeyer
30 Jun 2008, 6:28 AM
New constructors are in SVN.