void windowMenu_menuSelected(MenuEvent e) {
    // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes
    // the Window
    // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon
    // Aquino]
    if (windowMenu.getItemCount() > 0
        && windowMenu.getItem(0) != null
        && windowMenu
            .getItem(0)
            .getText()
            .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) {
      JMenuItem newWindowMenuItem = windowMenu.getItem(0);
      windowMenu.removeAll();
      windowMenu.add(newWindowMenuItem);
      windowMenu.addSeparator();
    } else {
      // ezLink doesn't have a Clone Window menu [Jon Aquino]
      windowMenu.removeAll();
    }

    // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames();
    final JInternalFrame[] frames = desktopPane.getAllFrames();
    for (int i = 0; i < frames.length; i++) {
      JMenuItem menuItem = new JMenuItem();
      // Increase truncation threshold from 20 to 40, for eziLink [Jon
      // Aquino]
      menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40));
      associate(menuItem, frames[i]);
      windowMenu.add(menuItem);
    }
    if (windowMenu.getItemCount() == 0) {
      // For ezLink [Jon Aquino]
      windowMenu.add(new JMenuItem("(No Windows)"));
    }
  }
Beispiel #2
0
 public void updateMidiInMenuOptions(String[] midiInOptions) {
   midiInMenu.removeAll();
   pageChangeMidiInMenu.removeAll();
   for (int i = 0; i < midiInOptions.length; i++) {
     midiInMenu.remove(getNoInputDevicesEnabledItem());
     pageChangeMidiInMenu.remove(getNoInputDevicesEnabledItem2());
     JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem("MIDI Input: " + midiInOptions[i]);
     JCheckBoxMenuItem cbMenuItem2 = new JCheckBoxMenuItem("MIDI Input: " + midiInOptions[i]);
     cbMenuItem.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             String[] pieces = e.getActionCommand().split("MIDI Input: ");
             actionToggleMidiInput(pieces[1]);
           }
         });
     cbMenuItem2.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             String[] pieces = e.getActionCommand().split("MIDI Input: ");
             actionTogglePageChangeMidiInput(pieces[1]);
           }
         });
     midiInMenu.add(cbMenuItem);
     pageChangeMidiInMenu.add(cbMenuItem2);
   }
   if (midiInMenu.getItemCount() == 0) {
     midiInMenu.add(getNoInputDevicesEnabledItem());
     pageChangeMidiInMenu.add(getNoInputDevicesEnabledItem2());
   }
 }
Beispiel #3
0
  /**
   * initialize the symbols menu
   *
   * @param m menu
   */
  public void initSymbolsMenu(JMenu m) {
    m.removeAll();
    for (int i = 0; i < glyphs.size(); i++) {
      final MetSymbol metSymbol = (MetSymbol) glyphs.get(i);
      JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol);
      mi.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseReleased(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseEntered(MouseEvent e) {
              highlightedMetSymbol = metSymbol;
              StationModelCanvas.this.repaint();
            }

            public void mouseExited(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }
          });
      m.add(mi);
    }
  }
  /** Create the menu holding the currently available stencil sets. */
  public void createStencilMenu() {

    if (mnuStencils == null) {
      return;
    }

    Vector vtStencils = ProjectCompendium.APP.oStencilManager.getStencilNames();
    vtStencils = CoreUtilities.sortList(vtStencils);

    mnuStencils.removeAll();
    int count = vtStencils.size();
    for (int i = 0; i < count; i++) {
      final String sName = (String) vtStencils.elementAt(i);

      JMenuItem item = new JMenuItem(sName);
      ActionListener oAction =
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              ProjectCompendium.APP.oStencilManager.openStencilSet(sName);
            }
          };
      item.addActionListener(oAction);

      mnuStencils.add(item);
    }
  }
 /** Populate recent bookmarks. */
 public void populateRecentBookmarks() {
   JMenu bookmarksMenu = this.recentBookmarksMenu;
   bookmarksMenu.removeAll();
   Collection<HistoryEntry<BookmarkInfo>> historyEntries =
       BookmarksHistory.getInstance().getRecentEntries(PREFERRED_MAX_MENU_SIZE);
   for (HistoryEntry<BookmarkInfo> hentry : historyEntries) {
     BookmarkInfo binfo = hentry.getItemInfo();
     String text = binfo.getTitle();
     URL url = binfo.getUrl();
     String urlText = url.toExternalForm();
     if ((text == null) || (text.length() == 0)) {
       text = urlText;
     }
     long elapsed = System.currentTimeMillis() - hentry.getTimetstamp();
     text = text + " (" + Timing.getElapsedText(elapsed) + " ago)";
     Action action = this.actionPool.createBookmarkNavigateAction(url);
     JMenuItem menuItem = ComponentSource.menuItem(text, action);
     StringBuffer toolTipText = new StringBuffer();
     toolTipText.append("<html>");
     toolTipText.append(urlText);
     String description = binfo.getDescription();
     if ((description != null) && (description.length() != 0)) {
       toolTipText.append("<br>");
       toolTipText.append(description);
     }
     menuItem.setToolTipText(toolTipText.toString());
     bookmarksMenu.add(menuItem);
   }
 }
  /** Populate searchers. */
  private void populateSearchers() {
    JMenu searchersMenu = this.searchersMenu;
    searchersMenu.removeAll();
    final ToolsSettings settings = ToolsSettings.getInstance();
    Collection<SearchEngine> searchEngines = settings.getSearchEngines();
    SearchEngine selectedEngine = settings.getSelectedSearchEngine();
    if (searchEngines != null) {
      for (SearchEngine se : searchEngines) {
        final SearchEngine finalSe = se;
        JRadioButtonMenuItem item = new JRadioButtonMenuItem();
        item.setAction(
            new AbstractAction() {

              private static final long serialVersionUID = 1L;

              @Override
              public void actionPerformed(ActionEvent e) {
                settings.setSelectedSearchEngine(finalSe);
                settings.save();
                ComponentSource.this.updateSearchButtonTooltip();
              }
            });
        item.setSelected(se == selectedEngine);
        item.setText(se.getName());
        item.setToolTipText(se.getDescription());
        searchersMenu.add(item);
      }
    }
  }
Beispiel #7
0
 public JMenu fillMenu(JMenu menu) {
   menu.removeAll();
   for (int i = 0; i < itemList.size(); i++) {
     menu.add(itemList.get(i));
   }
   return menu;
 }
Beispiel #8
0
  private void updateTabsMenu() {
    tabsMenu.removeAll();

    for (JMenuItem mi : miList) {
      A4n.MoveChannelsTo a = (A4n.MoveChannelsTo) mi.getAction();
      if (!a.getChannelsPane().equals(getSelectedChannelsPane())) tabsMenu.add(mi);
    }
  }
Beispiel #9
0
 /** Override JMoreMenu removeAll. Automatically take "more>" structure into account. */
 public void removeAll() {
   if (moreMenu != null) {
     moreMenu.removeAll();
     super.remove(moreMenu);
     moreMenu = null;
   }
   super.removeAll();
   myHeight = 0;
 }
Beispiel #10
0
  private void restartUI() {
    themeList.clear();
    themesMenu.removeAll();

    lfButtonGroup = null;
    themesMenu = null;

    UIApplication.restartUI();
  }
 private void resetMarks() {
   interpToMark.removeAll();
   shiftToMark.removeAll();
   Iterator marks = mediator.getMarkerModel().getLabels().iterator();
   boolean hasMark = false;
   while (marks.hasNext()) {
     String mark = (String) marks.next();
     if (!ChronicleViewer.CURR_FRAME_LABEL.equals(mark)) {
       JMenuItem mi = new JMenuItem(mark);
       mi.addActionListener(itmAction);
       interpToMark.add(mi);
       mi = new JMenuItem(mark);
       mi.addActionListener(stmAction);
       shiftToMark.add(mi);
       hasMark = true;
     }
   }
   shiftToMark.setEnabled(hasMark);
   interpToMark.setEnabled(hasMark);
 }
Beispiel #12
0
  public void makeRecentMenu() {
    recentMenu.removeAll();
    for (File f : recentFiles) {
      Debug.println(f);
      if (!f.exists()) {
        if (MainFrame.GUI2_DEBUG)
          System.err.println("a recent project was not found, removing it from menu");
        continue;
      }

      recentMenu.add(MainFrame.getInstance().createRecentItem(f, SaveType.forFile(f)));
    }
  }
Beispiel #13
0
  protected void updateRecentScriptsMenu() {
    while (recentScripts.size() > ClassicPrefs.getRecentScriptsSize()) {
      recentScripts.removeElementAt(recentScripts.size() - 1);
    }

    recentScriptsMenu.removeAll();

    for (String script : recentScripts) {
      JMenuItem mi = new JMenuItem(script);
      recentScriptsMenu.add(mi);
      mi.addActionListener(new RecentScriptHandler(script));
    }

    recentScriptsMenu.setEnabled(recentScripts.size() != 0);
  }
Beispiel #14
0
 /** Make the view menu */
 private void makeStationModelMenu() {
   stationModelMenu.removeAll();
   List symbols = smm.getResources();
   List items = new ArrayList();
   ObjectListener listener =
       new ObjectListener(null) {
         public void actionPerformed(ActionEvent ae) {
           if (!okToChange()) {
             return;
           }
           setStationModel((StationModel) theObject, true);
         }
       };
   GuiUtils.makeMenu(stationModelMenu, makeStationModelMenuItems(symbols, listener, smm));
 }
  /** Update favorite menu with resource. */
  public void updateFavoriteMenu() {
    final Vector favorites = resource.getFavorites();
    favoriteItems = new JMenuItem[favorites.size()];

    historyMenu.removeAll();

    // 顯示目前我的最愛內容
    for (int i = 0; i < favorites.size(); i++) {
      final Site fa = (Site) favorites.elementAt(i);
      favoriteItems[i] = new JMenuItem(fa.getName());
      favoriteItems[i].setToolTipText(fa.getHost() + ":" + fa.getPort()); // $NON-NLS-1$
      favoriteItems[i].addActionListener(actionController);
      historyMenu.add(favoriteItems[i]);
    }
  }
Beispiel #16
0
  public void refreshSerialPortList() {

    String[] serialPortList = SerialPortList.getPortNames();

    portMenu.removeAll();

    portMenu.add(refreshItem);

    JMenuItem menuItem;
    for (String serialPort : serialPortList) {

      menuItem = new JMenuItem(serialPort);
      menuItem.addActionListener(e -> onSerialPortClicked(e.getActionCommand()));
      portMenu.add(menuItem);
    }
  }
Beispiel #17
0
 /** Make the file menu */
 private void makeFileMenu() {
   fileMenu.removeAll();
   fileMenu.add(makeMenuItem("New", 'n', GuiUtils.CMD_NEW));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Save", 's', GuiUtils.CMD_SAVE));
   fileMenu.add(makeMenuItem("Save As...", GuiUtils.CMD_SAVEAS));
   fileMenu.add(makeMenuItem("Rename...", GuiUtils.CMD_RENAME));
   fileMenu.addSeparator();
   JMenuItem removeMenuItem = makeMenuItem("Remove", GuiUtils.CMD_REMOVE);
   removeMenuItem.setEnabled(smm.isUsers(stationModel));
   fileMenu.add(removeMenuItem);
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Import...", GuiUtils.CMD_IMPORT));
   fileMenu.add(makeMenuItem("Export...", GuiUtils.CMD_EXPORT));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Close", GuiUtils.CMD_CLOSE));
 }
 /** Populate forward more. */
 public void populateForwardMore() {
   NavigationEntry[] entries = this.window.getForwardNavigationEntries();
   JMenu forwardMoreMenu = this.forwardMoreMenu;
   forwardMoreMenu.removeAll();
   for (NavigationEntry entry : entries) {
     String method = entry.getMethod();
     if ("GET".equals(method)) {
       String title = entry.getTitle();
       URL url = entry.getUrl();
       String text = (title == null) || (title.length() == 0) ? url.toExternalForm() : title;
       Action action = this.actionPool.createGoToAction(entry);
       JMenuItem menuItem = menuItem(text, action);
       menuItem.setToolTipText(url.toExternalForm());
       forwardMoreMenu.add(menuItem);
     }
   }
 }
Beispiel #19
0
 public void updateShowPageMenuItems(String[] pages) {
   showPageMenu.removeAll();
   for (int i = 0; i < pages.length; i++) {
     JMenuItem pageItem = new JMenuItem("" + (i + 1) + ": " + pages[i]);
     pageItem.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             String[] pieces = e.getActionCommand().split(":");
             int pageIndex = Integer.parseInt(pieces[0]) - 1;
             MonomeConfiguration monomeConfig =
                 MonomeConfigurationFactory.getMonomeConfiguration(index);
             monomeConfig.switchPage(monomeConfig.pages.get(pageIndex), pageIndex, true);
           }
         });
     showPageMenu.add(pageItem);
   }
 }
Beispiel #20
0
 public void loadProtocols() {
   _protocolMenu.removeAll();
   for (Protocol proto : ProtocolManager.getInstance().getProtocols()) {
     JMenuItem protoButton = new JMenuItem(proto.getName() + " (" + proto.getPort() + ")");
     protoButton.setActionCommand("p:" + proto.getName());
     protoButton.addActionListener(_pel);
     _protocolMenu.add(protoButton);
   }
   JMenuItem newProtoButton = new JMenuItem("New Protocol...");
   newProtoButton.setActionCommand("new");
   newProtoButton.addActionListener(_pel);
   _protocolMenu.addSeparator();
   _protocolMenu.add(newProtoButton);
   if (!ProtocolManager.getInstance().getProtocols().isEmpty())
     switchToProtocol(ProtocolManager.getInstance().getProtocols().iterator().next());
   else switchToProtocol(null);
 }
  /**
   * Creates an {@link OtrContactMenu} for each {@link Contact} contained in the
   * <tt>metaContact</tt>.
   *
   * @param metaContact The {@link MetaContact} this {@link OtrMetaContactMenu} refers to.
   */
  private void createOtrContactMenus(MetaContact metaContact) {
    JMenu menu = getMenu();

    // Remove any existing OtrContactMenu items.
    menu.removeAll();

    // Create the new OtrContactMenu items.
    if (metaContact != null) {
      Iterator<Contact> contacts = metaContact.getContacts();

      if (metaContact.getContactCount() == 1) {
        new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, false);
      } else
        while (contacts.hasNext()) {
          new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, true);
        }
    }
  }
 /** Populate tagged bookmarks. */
 public void populateTaggedBookmarks() {
   JMenu bookmarksMenu = this.taggedBookmarksMenu;
   bookmarksMenu.removeAll();
   Collection<BookmarkInfo> bookmarkInfoList =
       BookmarksHistory.getInstance()
           .getRecentItemInfo(PREFERRED_MAX_MENU_SIZE * PREFERRED_MAX_MENU_SIZE);
   Map<String, JMenu> tagMenus = new HashMap<String, JMenu>();
   for (BookmarkInfo binfo : bookmarkInfoList) {
     URL url = binfo.getUrl();
     String urlText = url.toExternalForm();
     String[] tags = binfo.getTags();
     if (tags != null) {
       for (String tag : tags) {
         JMenu tagMenu = tagMenus.get(tag);
         if (tagMenu == null) {
           if (tagMenus.size() < PREFERRED_MAX_MENU_SIZE) {
             tagMenu = new JMenu(tag);
             tagMenus.put(tag, tagMenu);
             bookmarksMenu.add(tagMenu);
           }
         }
         if ((tagMenu != null) && (tagMenu.getItemCount() < PREFERRED_MAX_MENU_SIZE)) {
           String text = binfo.getTitle();
           if ((text == null) || (text.length() == 0)) {
             text = urlText;
           }
           Action action = this.actionPool.createBookmarkNavigateAction(url);
           JMenuItem menuItem = ComponentSource.menuItem(text, action);
           StringBuffer toolTipText = new StringBuffer();
           toolTipText.append("<html>");
           toolTipText.append(urlText);
           String description = binfo.getDescription();
           if ((description != null) && (description.length() != 0)) {
             toolTipText.append("<br>");
             toolTipText.append(description);
           }
           menuItem.setToolTipText(toolTipText.toString());
           tagMenu.add(menuItem);
         }
       }
     }
   }
 }
    public void majContenuMenu() {
      ElementPresentation ep = lnkPanneauDetail.get_elementCourant();

      jMenuSupprimerContenu.setVisible(true);
      if (ep != null && ep.getContenu() == null) {
        jMenuAjouterContenu.setVisible(true);
        jMenuChangerContenu.setVisible(false);
        jMenuSupprimerContenu.setEnabled(false);
      } else {
        jMenuAjouterContenu.setVisible(false);
        jMenuChangerContenu.setVisible(true);
        jMenuSupprimerContenu.setEnabled(true);
      }

      if (_dernierPanneau.equals("DGuide")) {
        jMenuAjouterGuide.setVisible(false);
        jMenuSupprimer.setVisible(true);
      } else {
        jMenuAjouterGuide.setVisible(true);
        jMenuSupprimer.setVisible(
            _dernierPanneau.equals("DElementPresentation")
                && !ep.get_id()
                    .equals(
                        getLnkSysteme()
                            .getlnkControleurPresentation()
                            .getlnkPresentation()
                            .getIdRacine()));
      }

      jMenuAjouterGuide.removeAll();
      if (ep != null) {
        Iterator vTypes =
            this.lnkControleurPanneaux.getLnkSysteme().getLnkControleurGuide().types();
        while (vTypes.hasNext()) {
          String value = (String) vTypes.next();
          JMenuItem mi = new JMenuItem(value);
          mi.addActionListener(
              new listenerSousMenusGuides(value, lnkPanneauDetail, this.lnkControleurPanneaux));
          jMenuAjouterGuide.add(mi);
        }
      }
    }
Beispiel #24
0
  public void chargerLaf() {
    MD_Laf.removeAll();
    // Groupe
    SC_RadioLaf = new ButtonGroup();

    // Look And Feel
    for (int i = 0; i < UIManager.getInstalledLookAndFeels().length; i++) {
      // Création d'un bouton radio
      JRadioButtonMenuItem OO_LookAndFeel =
          new JRadioButtonMenuItem(UIManager.getInstalledLookAndFeels()[i].getName());
      // Ajout au groupe
      SC_RadioLaf.add(OO_LookAndFeel);
      // Ajout du listener
      OO_LookAndFeel.addActionListener(actionLaf);
      // Si le look and feel courant correspond à l'élément
      if (OO_LookAndFeel.getText().equals(UIManager.getLookAndFeel().getName()))
        OO_LookAndFeel.setSelected(true);
      // Ajout au panel
      MD_Laf.add(OO_LookAndFeel);
    }
  }
Beispiel #25
0
 protected JMenu buildPlanSeqViewMenu(PwProject project, JMenu planSeqViewMenu) {
   if (planSeqViewMenu == null) {
     planSeqViewMenu = new JMenu(PLANSEQ_MENU);
   }
   planSeqViewMenu.removeAll();
   sequenceNameMap = new HashMap();
   // System.err.println( "buildPlanSeqViewMenu");
   List planSeqNames = project.listPlanningSequences();
   Collections.sort(planSeqNames, new SeqNameComparator());
   Iterator seqUrlsItr = planSeqNames.iterator();
   while (seqUrlsItr.hasNext()) {
     String seqUrl = (String) seqUrlsItr.next();
     String seqName = getSequenceMenuItemName(Utilities.getUrlLeaf(seqUrl), planSeqViewMenu);
     // System.err.println( "  sequenceName " + seqName);
     sequenceNameMap.put(seqUrl, seqName);
     JMenu seqMenu = new JMenu(seqName);
     planSeqViewMenu.add(seqMenu);
     buildSequenceViewSubMenu(seqMenu, seqUrl, seqName);
   }
   return planSeqViewMenu;
 } // end buildPlanSeqViewMenu
Beispiel #26
0
 public void chargerLangue() {
   MD_Langue.removeAll();
   // Groupe
   SC_Radios = new ButtonGroup();
   // Radios langue
   for (int i = 0; i < Bundle.getLanguesDisponibles().size(); i++) {
     // Récupération de la première des langues disponibles
     String langue = Bundle.getLanguesDisponibles().elementAt(i).toString();
     // Récupération de la langue courante
     String langueCourante = Bundle.getLangueCourante();
     // Création d'un bouton radio
     JRadioButtonMenuItem OO_Langue = new JRadioButtonMenuItem(langue);
     // Ajout au groupe
     SC_Radios.add(OO_Langue);
     // Ajout du listener
     OO_Langue.addActionListener(actionLangue);
     // Si la langue courante correspond à l'élément
     if (langueCourante.equals(langue)) OO_Langue.setSelected(true);
     // Ajout au panel
     MD_Langue.add(OO_Langue);
   }
 }
 /**
  * Gets the chronology menu.
  *
  * @return the chronology menu
  */
 public JMenu getChronologyMenu() {
   JMenu menu = new JMenu("Recent Hosts");
   menu.removeAll();
   Collection<HostEntry> hostEntries =
       NavigationHistory.getInstance().getRecentHostEntries(PREFERRED_MAX_MENU_SIZE);
   for (HostEntry entry : hostEntries) {
     String urlText = "http://" + entry.getHost();
     try {
       URL url = new URL(urlText);
       long elapsed = System.currentTimeMillis() - entry.getTimestamp();
       String menuText = entry.getHost() + " (" + Timing.getElapsedText(elapsed) + " ago)";
       Action action = this.actionPool.createNavigateAction(url);
       JMenuItem menuItem = menuItem(menuText, action);
       menuItem.setToolTipText(url.toExternalForm());
       menu.add(menuItem);
     } catch (MalformedURLException mfu) {
       logger.log(Level.WARNING, "populateRecentHosts(): Bad URL=" + urlText, mfu);
     }
   }
   menu.addSeparator();
   menu.add(menuItem("Show All Recent Hosts", new ShowRecentHostsAction(this, window)));
   return menu;
 }
    @Override
    public void run() {
      if (androidMode.getSDK() == null) return;

      final Devices devices = Devices.getInstance();
      java.util.List<Device> deviceList = devices.findMultiple(false);
      Device selectedDevice = devices.getSelectedDevice();

      if (deviceList.size() == 0) {
        // if (deviceMenu.getItem(0).isEnabled()) {
        if (0 < deviceMenu.getItemCount()) {
          deviceMenu.removeAll();
          JMenuItem noDevicesItem = new JMenuItem("No connected devices");
          noDevicesItem.setEnabled(false);
          deviceMenu.add(noDevicesItem);
        }
        devices.setSelectedDevice(null);
      } else {
        deviceMenu.removeAll();

        if (selectedDevice == null) {
          selectedDevice = deviceList.get(0);
          devices.setSelectedDevice(selectedDevice);
        } else {
          // check if selected device is still connected
          boolean found = false;
          for (Device device : deviceList) {
            if (device.equals(selectedDevice)) {
              found = true;
              break;
            }
          }

          if (!found) {
            selectedDevice = deviceList.get(0);
            devices.setSelectedDevice(selectedDevice);
          }
        }

        for (final Device device : deviceList) {
          final JCheckBoxMenuItem deviceItem = new JCheckBoxMenuItem(device.getName());
          deviceItem.setEnabled(true);

          if (device.equals(selectedDevice)) deviceItem.setState(true);

          // prevent checkboxmenuitem automatic state changing onclick
          deviceItem.addChangeListener(
              new ChangeListener() {
                @Override
                public void stateChanged(ChangeEvent e) {
                  if (device.equals(devices.getSelectedDevice())) deviceItem.setState(true);
                  else deviceItem.setState(false);
                }
              });

          deviceItem.addActionListener(
              new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                  devices.setSelectedDevice(device);

                  for (int i = 0; i < deviceMenu.getItemCount(); i++) {
                    ((JCheckBoxMenuItem) deviceMenu.getItem(i)).setState(false);
                  }

                  deviceItem.setState(true);
                }
              });

          deviceMenu.add(deviceItem);
        }
      }
    }
  /**
   * Recria o menu editar do Frame Principal
   *
   * @param menu
   * @return
   */
  private JMenu criaMenuEditar(JMenu menu) {
    menu.removeAll();
    menu.setMnemonic('E');
    menu.setMnemonic(KeyEvent.VK_E);

    menu.add(new JMenuItemTeclaAtalho(textAreaSourceCode));

    menu.add(new JSeparator());

    JMenuItem btnContraste = new JMenuItem(XHTML_Panel.ALTERAR_CONTRASTE);
    btnContraste.addActionListener(this);
    btnContraste.setActionCommand("Contraste");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD,
    // ActionEvent.CTRL_MASK));
    btnContraste.setToolTipText(XHTML_Panel.DICA_CONTRASTE);
    btnContraste.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_CONTRASTE);
    menu.add(btnContraste);

    JMenuItem btnAumenta = new JMenuItem(XHTML_Panel.AUMENTA_FONTE);
    btnAumenta.addActionListener(this);
    btnAumenta.setActionCommand("AumentaFonte");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    btnAumenta.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK));
    btnAumenta.setToolTipText(XHTML_Panel.DICA_AUMENTA_FONTE);
    btnAumenta.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_AUMENTA_FONTE);
    menu.add(btnAumenta);

    JMenuItem btnDiminui = new JMenuItem(XHTML_Panel.DIMINUI_FONTE);
    btnDiminui.addActionListener(this);
    btnDiminui.setActionCommand("DiminuiFonte");
    // btnDiminui.setMnemonic('F');
    // btnDiminui.setMnemonic(KeyEvent.VK_F);
    btnDiminui.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK));
    btnDiminui.setToolTipText(XHTML_Panel.DICA_DIMINUI_FONTE);
    btnDiminui.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_DIMINUI_FONTE);
    menu.add(btnDiminui);

    menu.add(new JSeparator());

    JMenuItem btnProcurar = new JMenuItem(XHTML_Panel.PROCURAR);
    btnProcurar.addActionListener(this);
    btnProcurar.setActionCommand("Procurar");
    btnProcurar.setMnemonic('P');
    btnProcurar.setMnemonic(KeyEvent.VK_P);
    btnProcurar.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    btnProcurar.setToolTipText(XHTML_Panel.DICA_PROCURAR);
    btnProcurar.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_PROCURAR);
    menu.add(btnProcurar);

    JMenuItem btnSelecionarTudo = new JMenuItem(XHTML_Panel.SELECIONAR_TUDO);
    btnSelecionarTudo.addActionListener(this);
    btnSelecionarTudo.setActionCommand("SelecionarTudo");
    btnSelecionarTudo.setMnemonic('T');
    btnSelecionarTudo.setMnemonic(KeyEvent.VK_T);
    btnSelecionarTudo.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK));
    btnSelecionarTudo.setToolTipText(XHTML_Panel.DICA_SELECIONAR_TUDO);
    btnSelecionarTudo
        .getAccessibleContext()
        .setAccessibleDescription(XHTML_Panel.DICA_SELECIONAR_TUDO);
    menu.add(btnSelecionarTudo);

    JMenuItem btnDesfazer = new JMenuItem(XHTML_Panel.DESFAZER);
    btnDesfazer.addActionListener(this);
    btnDesfazer.setActionCommand("Desfazer");
    btnDesfazer.setMnemonic('z');
    btnDesfazer.setMnemonic(KeyEvent.VK_Z);
    btnDesfazer.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
    btnDesfazer.setToolTipText(XHTML_Panel.DICA_DESFAZER);
    btnDesfazer.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_DESFAZER);

    menu.add(btnDesfazer);
    return menu;
  }
  private void updateSdkMenu(final JMenu sdkMenu) {
    try {
      ArrayList<AndroidSDK.SDKTarget> targets = androidMode.getSDK().getAvailableSdkTargets();

      if (targets.size() != 0) sdkMenu.removeAll();

      AndroidSDK.SDKTarget lowestTargetAvailable = null;
      JCheckBoxMenuItem lowestTargetMenuItem = null;

      String savedTargetVersion = Preferences.get("android.sdk.version");
      boolean savedTargetSet = false;

      for (final AndroidSDK.SDKTarget target : targets) {
        if (target.version < 11) {
          // We do not support API level less than 11
          continue;
        }
        final JCheckBoxMenuItem item =
            new JCheckBoxMenuItem("API " + target.name + " (" + target.version + ")");

        if (savedTargetSet == false
            && (lowestTargetAvailable == null || lowestTargetAvailable.version > target.version)) {
          lowestTargetAvailable = target;
          lowestTargetMenuItem = item;
        }

        if (Integer.toString(target.version).equals(savedTargetVersion)) {
          AndroidBuild.setSdkTarget(target, sketch);
          item.setState(true);
          savedTargetSet = true;
        }

        item.addChangeListener(
            new ChangeListener() {
              @Override
              public void stateChanged(ChangeEvent e) {
                if (target.name.equals(AndroidBuild.sdkName)) item.setState(true);
                else item.setState(false);
              }
            });

        item.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                AndroidBuild.setSdkTarget(target, sketch);

                for (int i = 0; i < sdkMenu.getItemCount(); i++) {
                  ((JCheckBoxMenuItem) sdkMenu.getItem(i)).setState(false);
                }

                item.setState(true);
              }
            });

        sdkMenu.add(item);
      }

      if (!savedTargetSet) {
        AndroidBuild.setSdkTarget(lowestTargetAvailable, sketch);
        lowestTargetMenuItem.setState(true);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }