Package java.awt

Examples of java.awt.MenuItem$State


    }

    final String tempS2 = tempS;

    //      JMenuItem custItem = new JMenuItem(tempS2);
    MenuItem custItem = new MenuItem(tempS2);
    if (confirmRequest) {
      custItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          //
          int result = JOptionPane.showConfirmDialog(KnowledgeFlowApp.this,
              tempS2,
              "Confirm action",
              JOptionPane.YES_NO_OPTION);
          if (result == JOptionPane.YES_OPTION) {
            Thread startPointThread = new Thread() {
              public void run() {
                try {
                  if (startable) {
                    ((Startable)bc).start();                   
                  } else if (bc instanceof UserRequestAcceptor) {
                    ((UserRequestAcceptor) bc).performRequest(tempS2);
                  }
                  notifyIsDirty();
                } catch (Exception ex) {
                  ex.printStackTrace();
                }
              }
            };
            startPointThread.setPriority(Thread.MIN_PRIORITY);
            startPointThread.start();
          }
        }
      });
    } else {
      custItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          Thread startPointThread = new Thread() {
            public void run() {
              try {
                if (startable) {
                  ((Startable)bc).start();                 
                } else if (bc instanceof UserRequestAcceptor) {
                  ((UserRequestAcceptor) bc).performRequest(tempS2);
                }
                notifyIsDirty();
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
          };
          startPointThread.setPriority(Thread.MIN_PRIORITY);
          startPointThread.start();
        }
      });
    }

    if (disabled) {
      custItem.setEnabled(false);
    }

    beanContextMenu.add(custItem);
  }
View Full Code Here


        closestConnections.size() > 0 ||
        (m_pasteBuffer != null && m_pasteBuffer.length() > 0)) {

      if (m_mainKFPerspective.getSelectedBeans().size() > 0) {

        MenuItem snapItem = new MenuItem("Snap selected to grid");
        snapItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            snapSelectedToGrid();
          }
        });
        rightClickMenu.add(snapItem);
        menuItemCount++;

        MenuItem copyItem = new MenuItem("Copy selected");
        copyItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            copyToClipboard();
            m_mainKFPerspective.setSelectedBeans(new Vector());
          }
        });
        rightClickMenu.add(copyItem);
        menuItemCount++;

        MenuItem cutItem = new MenuItem("Cut selected");
        cutItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // only delete if our copy was successful!
            if (copyToClipboard()) {             
              deleteSelectedBeans();
            }
          }
        });
        rightClickMenu.add(cutItem);
        menuItemCount++;

        MenuItem deleteSelected = new MenuItem("Delete selected");
        deleteSelected.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            deleteSelectedBeans();
          }
        });
        rightClickMenu.add(deleteSelected);
        menuItemCount++;

        // Able to group selected subflow?
        boolean groupable = true;
        final Vector selected = m_mainKFPerspective.getSelectedBeans();
        // check if sub flow is valid
        final Vector inputs = BeanConnection.inputs(selected,
            m_mainKFPerspective.getCurrentTabIndex());
        final Vector outputs = BeanConnection.outputs(selected,
            m_mainKFPerspective.getCurrentTabIndex());

        // screen the inputs and outputs
        if (inputs.size() == 0 || outputs.size() == 0) {
          groupable = false;
        }

        // dissallow MetaBeans in the selected set (for the
        // time being).
        if (groupable) {
          for (int i = 0; i < selected.size(); i++) {
            BeanInstance temp = (BeanInstance)selected.elementAt(i);
            if (temp.getBean() instanceof MetaBean) {
              groupable = false;
              break;
            }
          }
        }

        if (groupable) {
          // show connector dots for input beans
          for (int i = 0; i < inputs.size(); i++) {
            BeanInstance temp = (BeanInstance)inputs.elementAt(i);
            if (temp.getBean() instanceof Visible) {
              ((Visible)temp.getBean()).getVisual().
              setDisplayConnectors(true, java.awt.Color.red);
            }
          }

          // show connector dots for output beans
          for (int i = 0; i < outputs.size(); i++) {
            BeanInstance temp = (BeanInstance)outputs.elementAt(i);
            if (temp.getBean() instanceof Visible) {
              ((Visible)temp.getBean()).getVisual().
              setDisplayConnectors(true, java.awt.Color.green);
            }
          }

          MenuItem groupItem = new MenuItem("Group selected");
          groupItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              groupSubFlow(selected, inputs, outputs);
            }
          });
          rightClickMenu.add(groupItem);
          menuItemCount++;
        }                       
      }     

      if (m_pasteBuffer != null && m_pasteBuffer.length() > 0) {
        rightClickMenu.addSeparator();
        menuItemCount++;

        MenuItem pasteItem = new MenuItem("Paste");
        pasteItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // deserialize, integerate and
            // position at x, y

            pasteFromClipboard(x, y, m_pasteBuffer, true);
          }       
        });
        rightClickMenu.add(pasteItem);
        menuItemCount++;
      }


      if (closestConnections.size() > 0) {
        rightClickMenu.addSeparator();
        menuItemCount++;

        MenuItem deleteConnection = new MenuItem("Delete Connection:");
        deleteConnection.setEnabled(false);
        rightClickMenu.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) {
              addUndoPoint();

              bc.remove(m_mainKFPerspective.getCurrentTabIndex());
              m_beanLayout.revalidate();
              m_beanLayout.repaint();
              m_mainKFPerspective.setEditedStatus(true);
              if (m_mainKFPerspective.getSelectedBeans().size() > 0) {
                m_mainKFPerspective.setSelectedBeans(new Vector());
              }               
              notifyIsDirty();
            }
          });
          rightClickMenu.add(deleteItem);
          menuItemCount++;
        }
      }           
    }

    if (menuItemCount > 0) {
      rightClickMenu.addSeparator();
      menuItemCount++;
    }

    MenuItem noteItem = new MenuItem("New note");
    noteItem.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {

        Note n = new Note();
        m_toolBarBean = n;
View Full Code Here

      PopupMenu deleteConnectionMenu = new PopupMenu();

      //      deleteConnectionMenu.insert(new JLabel("Delete Connection",
      //               SwingConstants.CENTER),
      //          menuItemCount);
      MenuItem deleteConnection = new MenuItem("Delete Connection:");
      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_mainKFPerspective.getCurrentTabIndex());
            m_beanLayout.revalidate();
            m_beanLayout.repaint();
            m_mainKFPerspective.setEditedStatus(true);
View Full Code Here

            boolean supported = (Boolean) Utils.callStaticMethod("java.awt.SystemTray.isSupported");
            if (!supported) {
                return false;
            }
            PopupMenu menuConsole = new PopupMenu();
            MenuItem itemConsole = new MenuItem("H2 Console");
            itemConsole.setActionCommand("console");
            itemConsole.addActionListener(this);
            itemConsole.setFont(font);
            menuConsole.add(itemConsole);
            MenuItem itemStatus = new MenuItem("Status");
            itemStatus.setActionCommand("status");
            itemStatus.addActionListener(this);
            itemStatus.setFont(font);
            menuConsole.add(itemStatus);
            MenuItem itemExit = new MenuItem("Exit");
            itemExit.setFont(font);
            itemExit.setActionCommand("exit");
            itemExit.addActionListener(this);
            menuConsole.add(itemExit);

            // tray = SystemTray.getSystemTray();
            tray = Utils.callStaticMethod("java.awt.SystemTray.getSystemTray");
View Full Code Here

    //       Otherwise a UnsatisfiedLinkError will raise on linux systems
    SystemTray tray = SystemTray.getSystemTray();
    Image icon = loadImageFromClasspath("net/sf/regain/ui/desktop/regain_icon_16.gif");

    PopupMenu menu = new PopupMenu();
    MenuItem item;

    item = new MenuItem(localizer.msg("search", "Search"));
    item.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("searchinput.jsp");
      }
    });
    menu.add(item);

    item = new MenuItem(localizer.msg("status", "Status"));
    item.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("status.jsp");
      }
    });
    menu.add(item);

    item = new MenuItem(localizer.msg("config", "Preferences"));
    item.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent evt) {
        DesktopToolkit.openPageInBrowser("config.jsp");
      }
    });
    menu.add(item);

    menu.addSeparator();

    item = new MenuItem(localizer.msg("exit", "Exit"));
    item.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent evt) {
        Main.quit();
      }
View Full Code Here

    menuFile.setLabel("File");
    menuBar.add(menuFile);
   
    // File>Open File
    {
      final MenuItem menuItemOpenFile = new MenuItem("Open File...");
      menuItemOpenFile.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onOpenFile();
            }
          }
        );
      menuFile.add(menuItemOpenFile);
    }

    // File>Open URL
    {
      final MenuItem menuItemOpenURL = new MenuItem("Open URL...");
      menuItemOpenURL.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onOpenURL();
            }
          }
        );
      menuFile.add(menuItemOpenURL);
    }
   
    // File>Open RTP Session
    {
      final MenuItem menuItemReceiveRTP = new MenuItem("Open RTP Session...");
      menuItemReceiveRTP.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onReceiveRTP();
            }
          }
        );
      menuFile.add(menuItemReceiveRTP);
    }
   
    // File>Capture
    {
      final MenuItem menuItemOpenCaptureDevice = new MenuItem("Capture...");
      menuItemOpenCaptureDevice.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onOpenCaptureDevice();
            }
          }
        );
      menuFile.add(menuItemOpenCaptureDevice);
    }
   

    // separator
    menuFile.addSeparator();

    // TODO: export

    // File>Transmit RTP
    {
      final MenuItem menuItemTransmitRTP = new MenuItem("Transmit RTP...");
      menuItemTransmitRTP.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onTransmitRTP();
            }
          }
        );
      menuFile.add(menuItemTransmitRTP);
    }

    // File>Transcode
    {
      final MenuItem menuItemTranscode = new MenuItem("Transcode...");
      menuItemTranscode.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              playerPanel.onTranscode();
            }
          }
        );
      menuFile.add(menuItemTranscode);
    }
   
    // separator
    menuFile.addSeparator();
   
    // File>Registry Editor
    {
      final MenuItem menuItemRegistryEditor = new MenuItem("Registry Editor...");
      menuItemRegistryEditor.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              onOpenRegistryEditor();
            }
          }
        );
      menuFile.add(menuItemRegistryEditor);
    }
   
    // File>Exit
    {
      final MenuItem menuItemExit = new MenuItem("Exit");
      menuItemExit.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              onExit();
            }
          }
        );
      menuFile.add(menuItemExit);
    }
   
   
    final Menu menuPlayer = new Menu();
    menuPlayer.setLabel("Player");
    menuBar.add(menuPlayer);
   
    // Player>Auto-play
    {
      final CheckboxMenuItem menuItemAutoPlay = new CheckboxMenuItem("Auto-play");
      menuItemAutoPlay.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e)
        {
          playerPanel.onAutoPlay(menuItemAutoPlay.getState());
        }
       
      });

      menuPlayer.add(menuItemAutoPlay);
      menuItemAutoPlay.setState(playerPanel.getPrefs().autoPlay);
    }
   
    // Player>Auto-loop
    {
      final CheckboxMenuItem menuItemAutoLoop = new CheckboxMenuItem("Auto-loop");
      menuItemAutoLoop.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e)
        {
          playerPanel.onAutoLoop(menuItemAutoLoop.getState());
        }
       
      });
      menuPlayer.add(menuItemAutoLoop);
      playerPanel.onAutoLoop(false);   // TODO: not working right yet.
      menuItemAutoLoop.setState(playerPanel.getPrefs().autoLoop);
      menuItemAutoLoop.setEnabled(false)// TODO: not working right yet.
     

    }

   
    final Menu menuHelp = new Menu();
    menuHelp.setLabel("Help");
    menuBar.add(menuHelp);
   
    // Help>About
    {
      final MenuItem menuItemHelpAbout = new MenuItem("About...");
      menuItemHelpAbout.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              AboutPanel.run(frame);
            }
          }
View Full Code Here

        System.exit(0);
    }
      }
  };

  MenuItem item;
  MenuBar mb = new MenuBar();
  // File Menu
  Menu mnFile = new Menu("File");
  mnFile.add(item = new MenuItem("Open"));
  item.addActionListener(al);
  mnFile.add(item = new MenuItem("Exit"));
  item.addActionListener(al);

  // Options Menu 
  Menu mnOptions = new Menu("Options");
  cbAutoLoop = new CheckboxMenuItem("Auto replay");
  cbAutoLoop.setState(true);
View Full Code Here

 
  private void initializeSystemTray()  {
    tray = new FaxTray();
   
    if (tray.isSupported()) {
      tray.getPopupMenu().add(new MenuItem((String) exitAction.getValue(Action.NAME)));
    }
  }
View Full Code Here

     * @see com.adito.agent.client.AgentClientGUI#init(com.adito.agent.client.Agent)
     */
    public void init(Agent agent) {
        super.init(agent);

        MenuItem open = new MenuItem(Messages.getString("GUI.menu.openBrowser")); //$NON-NLS-1$
        open.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                openBrowser(null);
            }
        });

        // #ifdef DEBUG
        MenuItem console = new MenuItem(Messages.getString("GUI.menu.debugConsole")); //$NON-NLS-1$
        console.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                getConsole().show();
            }
        });
        // #endif

        MenuItem ports = new MenuItem(Messages.getString("GUI.menu.tunnelMonitor")); //$NON-NLS-1$
        ports.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                getPortMonitor().setVisible(!getPortMonitor().isVisible());
            }
        });

        MenuItem exit = new MenuItem(Messages.getString("GUI.menu.exit")); //$NON-NLS-1$
        exit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                getAgent().disconnect();
            }
        });

View Full Code Here

    public void addMenuItem(final String parentName, final AgentAction action) {
     
      Menu menu = parentName == null ? file : (Menu) menuLookup.get(parentName);
        if(menu==null)
          return;
        MenuItem item = new MenuItem(action.getAction());
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                action.actionPerformed();
            }
        });
        menu.add(item);
View Full Code Here

TOP

Related Classes of java.awt.MenuItem$State

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.