Package javax.swing

Examples of javax.swing.JMenuItem$AccessibleJMenuItem


      final TreePath path = path1;
      final FavoriteNode last = (FavoriteNode)path.getLastPathComponent();

      setSelectionPath(path);

      JMenuItem item;

      if(last.isDirectoryNode() && last.getChildCount() > 0) {
        item = new JMenuItem(isExpanded(path) ? mLocalizer.msg("collapse", "Collapse") : mLocalizer.msg("expand", "Expand"));
        item.setFont(item.getFont().deriveFont(Font.BOLD));

        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if(isExpanded(path)) {
              collapsePath(path);
            } else {
              expandPath(path);
            }
          }
        });

        if(!last.equals(mRootNode)) {
          menu.add(item);
        }

        item = new JMenuItem(mLocalizer.msg("expandAll", "Expand all"));

        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            expandAll(last);
          }
        });

        menu.add(item);

        item = new JMenuItem(mLocalizer.msg("collapseAll", "Collapse all"));

        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            collapseAll(last);
          }
        });
        menu.add(item);

        menu.addSeparator();
      }

      if (!last.isDirectoryNode()) {
        item = new JMenuItem(mLocalizer.ellipsisMsg("editFavorite", "Edit favorite '{0}'", last.getFavorite().getName()),
            TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));
        item.setFont(item.getFont().deriveFont(Font.BOLD));

        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ManageFavoritesDialog.getInstance().editSelectedFavorite();
          }
        });
        menu.add(item);
        menu.addSeparator();
      }

      item = new JMenuItem(mLocalizer.msg("newFolder", "New folder"),
          IconLoader.getInstance().getIconFromTheme("actions", "folder-new", 16));

      item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          newFolder(last);
        }
      });
      menu.add(item);

      item = new JMenuItem(mLocalizer.ellipsisMsg("newFavorite", "New Favorite"),
          TVBrowserIcons.newIcon(TVBrowserIcons.SIZE_SMALL));

      item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          ManageFavoritesDialog.getInstance().newFavorite(last.isDirectoryNode() ? last : (FavoriteNode)last.getParent());
        }
      });
      menu.add(item);

      if(last.isDirectoryNode()) {
        if(!last.equals(mRootNode)) {
          item = new JMenuItem(mLocalizer.msg("renameFolder", "Rename folder"),
              TVBrowserIcons.edit(TVBrowserIcons.SIZE_SMALL));

          item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              renameFolder(last);
            }
          });

          menu.add(item);
        }
      }

      FavoriteNode parentSort = null;

      if(!last.isDirectoryNode() && last.getParent().equals(mRootNode) && mRootNode.getChildCount() > 1) {
        parentSort = (FavoriteNode)last.getParent();
      }

      final FavoriteNode sortNode = parentSort == null ? last : parentSort;

      if(last.getChildCount() > 1 || (last.getParent().equals(mRootNode) && mRootNode.getChildCount() > 1 )) {
        menu.addSeparator();

        item = new JMenuItem(mLocalizer.msg("sort", "Sort alphabetically"),
            IconLoader.getInstance().getIconFromTheme("actions", "sort-list", 16));
        final String titleAlpha = item.getText();
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              FavoriteTreeModel.getInstance().sort(sortNode,FavoriteNodeComparator.getInstance(), titleAlpha);
              reload(sortNode);
          }
        });
        menu.add(item);

        item = new JMenuItem(mLocalizer.msg("sortCount", "Sort by number of programs"),
            IconLoader.getInstance().getIconFromTheme("actions", "sort-list-numerical", 16));
        final String titleCount = item.getText();
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              FavoriteTreeModel.getInstance().sort(sortNode,FavoriteNodeCountComparator.getInstance(),titleCount);
              reload(sortNode);
          }
        });
        menu.add(item);
      }

      if(parentSort != null) {
        menu.addSeparator();
      }


      item = new JMenuItem(Localizer.getLocalization(Localizer.I18N_DELETE),
          TVBrowserIcons.delete(TVBrowserIcons.SIZE_SMALL));

      item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          delete(last);
        }
      });

      if(!last.equals(mRootNode) && last.getChildCount() < 1) {
        menu.add(item);
      }

      if(!ManageFavoritesDialog.getInstance().programListIsEmpty()) {
        menu.addSeparator();

        item = new JMenuItem(ManageFavoritesDialog.mLocalizer.msg("send", "Send Programs to another Plugin"), TVBrowserIcons.copy(TVBrowserIcons.SIZE_SMALL));
        item.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
             ManageFavoritesDialog.getInstance().showSendDialog();
          }
        });
View Full Code Here


  protected void createPanel() {
    JScrollPane                pane;
   
    setLayout(new BorderLayout());
   
    menuItemMean = new JMenuItem("Get mean...");
    menuItemMean.addActionListener(this);
    menuItemSetAllValues = new JMenuItem("Set all values to...");
    menuItemSetAllValues.addActionListener(this);
    menuItemSetMissingValues = new JMenuItem("Set missing values to...");
    menuItemSetMissingValues.addActionListener(this);
    menuItemReplaceValues = new JMenuItem("Replace values with...");
    menuItemReplaceValues.addActionListener(this);
    menuItemRenameAttribute = new JMenuItem("Rename attribute...");
    menuItemRenameAttribute.addActionListener(this);
    menuItemAttributeAsClass = new JMenuItem("Attribute as class");
    menuItemAttributeAsClass.addActionListener(this);
    menuItemDeleteAttribute = new JMenuItem("Delete attribute");
    menuItemDeleteAttribute.addActionListener(this);
    menuItemDeleteAttributes = new JMenuItem("Delete attributes...");
    menuItemDeleteAttributes.addActionListener(this);
    menuItemSortInstances = new JMenuItem("Sort data (ascending)");
    menuItemSortInstances.addActionListener(this);
    menuItemOptimalColWidth = new JMenuItem("Optimal column width (current)");
    menuItemOptimalColWidth.addActionListener(this);
    menuItemOptimalColWidths = new JMenuItem("Optimal column width (all)");
    menuItemOptimalColWidths.addActionListener(this);

    // row popup
    menuItemUndo = new JMenuItem("Undo");
    menuItemUndo.addActionListener(this);
    menuItemCopy = new JMenuItem("Copy");
    menuItemCopy.addActionListener(this);
    menuItemSearch = new JMenuItem("Search...");
    menuItemSearch.addActionListener(this);
    menuItemClearSearch = new JMenuItem("Clear search");
    menuItemClearSearch.addActionListener(this);
    menuItemDeleteSelectedInstance = new JMenuItem("Delete selected instance");
    menuItemDeleteSelectedInstance.addActionListener(this);
    menuItemDeleteAllSelectedInstances = new JMenuItem("Delete ALL selected instances");
    menuItemDeleteAllSelectedInstances.addActionListener(this);
   
    // table
    m_TableArff = new ArffTable();
    m_TableArff.setToolTipText("Right click (or left+alt) for context menu");
View Full Code Here

   */
  protected void visualizeClusterer(String name, int x, int y) {
    final String selectedName = name;
    JPopupMenu resultListMenu = new JPopupMenu();

    JMenuItem visMainBuffer = new JMenuItem("View in main window");
    if (selectedName != null) {
      visMainBuffer.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      m_History.setSingle(selectedName);
    }
  });
    } else {
      visMainBuffer.setEnabled(false);
    }
    resultListMenu.add(visMainBuffer);

    JMenuItem visSepBuffer = new JMenuItem("View in separate window");
    if (selectedName != null) {
    visSepBuffer.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    m_History.openFrame(selectedName);
  }
      });
    } else {
      visSepBuffer.setEnabled(false);
    }
    resultListMenu.add(visSepBuffer);

    JMenuItem saveOutput = new JMenuItem("Save result buffer");
    if (selectedName != null) {
      saveOutput.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      saveBuffer(selectedName);
    }
  });
    } else {
      saveOutput.setEnabled(false);
    }
    resultListMenu.add(saveOutput);
   
    JMenuItem deleteOutput = new JMenuItem("Delete result buffer");
    if (selectedName != null) {
      deleteOutput.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    m_History.removeResult(selectedName);
  }
      });
    } else {
      deleteOutput.setEnabled(false);
    }
    resultListMenu.add(deleteOutput);

    resultListMenu.addSeparator();

    JMenuItem loadModel = new JMenuItem("Load model");
    loadModel.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    loadClusterer();
  }
      });
    resultListMenu.add(loadModel);

    FastVector o = null;
    if (selectedName != null) {
      o = (FastVector)m_History.getNamedObject(selectedName);
    }

    VisualizePanel temp_vp = null;
    String temp_grph = null;
    Clusterer temp_clusterer = null;
    Instances temp_trainHeader = null;
    int[] temp_ignoreAtts = null;
   
    if (o != null) {
      for (int i = 0; i < o.size(); i++) {
  Object temp = o.elementAt(i);
  if (temp instanceof Clusterer) {
    temp_clusterer = (Clusterer)temp;
  } else if (temp instanceof Instances) { // training header
    temp_trainHeader = (Instances)temp;
  } else if (temp instanceof int[]) { // ignored attributes
    temp_ignoreAtts = (int[])temp;
  } else if (temp instanceof VisualizePanel) { // normal errors
    temp_vp = (VisualizePanel)temp;
  } else if (temp instanceof String) { // graphable output
    temp_grph = (String)temp;
  }
      }
    }
     
    final VisualizePanel vp = temp_vp;
    final String grph = temp_grph;
    final Clusterer clusterer = temp_clusterer;
    final Instances trainHeader = temp_trainHeader;
    final int[] ignoreAtts = temp_ignoreAtts;
   
    JMenuItem saveModel = new JMenuItem("Save model");
    if (clusterer != null) {
      saveModel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      saveClusterer(selectedName, clusterer, trainHeader, ignoreAtts);
    }
  });
    } else {
      saveModel.setEnabled(false);
    }
    resultListMenu.add(saveModel);
   
    JMenuItem reEvaluate =
      new JMenuItem("Re-evaluate model on current test set");
    if (clusterer != null && m_TestInstances != null) {
      reEvaluate.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      reevaluateModel(selectedName, clusterer, trainHeader, ignoreAtts);
    }
  });
    } else {
      reEvaluate.setEnabled(false);
    }
    resultListMenu.add(reEvaluate);
   
    resultListMenu.addSeparator();
   
    JMenuItem visClusts = new JMenuItem("Visualize cluster assignments");
    if (vp != null) {
      visClusts.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        visualizeClusterAssignments(vp);
      }
    });
     
    } else {
      visClusts.setEnabled(false);
    }
    resultListMenu.add(visClusts);

    JMenuItem visTree = new JMenuItem("Visualize tree");
    if (grph != null) {
      visTree.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      String title;
      if (vp != null) title = vp.getName();
      else title = selectedName;
      visualizeTree(grph, title);
    }
  });
    } else {
      visTree.setEnabled(false);
    }
    resultListMenu.add(visTree);

   
    // visualization plugins
    JMenu visPlugins = new JMenu("Plugins");
    boolean availablePlugins = false;
   
    // trees
    if (grph != null) {
      // trees
      Vector pluginsVector = GenericObjectEditor.getClassnames(TreeVisualizePlugin.class.getName());
      for (int i = 0; i < pluginsVector.size(); i++) {
  String className = (String) (pluginsVector.elementAt(i));
  try {
    TreeVisualizePlugin plugin = (TreeVisualizePlugin) Class.forName(className).newInstance();
    if (plugin == null)
      continue;
    availablePlugins = true;
    JMenuItem pluginMenuItem = plugin.getVisualizeMenuItem(grph, selectedName);
    Version version = new Version();
    if (pluginMenuItem != null) {
      if (version.compareTo(plugin.getMinVersion()) < 0)
        pluginMenuItem.setText(pluginMenuItem.getText() + " (weka outdated)");
      if (version.compareTo(plugin.getMaxVersion()) >= 0)
        pluginMenuItem.setText(pluginMenuItem.getText() + " (plugin outdated)");
      visPlugins.add(pluginMenuItem);
    }
  }
  catch (Exception e) {
    //e.printStackTrace();
View Full Code Here

    // check if menu item has key event for pure keyboard usage
    TreePath[] selectedPaths = mTree.getSelectionPaths();
    ContextMenu menu = createContextMenu(selectedPaths);
    for (MenuElement element : menu.getPopupMenu().getSubElements()) {
      if (element instanceof JMenuItem) {
        final JMenuItem item = (JMenuItem) element;
        final Action action = item.getAction();
        if (action != null) {
          Object keyboard = action
              .getValue(ContextMenuIf.ACTIONKEY_KEYBOARD_EVENT);
          if (keyboard != null && keyboard instanceof Integer
              && (Integer) keyboard == event.getKeyCode()) {
View Full Code Here

        if(item instanceof SoftwareUpdateItem) {
          if(((SoftwareUpdateItem)item).getWebsite() != null) {
            JPopupMenu menu = new JPopupMenu();

            JMenuItem menuItem = new JMenuItem(mLocalizer.msg("openWebsite","Open website"), TVBrowserIcons.webBrowser(TVBrowserIcons.SIZE_SMALL));
            menuItem.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                Launch.openURL(((SoftwareUpdateItem)item).getWebsite());
              }
            });
View Full Code Here

      if (popup.getComponentCount() > 0) {
        popup.addSeparator();
      }

      JMenuItem menuItem = new JMenuItem(TVBrowserActions.scrollToNow.getValue(Action.NAME).toString());
      menuItem.setHorizontalTextPosition(SwingConstants.CENTER);

      menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          MainFrame.getInstance().scrollToNow();
          btn.setSelected(false);
          MainFrame.getInstance().updateToolbar();
        }
View Full Code Here

    return item;
  }

  private JMenuItem createChannelMenuItem(final Channel ch,
      final AbstractButton btn) {
    JMenuItem item = new JMenuItem();

    if (Settings.propShowChannelNamesInChannellist.getBoolean()) {
      item.setText(ch.getName());
    }

    if (Settings.propShowChannelIconsInChannellist.getBoolean()) {
      item.setIcon(UiUtilities.createChannelIcon(ch.getIcon()));
      item.setPreferredSize(new Dimension(item.getPreferredSize().width, item
          .getIcon().getIconHeight()));
    }

    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        MainFrame.getInstance().showChannel(ch);
        btn.setSelected(false);
        MainFrame.getInstance().updateToolbar();
      }
View Full Code Here

    }
    if (hour.length() == 1) {
      hour = "0" + hour;
    }

    JMenuItem item = new JMenuItem(hour + ":" + minute);
    item.setHorizontalTextPosition(SwingConstants.CENTER);

    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        MainFrame.getInstance().scrollToTime(time);
        btn.setSelected(false);
        MainFrame.getInstance().updateToolbar();
      }
View Full Code Here

   
    return show;
  }

  private static JMenuItem createConfigureItem() {
    JMenuItem item = new JMenuItem(mLocalizer.ellipsisMsg("configure", "Configure"));
    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        new ToolBarDragAndDropSettings();
      }
    });
    return item;
View Full Code Here

    } else {
      return;
    }


    JMenuItem item = new JMenuItem(label);
    item.setActionCommand(name);
    item.setEnabled(configItemEnabled);

    item.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().startsWith("#scrollTo") && e.getActionCommand().indexOf("Channel") == -1) {
          MainFrame.getInstance().showSettingsDialog("#timebuttons");
        } else if (e.getActionCommand().startsWith("#filter")) {
          MainFrame.getInstance().showFilterDialog();
        } else if (e.getActionCommand().startsWith("#scrollToChannel")) {
          MainFrame.getInstance().showSettingsDialog(SettingsItem.CHANNELS);
        } else if (e.getActionCommand().indexOf("##") != -1){
          MainFrame.getInstance().showSettingsDialog(e.getActionCommand().substring(0,e.getActionCommand().indexOf("##")));
        } else {
          MainFrame.getInstance().showSettingsDialog(e.getActionCommand());
        }
      }
    });
    menu.add(item);
    menu.addSeparator();

    item = new JMenuItem(mLocalizer.msg("removeButton", "Remove button"));
    final String buttonName = name;
    item.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Action[] actions = mModel.getActions();
        ArrayList<String> idList = new ArrayList<String>();
       
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.