Package javax.swing

Examples of javax.swing.JMenuItem$AccessibleJMenuItem


        JPopupMenu popupMenu = new JPopupMenu();
        if (searchText != null && searchText.length() > 0) {
          String value = ProgramInfo.getInstance().getSettings()
              .getActorSearch();

          JMenuItem item = searchTextMenuItem(searchText);

          if (value.equals("internalSearch")) {
            item.setFont(item.getFont().deriveFont(Font.BOLD));
          }

          popupMenu.add(item);

          item = new JMenuItem(mLocalizer.msg("searchWikipedia",
              "Search in Wikipedia"));
          item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              searchWikipedia(searchText);
            }
          });

          if (value.equals("internalWikipedia")) {
            item.setFont(item.getFont().deriveFont(Font.BOLD));
          }

          popupMenu.add(item);

          final PluginAccess webPlugin = PluginManagerImpl.getInstance()
              .getActivatedPluginForId("java.webplugin.WebPlugin");

          if (webPlugin != null && webPlugin.canReceiveProgramsWithTarget()) {
            ProgramReceiveTarget[] targets = webPlugin
                .getProgramReceiveTargets();

            if (targets != null && targets.length > 0) {
              final JMenu subMenu = new JMenu(webPlugin.getInfo().getName());
              subMenu.setIcon(webPlugin.getMarkIcon());
              popupMenu.add(subMenu);

              for (final ProgramReceiveTarget target : targets) {
                item = new JMenuItem(target.toString());
                item.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    searchWebPlugin(searchText, target);
                  }
                });

                if (value.endsWith(target.getTargetId())) {
                  item.setFont(item.getFont().deriveFont(Font.BOLD));
                }

                subMenu.add(item);
              }
            }
          }

          popupMenu.addSeparator();
          popupMenu.add(addFavoriteMenuItem(searchText, actorFavorite));
          popupMenu.addSeparator();
        }
        JMenu subMenu = ContextMenuManager.getInstance()
            .createContextMenuItems(ProgramInfoProxy.getInstance(), mProgram,
                true);
        subMenu.setText(Localizer.getLocalization(Localizer.I18N_PROGRAM));
        popupMenu.add(subMenu);
        return popupMenu;
      }

      private void handleEvent(MouseEvent e, boolean popupEvent) {
        JEditorPane editor = (JEditorPane) e.getSource();

        Point pt = new Point(e.getX(), e.getY());
        int pos = editor.viewToModel(pt);
        if (pos >= 0) {
          String link = getLink(pos, editor);

          if (link != null
              && link.startsWith(ProgramTextCreator.TVBROWSER_URL_PROTOCOL)) {
            final String searchText = link
                .substring(ProgramTextCreator.TVBROWSER_URL_PROTOCOL.length());

            if (popupEvent) {
              JPopupMenu popupMenu = getPopupMenu(searchText, true);
              popupMenu.show(e.getComponent(), e.getX(), e.getY());
            } else {
              String value = ProgramInfo.getInstance().getSettings()
                  .getActorSearch();

              boolean found = false;

              if (value.contains("#_#_#")) {
                String[] keys = value.split("#_#_#");

                PluginAccess webPlugin = PluginManagerImpl.getInstance()
                    .getActivatedPluginForId(keys[0]);

                if (webPlugin != null
                    && webPlugin.canReceiveProgramsWithTarget()) {
                  ProgramReceiveTarget[] targets = webPlugin
                      .getProgramReceiveTargets();

                  if (targets != null) {

                    for (ProgramReceiveTarget target : targets) {
                      if (target.getTargetId().equals(keys[1])) {
                        searchWebPlugin(searchText, target);
                        found = true;
                      }
                    }
                  }
                }
              }

              if (!found) {
                if (value.equals("internalSearch")) {
                  internalSearch(searchText);
                } else {
                  searchWikipedia(searchText);
                }
              }
            }
          } else if (popupEvent){
            String selection = getSelection(pos, editor);
            JPopupMenu popupMenu = getPopupMenu(selection, false);
            TextComponentPopupEventQueue.addStandardContextMenu(mInfoEP,
                popupMenu);
            popupMenu.show(e.getComponent(), e.getX(), e.getY());
          }
        }
      }

      private JMenuItem searchTextMenuItem(final String desc) {
        JMenuItem item = new JMenuItem(mLocalizer.msg("searchTvBrowser",
            "Search in TV-Browser"), IconLoader.getInstance().getIconFromTheme(
            "actions", "edit-find"));
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            internalSearch(desc);
          }
        });
        return item;
      }

      private JMenuItem addFavoriteMenuItem(final String desc,
          final boolean actor) {
        JMenuItem item;
        item = new JMenuItem(mLocalizer.ellipsisMsg("addFavorite",
            "Create favorite"), IconLoader.getInstance().getIconFromTheme(
            "emblems", "emblem-favorite"));
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (actor) {
              FavoritesPlugin.getInstance().showCreateActorFavoriteWizard(
                  mProgram, desc);
            } else {
View Full Code Here


    mToolbarMI.setSelected(Settings.propIsToolbarVisible.getBoolean());
    mToolbarMI.addActionListener(this);
    new MenuHelpTextAdapter(mToolbarMI, mLocalizer.msg("menuinfo.toolbar", ""),
        mLabel);

    mToolbarCustomizeMI = new JMenuItem(ContextMenu.mLocalizer.ellipsisMsg(
        "configure", "Configure"));
    mToolbarCustomizeMI.addActionListener(this);
    new MenuHelpTextAdapter(mToolbarCustomizeMI, mLocalizer.msg(
        "menuinfo.customizeToolbar", ""), mLabel);
View Full Code Here

    mViewMenu.add(mFullscreenMI);
  }

  private JMenuItem createMenuItem(final String localizerKey,
      final String defaultLabel, Icon icon, boolean ellipsis) {
    JMenuItem item = new JMenuItem();
    setLabelAndAccessKeys(localizerKey, defaultLabel, item, ellipsis);
    if (icon != null) {
      item.setIcon(icon);
    }
    return item;
  }
View Full Code Here

    }
    return item;
  }

  private JMenuItem createMenuItem(final TVBrowserAction action) {
    JMenuItem item = new JMenuItem(action);
    setLabelAndAccessKeys("", action.getMenuText(), item, action.useEllipsis());
    item.setIcon(action.getIcon());
    new MenuHelpTextAdapter(item, action.getMenuHelpText(), mLabel);
    KeyStroke accelerator = action.getAccelerator();
    if (accelerator != null) {
      item.setAccelerator(accelerator);
    }
    return item;
  }
View Full Code Here

        menuItem.setSelected(true);
      }
    }
    menu.add(new JSeparator());
    // new channel group
    JMenuItem menuItemAdd = createMenuItem("channelGroupNew",
        "Add channel group", null, true);
    menuItemAdd.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, null,
            ChannelFilterComponent.class);
        FilterComponent rule = dlg.getFilterComponent();
        if ((rule != null) && (rule instanceof ChannelFilterComponent)) {
          FilterComponentList.getInstance().add(rule);
          FilterComponentList.getInstance().store();
          MainFrame.getInstance()
              .setChannelGroup((ChannelFilterComponent) rule);
        }
      }
    });
    menu.add(menuItemAdd);
    // edit channel group
    JMenuItem menuItemEdit = createMenuItem("channelGroupEdit",
        "Edit current channel group", null, true);
    menuItemEdit.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        FilterComponent rule = MainFrame.getInstance().getChannelGroup();
        if (rule != null) {
          // rule must be removed before editing it, otherwise the dialog doesn't save it
          FilterComponentList.getInstance().remove(rule.getName());
          EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, rule);
          FilterComponent newRule = dlg.getFilterComponent();
          if (newRule == null) { // restore original rule
            newRule = rule;
          }
          FilterComponentList.getInstance().add(newRule);
          FilterComponentList.getInstance().store();
          MainFrame.getInstance().setChannelGroup((ChannelFilterComponent) newRule);
        }
      }
    });
    menu.add(menuItemEdit);
    menuItemEdit.setEnabled(!MainFrame.isStarting() && MainFrame.getInstance().getChannelGroup() != null);
  }
View Full Code Here

    menu.add(menuItemEdit);
    menuItemEdit.setEnabled(!MainFrame.isStarting() && MainFrame.getInstance().getChannelGroup() != null);
  }

  private JMenuItem createDateMenuItem(final Date date) {
    JMenuItem item = new JMenuItem(date.getLongDateString());
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        mMainFrame.goTo(date);
      }
    });
    return item;
View Full Code Here

  private JMenuItem createChannelMenuItem(final Channel channel) {
    Icon icon = null;
    if (Settings.propShowChannelIconsInChannellist.getBoolean()) {
      icon = UiUtilities.createChannelIcon(channel.getIcon());
    }
    JMenuItem item = new JMenuItem(channel.getName(), icon);
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        mMainFrame.showChannel(channel);
      }
    });
View Full Code Here

  }

  private JMenuItem createTimeMenuItem(final int time) {
    int h = time / 60;
    int min = time % 60;
    JMenuItem item = new JMenuItem((h < 10 ? "0" : "") + h + ":"
        + (min < 10 ? "0" : "") + min);
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        mMainFrame.scrollToTime(time);
      }
    });
    return item;
View Full Code Here

        .getDataServices();
    for (TvDataServiceProxy service : services) {
      final String license = service.getInfo().getLicense();
      if (license != null) {
        String name = service.getInfo().getName();
        JMenuItem item = new JMenuItem(name, new ImageIcon(
            "imgs/tvbrowser16.png"));
        setMnemonic(item);
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            LicenseBox box = new LicenseBox(mMainFrame, license, false);
            util.ui.UiUtilities.centerAndShow(box);
          }
        });
View Full Code Here

    mPluginsMenu.add(mInstallPluginsMI);
    mPluginsMenu.add(mPluginManagerMI);
  }

  private JMenuItem createMenuItem(ActionMenu menu) {
    JMenuItem result;
    Icon icon = (Icon) menu.getAction().getValue(Action.SMALL_ICON);
    if (icon != null) {
      // resize any icon that is not a channel icon
      if (icon.getIconWidth() != 42 || icon.getIconHeight() != 22) {
        icon = new FixedSizeIcon(16, 16, icon);
      }
    }
    if (menu.hasSubItems()) {
      result = new ScrollableMenu(menu.getTitle());

      if (icon != null) {
        result.setIcon(icon);
      }

      ActionMenu[] subItems = menu.getSubItems();
      for (ActionMenu subItem : subItems) {
        final JMenuItem menuItem = createMenuItem(subItem);
        if (menuItem != null) {
          result.add(menuItem);
        } else {
          ((JMenu) result).addSeparator();
        }
      }
    } else {
      if (ContextMenuSeparatorAction.getInstance().equals(menu.getAction())) {
        return null;
      }
      result = new JMenuItem(menu.getAction());
      if (icon != null) {
        result.setIcon(icon);
      }
    }
View Full Code Here

TOP

Related Classes of javax.swing.JMenuItem$AccessibleJMenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.