Example #1
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     profiles.delete(name);
   }
 }
Example #2
0
 private void addProfiles(JMenu menu, String[] profileNames, ActionListener listener) {
   for (int i = 0; i < profileNames.length; i++) {
     JMenuItem item = new JMenuItem(profileNames[i]);
     item.addActionListener(listener);
     menu.add(item);
   }
 }
Example #3
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     Profile profile = profiles.getProfile(name);
     Component[] components = selectorPanel.getComponents();
     for (int i = 0; i < components.length; i++) {
       Component comp = components[i];
       if (comp instanceof CPCheckBox) {
         CPCheckBox scb = (CPCheckBox) comp;
         String id = scb.element.id;
         boolean enb = profile.has(id);
         scb.setState(enb);
       }
     }
   }
 }
Example #4
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() instanceof JMenuItem) {
     JMenuItem item = (JMenuItem) e.getSource();
     String name = item.getText();
     if (name.equals("New...")) {
       name = JOptionPane.showInputDialog(selectorPanel, "Enter a name for the new profile.");
     }
     if ((name == null) || name.trim().equals("")) return;
     Profile profile = new Profile(name);
     Component[] components = selectorPanel.getComponents();
     for (int i = 0; i < components.length; i++) {
       Component comp = components[i];
       if (comp instanceof CPCheckBox) {
         CPCheckBox scb = (CPCheckBox) comp;
         String id = scb.element.id;
         if (scb.isSelected()) profile.add(id);
       }
     }
     profiles.add(profile);
   }
 }
Example #5
0
    public Popup() {
      super();
      String[] profileNames = profiles.getNames();
      JMenuItem item;

      // Make the load menu
      JMenu loadMenu = new JMenu("Load profile");
      loadMenu.setEnabled(profiles.size() > 0);
      addProfiles(loadMenu, profileNames, profileLoader);
      this.add(loadMenu);
      this.addSeparator();

      // put in a dummy item
      item = new JMenuItem();
      item.setEnabled(false);
      this.add(item);
      this.addSeparator();

      // Make the save menu
      JMenu saveMenu = new JMenu("Save profile");
      item = new JMenuItem("New...");
      item.addActionListener(profileSaver);
      saveMenu.add(item);
      saveMenu.addSeparator();
      addProfiles(saveMenu, profileNames, profileSaver);
      this.add(saveMenu);
      this.addSeparator();

      // put in a dummy item
      item = new JMenuItem();
      item.setEnabled(false);
      this.add(item);
      this.addSeparator();

      // Make the delete menu
      JMenu deleteMenu = new JMenu("Delete profile");
      deleteMenu.setEnabled(profiles.size() > 0);
      addProfiles(deleteMenu, profileNames, profileDeleter);
      this.add(deleteMenu);
    }