SVAbstractMenuItem.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2007 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License"); You may not
  4. // use this file except in compliance with the License. You may obtain a copy of
  5. // the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
  6. // applicable law or agreed to in writing, software distributed under the
  7. // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
  8. // OF ANY KIND, either express or implied. See the License for the specific
  9. // language governing permissions and limitations under the License.
  10. package com.google.scrollview.ui;
  11. /**
  12. * A MenuListItem is any sort of menu entry. This can either be within a popup
  13. * menu or within a menubar. It can either be a submenu (only name and
  14. * command-id) or a name with an associated value and possibly description. They
  15. * can also have new entries added (if they are submenus).
  16. *
  17. * @author wanke@google.com
  18. */
  19. import com.google.scrollview.events.SVEventType;
  20. import javax.swing.JMenu;
  21. import javax.swing.JMenuItem;
  22. abstract class SVAbstractMenuItem {
  23. JMenuItem mi;
  24. public String name;
  25. public int id;
  26. /**
  27. * Sets the basic attributes for name, id and the corresponding swing item
  28. */
  29. SVAbstractMenuItem(int id, String name, JMenuItem jmi) {
  30. this.mi = jmi;
  31. this.name = name;
  32. this.id = id;
  33. }
  34. /** Returns the actual value of the MenuListItem. */
  35. public String getValue() { return null; }
  36. /** Adds a child entry to the submenu. */
  37. public void add(SVAbstractMenuItem mli) { }
  38. /** Adds a child menu to the submenu (or root node). */
  39. public void add(JMenu jli) { }
  40. /**
  41. * What to do when user clicks on this item.
  42. * @param window The window the event happened.
  43. * @param eventType What kind of event will be associated
  44. * (usually SVET_POPUP or SVET_MENU).
  45. */
  46. public void performAction(SVWindow window, SVEventType eventType) {}
  47. }