Examples of PopupMenu


Examples of java.awt.PopupMenu

   * System Tray Icon Pop Up Menu
   *
   * @return PopupMenu
   */
  private PopupMenu createTrayPopup() {
    PopupMenu trayPopup = new PopupMenu();
   
   
    // About
    MenuItem aboutItem = new MenuItem("About");
    aboutItem.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        showAbout();
      }
     
    });
    trayPopup.add(aboutItem);
   
    trayPopup.addSeparator();
   
    // Shutdown Node
    MenuItem shutdownItem = new MenuItem("Shutdown");
    shutdownItem.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        doShutdownNode();
      }
     
    });
    trayPopup.add(shutdownItem);
   
    return trayPopup;
  }
View Full Code Here

Examples of java.awt.PopupMenu

    final int xx = x;
    final int yy = y;
    int menuItemCount = 0;

    // modifications by Zerbetto
    PopupMenu beanContextMenu = new PopupMenu();

    //JPopupMenu beanContextMenu = new JPopupMenu();

    //    beanContextMenu.insert(new JLabel("Edit",
    //              SwingConstants.CENTER),
    //         menuItemCount);
    MenuItem edit = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Edit_MenuItem_Text"));
    edit.setEnabled(false);
    beanContextMenu.insert(edit, menuItemCount);
    menuItemCount++;

    if (bc instanceof MetaBean) {
      //JMenuItem ungroupItem = new JMenuItem("Ungroup");
      MenuItem ungroupItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_UngroupItem_MenuItem_Text"));
      ungroupItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // ungroup
            bi.removeBean(m_beanLayout);

            Vector group = ((MetaBean) bc).getBeansInSubFlow();
            Vector associatedConnections = ((MetaBean) bc).getAssociatedConnections();
            ((MetaBean) bc).restoreBeans();

            for (int i = 0; i < group.size(); i++) {
              BeanInstance tbi = (BeanInstance) group.elementAt(i);
              addComponent(tbi, false);
              tbi.addBean(m_beanLayout);
            }

            for (int i = 0; i < associatedConnections.size(); i++) {
              BeanConnection tbc = (BeanConnection) associatedConnections.elementAt(i);
              tbc.setHidden(false);
            }

            m_beanLayout.repaint();
            notifyIsDirty();
          }
        });
      beanContextMenu.add(ungroupItem);
      menuItemCount++;

      // Add to user tab
      //JMenuItem addToUserTabItem = new JMenuItem("Add to user tab");
      MenuItem addToUserTabItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_AddToUserTabItem_MenuItem_Text"));
      addToUserTabItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addToUserToolBar((MetaBean) bi.getBean(), true);
            notifyIsDirty();
          }
        });
      beanContextMenu.add(addToUserTabItem);
      menuItemCount++;
    }

    //JMenuItem deleteItem = new JMenuItem("Delete");
    MenuItem deleteItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_DeleteItem_MenuItem_Text"));
    deleteItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          BeanConnection.removeConnections(bi);
          bi.removeBean(m_beanLayout);
          if (bc instanceof BeanCommon) {           
            String key = ((BeanCommon)bc).getCustomName()
              + "$" + bc.hashCode();
            m_logPanel.statusMessage(key + "|remove");
          }
          revalidate();
          notifyIsDirty();
        }
      });
    if (bc instanceof BeanCommon) {
      if (((BeanCommon)bc).isBusy()) {
        deleteItem.setEnabled(false);
      }
    }
    beanContextMenu.add(deleteItem);
    menuItemCount++;

    if (bc instanceof BeanCommon) {
      MenuItem nameItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_NameItem_MenuItem_Text"));
      nameItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String oldName = ((BeanCommon)bc).getCustomName();
            String name = JOptionPane.showInputDialog(KnowledgeFlowApp.this,
                Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Name_JOptionPane_ShowInputDialog_Text"),
                                                      oldName);
            if (name != null) {
              ((BeanCommon)bc).setCustomName(name);
            }
          }
        });
      if (bc instanceof BeanCommon) {
        if (((BeanCommon)bc).isBusy()) {
          nameItem.setEnabled(false);
        }
      }
      beanContextMenu.add(nameItem);
      menuItemCount++;
    }

    try {
      //BeanInfo [] compInfo = null;
      //JComponent [] associatedBeans = null;
      Vector compInfo = new Vector(1);
      Vector associatedBeans = null;
      Vector outputBeans = null;
      Vector compInfoOutputs = null;

      if (bc instanceof MetaBean) {
        compInfo = ((MetaBean) bc).getBeanInfoSubFlow();
        associatedBeans = ((MetaBean) bc).getBeansInSubFlow();

        outputBeans = ((MetaBean) bc).getBeansInOutputs();
        compInfoOutputs = ((MetaBean) bc).getBeanInfoOutputs();
      } else {
        compInfo.add(Introspector.getBeanInfo(bc.getClass()));
        compInfoOutputs = compInfo;
      }

      final Vector tempAssociatedBeans = associatedBeans;

      if (compInfo == null) {
        System.err.println(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Error_Text_First"));
      } else {
        //  System.err.println("Got bean info");
        for (int zz = 0; zz < compInfo.size(); zz++) {
          final int tt = zz;
          final Class custClass = ((BeanInfo) compInfo.elementAt(zz)).getBeanDescriptor()
            .getCustomizerClass();

          if (custClass != null) {
            //    System.err.println("Got customizer class");
            //    popupCustomizer(custClass, bc);
            //JMenuItem custItem = null;
            MenuItem custItem = null;
            boolean customizationEnabled = true;

            if (!(bc instanceof MetaBean)) {
              //custItem = new JMenuItem("Configure...");
              custItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_CustItem_MenuItem_Text_First"));
              if (bc instanceof BeanCommon) {
                customizationEnabled =
                  !((BeanCommon)bc).isBusy();
              }
            } else {
              String custName = custClass.getName();
              BeanInstance tbi = (BeanInstance) associatedBeans.elementAt(zz);
              if (tbi.getBean() instanceof BeanCommon) {
                custName = ((BeanCommon)tbi.getBean()).getCustomName();
              } else {
                if (tbi.getBean() instanceof WekaWrapper) {
                  custName = ((WekaWrapper) tbi.getBean()).getWrappedAlgorithm()
                  .getClass().getName();
                } else {
                  custName = custName.substring(0, custName.indexOf("Customizer"));
                }

                custName = custName.substring(custName.lastIndexOf('.') + 1,             
                                            custName.length());
              }
              //custItem = new JMenuItem("Configure: "+ custName);
              custItem = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_CustItem_MenuItem_Text_Second") + custName);
              if (tbi.getBean() instanceof BeanCommon) {
                customizationEnabled =
                  !((BeanCommon)tbi.getBean()).isBusy();
              }
            }

            custItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (bc instanceof MetaBean) {
                    popupCustomizer(custClass,
                      (JComponent) ((BeanInstance) tempAssociatedBeans.
                                    elementAt(tt)).getBean());
                  } else {
                    popupCustomizer(custClass, bc);
                  }

                  notifyIsDirty();
                }
              });
            custItem.setEnabled(customizationEnabled);
            beanContextMenu.add(custItem);
            menuItemCount++;
          } else {
            System.err.println(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Error_Text_Second"));
          }
        }

        Vector esdV = new Vector();

        //for (int i = 0; i < compInfoOutputs.size(); i++) {
        for (int i = 0; i < compInfo.size(); i++) {
          EventSetDescriptor[] temp =
          //  ((BeanInfo) compInfoOutputs.elementAt(i)).getEventSetDescriptors();
          ((BeanInfo) compInfo.elementAt(i)).getEventSetDescriptors();

          if ((temp != null) && (temp.length > 0)) {
            esdV.add(temp);
          }
        }

        //        EventSetDescriptor [] esds = compInfo.getEventSetDescriptors();
        //        if (esds != null && esds.length > 0) {
        if (esdV.size() > 0) {
          //          beanContextMenu.insert(new JLabel("Connections",
          //                                            SwingConstants.CENTER),
          //                                 menuItemCount);
          MenuItem connections = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Connection_MenuItem_Text"));
          connections.setEnabled(false);
          beanContextMenu.insert(connections, menuItemCount);
          menuItemCount++;
        }

        //final Vector finalOutputs = outputBeans;
        final Vector finalOutputs = associatedBeans;

        for (int j = 0; j < esdV.size(); j++) {
          final int fj = j;
          String sourceBeanName = "";

          if (bc instanceof MetaBean) {
            //Object sourceBean = ((BeanInstance) outputBeans.elementAt(j)).getBean();
            Object sourceBean = ((BeanInstance) associatedBeans.elementAt(j)).getBean();
            if (sourceBean instanceof BeanCommon) {
              sourceBeanName = ((BeanCommon)sourceBean).getCustomName();
            } else {
              if (sourceBean instanceof WekaWrapper) {
                sourceBeanName = ((WekaWrapper) sourceBean).getWrappedAlgorithm()
                .getClass().getName();
              } else {
                sourceBeanName = sourceBean.getClass().getName();
              }

              sourceBeanName =
                sourceBeanName.substring(sourceBeanName.lastIndexOf('.') + 1,
                    sourceBeanName.length());
            }
            sourceBeanName += ": ";
          }

          EventSetDescriptor[] esds = (EventSetDescriptor[]) esdV.elementAt(j);

          for (int i = 0; i < esds.length; i++) {
            //    System.err.println(esds[i].getName());
            // add each event name to the menu
            //            JMenuItem evntItem = new JMenuItem(sourceBeanName
            //                                               +esds[i].getName());
            MenuItem evntItem = new MenuItem(sourceBeanName +
                                             esds[i].getName());
            final EventSetDescriptor esd = esds[i];

            // Check EventConstraints (if any) here
            boolean ok = true;

            if (bc instanceof EventConstraints) {
              ok = ((EventConstraints) bc).eventGeneratable(esd.getName());
            }

            if (ok) {
              evntItem.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                    connectComponents(esd,
                                      (bc instanceof MetaBean)
                                      ? ((BeanInstance) finalOutputs.elementAt(fj)) : bi, xx, yy);
                    notifyIsDirty();
                  }
                });
            } else {
              evntItem.setEnabled(false);
            }

            beanContextMenu.add(evntItem);
            menuItemCount++;
          }
        }
      }
    } catch (IntrospectionException ie) {
      ie.printStackTrace();
    }

    //    System.err.println("Just before look for other options");
    // now look for other options for this bean
    if (bc instanceof UserRequestAcceptor || bc instanceof Startable) {
      Enumeration req = null;
     
      if (bc instanceof UserRequestAcceptor) {
        req = ((UserRequestAcceptor) bc).enumerateRequests();
      }

      if ((bc instanceof Startable) || (req !=null && req.hasMoreElements())) {
        //  beanContextMenu.insert(new JLabel("Actions",
        //            SwingConstants.CENTER),
        //             menuItemCount);
        MenuItem actions = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DoPopup_Actions_Text"));
        actions.setEnabled(false);
        beanContextMenu.insert(actions, menuItemCount);
        menuItemCount++;
      }

      if (bc instanceof Startable) {
        String tempS = ((Startable)bc).getStartMessage();
        insertUserOrStartableMenuItem(bc, true, tempS, beanContextMenu);
      }
     
      while (req != null && req.hasMoreElements()) {
        String tempS = (String) req.nextElement();
        insertUserOrStartableMenuItem(bc, false, tempS, beanContextMenu);
        menuItemCount++;
      }
    }

    //    System.err.println("Just before showing menu");
    // popup the menu
    if (menuItemCount > 0) {
      //beanContextMenu.show(m_beanLayout, x, y);
      m_beanLayout.add(beanContextMenu);
      beanContextMenu.show(m_beanLayout, x, y);
    }
  }
View Full Code Here

Examples of java.awt.PopupMenu

    if (closestConnections.size() > 0) {
      int menuItemCount = 0;

      // modifications by Zerbetto
      //JPopupMenu deleteConnectionMenu = new JPopupMenu();
      PopupMenu deleteConnectionMenu = new PopupMenu();

      //      deleteConnectionMenu.insert(new JLabel("Delete Connection",
      //               SwingConstants.CENTER),
      //          menuItemCount);
      MenuItem deleteConnection = new MenuItem(Messages.getInstance().getString("KnowledgeFlowApp_DeleteConnectionPopup_DeleteConnection_MenuItem_Text"));
      deleteConnection.setEnabled(false);
      deleteConnectionMenu.insert(deleteConnection, menuItemCount);
      menuItemCount++;

      for (int i = 0; i < closestConnections.size(); i++) {
        final BeanConnection bc = (BeanConnection) closestConnections.elementAt(i);
        String connName = bc.getSourceEventSetDescriptor().getName();

        //JMenuItem deleteItem = new JMenuItem(connName);
        String targetName = "";
        if (bc.getTarget().getBean() instanceof BeanCommon) {
          targetName = ((BeanCommon)bc.getTarget().getBean()).getCustomName();
        } else {
          targetName = bc.getTarget().getBean().getClass().getName();
          targetName = targetName.substring(targetName.lastIndexOf('.')+1, targetName.length());
        }
        MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
        deleteItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              bc.remove();
              m_beanLayout.revalidate();
              m_beanLayout.repaint();
              notifyIsDirty();
            }
          });
        deleteConnectionMenu.add(deleteItem);
        menuItemCount++;
      }

      //deleteConnectionMenu.show(m_beanLayout, x, y);
      m_beanLayout.add(deleteConnectionMenu);
      deleteConnectionMenu.show(m_beanLayout, x, y);
    }
  }
View Full Code Here

Examples of java.awt.PopupMenu

      image = ImageIO.read(RS2Lite.class.getResourceAsStream("/icon.png"));
    } catch (IOException e1) {
      e1.printStackTrace();
    }
    // Add uploaders from the list we loaded earlier
    PopupMenu tray = new PopupMenu();
    MenuItem screenshot = new MenuItem("Screenshot");
    screenshot.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        screenshot();
      }
    });
    tray.add(screenshot);
    //Exit menu
    MenuItem exit = new MenuItem("Exit");
    exit.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        System.exit(0);
      }

    });
    tray.add(exit);
    SystemTrayAdapter adapter = SystemTrayProvider.getSystemTray();
    icon = adapter.createAndAddTrayIcon(RS2Lite.class.getResource("/icon.png"), APPLICATION_TITLE,
        tray);
   
  }
View Full Code Here

Examples of java.awt.PopupMenu

   * ϵͳ����
   */
  public void tray() {
    tray = SystemTray.getSystemTray(); // ��ñ�����ϵͳ���̵�ʵ��
    ImageIcon icon = new ImageIcon(Constants.IMAGE_ICON); // ��Ҫ��ʾ�������е�ͼ��
    PopupMenu pop = new PopupMenu(); // ����һ���Ҽ�����ʽ�˵�
    MenuItem show = new MenuItem("�򿪳���");
    MenuItem exit = new MenuItem("�˳�����");
    pop.add(show);
    pop.add(exit);
    trayIcon = new TrayIcon(icon.getImage(), Constants.TITLE, pop);

    final JDapFrame thiz = this;
    trayIcon.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent e) {// ������������������������ͼ����˫��ʱ��Ĭ����ʾ����
View Full Code Here

Examples of java.awt.PopupMenu

        SystemTray tray = SystemTray.getSystemTray();
        if (!SystemTray.isSupported()) {
            throw new RuntimeException("Tray is not supported");
        }
        trayIcon = new TrayIcon(baseImage, appName);
        final PopupMenu popup = createMenu(popupItems);
        trayIcon.setPopupMenu(popup);
        trayIcon.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
View Full Code Here

Examples of org.beryl.gui.widgets.PopupMenu

          }
        }, new MapDataModel());
        dialog.initDialog(frame);
        dialog.show();
      } else if (name.equals("popup")) {
        PopupMenu popup = (PopupMenu) constructWidget("PropertyPopup");
        popup.popup(event);
      } else if (name.equals("delete")) {
        TableRow rows[] = (TableRow[]) dataModel.getValue("property.value");
        for (int i = 0; i < rows.length; i++) {
          PropertyTableRow row = (PropertyTableRow) rows[i];
          propertyModel.removeRow(row);
View Full Code Here

Examples of org.cafesip.gwtcomp.client.ui.PopupMenu

        });
    }

    private PopupMenu createConnectorsContextMenu()
    {
        PopupMenu menu = new PopupMenu();

        HTML refresh = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/reload.png", "Refresh"));
        ClickListener listener = new ConnectorOperationListener(
                ConnectorOperationListener.CONNECTORS_REFRESH);
        refresh
                .addClickListener(new TreeContextMenuItemListener(menu,
                        listener));
        menu.addMenuItem(refresh);

        menu.addSeparator();

        HTML list = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/view_tree.png", "List Connectors")); // icon?
        listener = new ConnectorOperationListener(
                ConnectorOperationListener.CONNECTORS_LIST);
        list.addClickListener(new TreeContextMenuItemListener(menu, listener));
        menu.addMenuItem(list);

        return menu;
    }
View Full Code Here

Examples of org.cafesip.gwtcomp.client.ui.PopupMenu

        return menu;
    }

    private PopupMenu createContextsContextMenu()
    {
        PopupMenu menu = new PopupMenu();

        HTML refresh = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/reload.png", "Refresh"));
        ClickListener listener = new ContextOperationListener(
                ContextOperationListener.CONTEXTS_REFRESH);
        refresh
                .addClickListener(new TreeContextMenuItemListener(menu,
                        listener));
        menu.addMenuItem(refresh);

        HTML list = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/view_tree.png", "List Contexts"));
        listener = new ContextOperationListener(
                ContextOperationListener.CONTEXTS_LIST);
        list.addClickListener(new TreeContextMenuItemListener(menu, listener));
        menu.addMenuItem(list);

        HTML create = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/edit_add.png", "Add a Context"));
        listener = new ContextOperationListener(
                ContextOperationListener.CONTEXT_ADD);
        create
                .addClickListener(new TreeContextMenuItemListener(menu,
                        listener));
        menu.addMenuItem(create);

        return menu;
    }
View Full Code Here

Examples of org.cafesip.gwtcomp.client.ui.PopupMenu

    }

    private PopupMenu createContextContextMenu(String contextName,
            SuperTreeItem contextItem)
    {
        PopupMenu menu = new PopupMenu();

        HTML refresh = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/reload.png", "Refresh"));
        ClickListener listener = new ContextOperationListener(
                ContextOperationListener.CONTEXT_JIPLETS_REFRESH, contextName,
                contextItem);
        refresh
                .addClickListener(new TreeContextMenuItemListener(menu,
                        listener));
        menu.addMenuItem(refresh);

        HTML view = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/view_detailed.png", "View Properties"));
        listener = new ContextOperationListener(
                ContextOperationListener.CONTEXT_VIEW_PROPERTIES, contextName);
        view.addClickListener(new TreeContextMenuItemListener(menu, listener));
        menu.addMenuItem(view);

        HTML delete = new HTML(HTMLHelper.imageWithText(GWT.getModuleBaseURL()
                + "gwtcomp-icons/editdelete.png", "Remove the Context"));
        listener = new ContextOperationListener(
                ContextOperationListener.CONTEXT_DELETE, contextName);
        delete
                .addClickListener(new TreeContextMenuItemListener(menu,
                        listener));
        menu.addMenuItem(delete);

        return menu;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.