/**
   * @param str name of Menu
   * @param bFlag set mnemonics on menu items
   */
  private JMenuBar createMenuBar(String str, boolean bFlag) {
    menubar = new JMenuBar();

    menu1 = new JMenu(str);
    menu1.setMnemonic(str.charAt(0));
    menu1.addActionListener(this);

    menubar.add(menu1);
    for (int i = 0; i < 8; i++) {
      JMenuItem menuitem = new JMenuItem("1 JMenuItem" + i);
      menuitem.addActionListener(this);
      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      menu1.add(menuitem);
    }

    // second menu
    menu2 = new JMenu("2 - Second Menu");
    menu2.addActionListener(this);
    menu2.setMnemonic('2');

    menubar.add(menu2);
    for (int i = 0; i < 5; i++) {
      JMenuItem menuitem = new JMenuItem("2 JMenuItem" + i);
      menuitem.addActionListener(this);

      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      menu2.add(menuitem);
    }
    JMenu submenu = new JMenu("Sub Menu");
    submenu.setMnemonic('S');
    submenu.addActionListener(this);
    for (int i = 0; i < 5; i++) {
      JMenuItem menuitem = new JMenuItem("S JMenuItem" + i);
      menuitem.addActionListener(this);
      if (bFlag) {
        menuitem.setMnemonic('0' + i);
      }
      submenu.add(menuitem);
    }
    menu2.add(new JSeparator());
    menu2.add(submenu);

    return menubar;
  }
  private JMenuBar makeMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // File
    JMenu menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FILE")); // $NON-NLS-1$
    menuBar.add(menu);
    menu.addActionListener(this);

    JMenuItem item = addItem("GameInformationFrame.LOAD"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.FILESAVE"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.CLOSESAVE"); // $NON-NLS-1$
    menu.add(item);

    // Edit
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_EDIT")); // $NON-NLS-1$
    menuBar.add(menu);

    item = new JMenuItem(undoManager.getUndoAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = new JMenuItem(undoManager.getRedoAction());
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.CUT"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.COPY"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    item = addItem("GameInformationFrame.PASTE"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SELECTALL"); // $NON-NLS-1$
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK));
    menu.add(item);

    return menuBar;
  }
    public MenuCentral(JMenu mnu, ControleurPanneaux cp) {
      _mnu = mnu;
      mnu.addMenuListener(
          new MenuListener() {
            public void menuSelected(MenuEvent e) {
              majContenuMenu();
            }

            public void menuDeselected(MenuEvent e) {}

            public void menuCanceled(MenuEvent e) {}
          });
      lnkControleurPanneaux = cp;
      jMenuAjouterContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("ajoutercontenu"));
      jMenuChangerContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("changerdecontenu"));
      jMenuSupprimerContenu.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("supprimercontenu"));
      jMenuAjouterGuide.setText(
          lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("ajouterguide"));
      jMenuSupprimer.setText(lnkSysteme.lnkFenetrePrincipale.getLnkLangues().valeurDe("supprimer"));

      jMenuAjouterContenu.setVisible(false);
      jMenuChangerContenu.setVisible(false);
      jMenuAjouterGuide.setVisible(false);
      jMenuSupprimerContenu.setVisible(false);
      jMenuSupprimer.setVisible(false);

      jMenuAjouterContenu.addActionListener(this);
      jMenuChangerContenu.addActionListener(this);
      jMenuAjouterGuide.addActionListener(this);
      jMenuSupprimerContenu.addActionListener(this);
      jMenuSupprimer.addActionListener(this);

      _mnu.add(jMenuAjouterContenu);
      _mnu.add(jMenuChangerContenu);
      _mnu.add(jMenuSupprimerContenu);
      _mnu.add(jMenuAjouterGuide);
      _mnu.add(jMenuSupprimer);
    }
Exemplo n.º 4
0
  @Override
  public void initialize() {

    if (SystemTray.isSupported()) {

      JMenuItem openMenu = new JMenuItem(Res.getString("menuitem.open"));
      JMenuItem minimizeMenu = new JMenuItem(Res.getString("menuitem.hide"));
      JMenuItem exitMenu = new JMenuItem(Res.getString("menuitem.exit"));
      statusMenu = new JMenu(Res.getString("menuitem.status"));
      JMenuItem logoutMenu = new JMenuItem(Res.getString("menuitem.logout.no.status"));

      SystemTray tray = SystemTray.getSystemTray();
      SparkManager.getNativeManager().addNativeHandler(this);
      ChatManager.getInstance().addChatMessageHandler(chatMessageHandler);
      // XEP-0085 suport (replaces the obsolete XEP-0022)
      org.jivesoftware.smack.chat.ChatManager.getInstanceFor(SparkManager.getConnection())
          .addChatListener(this);

      if (Spark.isLinux()) {
        newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY_LINUX);
        typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY_LINUX);
      } else {
        newMessageIcon = SparkRes.getImageIcon(SparkRes.MESSAGE_NEW_TRAY);
        typingIcon = SparkRes.getImageIcon(SparkRes.TYPING_TRAY);
      }

      availableIcon = Default.getImageIcon(Default.TRAY_IMAGE);
      if (Spark.isLinux()) {
        if (availableIcon == null) {
          availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE_LINUX);
          Log.error(availableIcon.toString());
        }
        awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY_LINUX);
        dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND_LINUX);
        offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE_LINUX);
        connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING_LINUX);
      } else {
        if (availableIcon == null) {
          availableIcon = SparkRes.getImageIcon(SparkRes.TRAY_IMAGE);
        }
        awayIcon = SparkRes.getImageIcon(SparkRes.TRAY_AWAY);
        dndIcon = SparkRes.getImageIcon(SparkRes.TRAY_DND);
        offlineIcon = SparkRes.getImageIcon(SparkRes.TRAY_OFFLINE);
        connectingIcon = SparkRes.getImageIcon(SparkRes.TRAY_CONNECTING);
      }

      popupMenu.add(openMenu);
      openMenu.addActionListener(
          new AbstractAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent event) {
              SparkManager.getMainWindow().setVisible(true);
              SparkManager.getMainWindow().toFront();
            }
          });
      popupMenu.add(minimizeMenu);
      minimizeMenu.addActionListener(
          new AbstractAction() {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent event) {
              SparkManager.getMainWindow().setVisible(false);
            }
          });
      popupMenu.addSeparator();
      addStatusMessages();
      popupMenu.add(statusMenu);
      statusMenu.addActionListener(
          new AbstractAction() {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent event) {}
          });

      if (Spark.isWindows()) {
        if (!Default.getBoolean("DISABLE_EXIT")) popupMenu.add(logoutMenu);

        logoutMenu.addActionListener(
            new AbstractAction() {
              private static final long serialVersionUID = 1L;

              @Override
              public void actionPerformed(ActionEvent e) {
                SparkManager.getMainWindow().logout(false);
              }
            });
      }
      // Exit Menu
      exitMenu.addActionListener(
          new AbstractAction() {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
              SparkManager.getMainWindow().shutdown();
            }
          });
      if (!Default.getBoolean("DISABLE_EXIT")) popupMenu.add(exitMenu);

      /** If connection closed set offline tray image */
      SparkManager.getConnection()
          .addConnectionListener(
              new ConnectionListener() {

                @Override
                public void connected(XMPPConnection xmppConnection) {
                  trayIcon.setImage(availableIcon.getImage());
                }

                @Override
                public void authenticated(XMPPConnection xmppConnection, boolean b) {
                  trayIcon.setImage(availableIcon.getImage());
                }

                @Override
                public void connectionClosed() {
                  trayIcon.setImage(offlineIcon.getImage());
                }

                @Override
                public void connectionClosedOnError(Exception arg0) {
                  trayIcon.setImage(offlineIcon.getImage());
                }

                @Override
                public void reconnectingIn(int arg0) {
                  trayIcon.setImage(connectingIcon.getImage());
                }

                @Override
                public void reconnectionSuccessful() {
                  trayIcon.setImage(availableIcon.getImage());
                }

                @Override
                public void reconnectionFailed(Exception arg0) {
                  trayIcon.setImage(offlineIcon.getImage());
                }
              });

      SparkManager.getSessionManager()
          .addPresenceListener(
              presence -> {
                if (presence.getMode() == Presence.Mode.available) {
                  trayIcon.setImage(availableIcon.getImage());
                } else if (presence.getMode() == Presence.Mode.away
                    || presence.getMode() == Presence.Mode.xa) {
                  trayIcon.setImage(awayIcon.getImage());
                } else if (presence.getMode() == Presence.Mode.dnd) {
                  trayIcon.setImage(dndIcon.getImage());
                } else {
                  trayIcon.setImage(availableIcon.getImage());
                }
              });

      try {

        trayIcon =
            new TrayIcon(
                availableIcon.getImage(), Default.getString(Default.APPLICATION_NAME), null);
        trayIcon.setImageAutoSize(true);

        trayIcon.addMouseListener(
            new MouseListener() {

              @Override
              public void mouseClicked(MouseEvent event) {
                // if we are using double click on tray icon
                if ((!pref.isUsingSingleTrayClick()
                        && event.getButton() == MouseEvent.BUTTON1
                        && event.getClickCount() % 2 == 0)
                    ||
                    // if we using single click on tray icon
                    (pref.isUsingSingleTrayClick()
                        && event.getButton() == MouseEvent.BUTTON1
                        && event.getClickCount() == 1)) {

                  // bring the mainwindow to front
                  if ((SparkManager.getMainWindow().isVisible())
                      && (SparkManager.getMainWindow().getState() == java.awt.Frame.NORMAL)) {
                    SparkManager.getMainWindow().setVisible(false);
                  } else {
                    SparkManager.getMainWindow().setVisible(true);
                    SparkManager.getMainWindow().setState(java.awt.Frame.NORMAL);
                    SparkManager.getMainWindow().toFront();
                  }

                } else if (event.getButton() == MouseEvent.BUTTON1) {
                  SparkManager.getMainWindow().toFront();
                  // SparkManager.getMainWindow().requestFocus();
                } else if (event.getButton() == MouseEvent.BUTTON3) {

                  if (popupMenu.isVisible()) {
                    popupMenu.setVisible(false);
                  } else {

                    double x = MouseInfo.getPointerInfo().getLocation().getX();
                    double y = MouseInfo.getPointerInfo().getLocation().getY();

                    if (Spark.isMac()) {
                      popupMenu.setLocation((int) x, (int) y);
                    } else {
                      popupMenu.setLocation(event.getX(), event.getY());
                    }

                    popupMenu.setInvoker(popupMenu);
                    popupMenu.setVisible(true);
                  }
                }
              }

              @Override
              public void mouseEntered(MouseEvent event) {}

              @Override
              public void mouseExited(MouseEvent event) {}

              @Override
              public void mousePressed(MouseEvent event) {

                // on Mac i would want the window to show when i left-click the Icon
                if (Spark.isMac() && event.getButton() != MouseEvent.BUTTON3) {
                  SparkManager.getMainWindow().setVisible(false);
                  SparkManager.getMainWindow().setVisible(true);
                  SparkManager.getMainWindow().requestFocusInWindow();
                  SparkManager.getMainWindow().bringFrameIntoFocus();
                  SparkManager.getMainWindow().toFront();
                  SparkManager.getMainWindow().requestFocus();
                }
              }

              @Override
              public void mouseReleased(MouseEvent event) {}
            });

        tray.add(trayIcon);
      } catch (Exception e) {
        // Not Supported
      }
    } else {
      Log.error("Tray don't supports on this platform.");
    }
  }
Exemplo n.º 5
0
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  private void initComponents() {
    contentPane = new javax.swing.JSplitPane();
    leftPanel = new javax.swing.JSplitPane();
    projectListPanel = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jList1 = new javax.swing.JList();
    treePanel = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jTree1 = new javax.swing.JTree();
    infoPanel = new javax.swing.JPanel();
    jMenuBar2 = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    newProjectMenu = new javax.swing.JMenuItem();
    openMenu = new javax.swing.JMenuItem();
    saveMenu = new javax.swing.JMenuItem();
    saveAsMenu = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    importPSIMenu = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    jSeparator3 = new javax.swing.JSeparator();
    quitMenu = new javax.swing.JMenuItem();
    projectMenu = new javax.swing.JMenu();
    indicsMenu = new javax.swing.JMenu();
    variationMenu = new javax.swing.JMenuItem();
    ressourceMenu = new javax.swing.JMenuItem();
    alertMenu = new javax.swing.JMenuItem();
    consoMenu = new javax.swing.JMenuItem();
    compareMenu = new javax.swing.JMenuItem();
    settingMenu = new javax.swing.JMenu();
    warningSettingMenu = new javax.swing.JMenuItem();
    helpMenu = new javax.swing.JMenu();
    helpContMenu = new javax.swing.JMenuItem();

    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm(evt);
          }
        });

    leftPanel.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    projectListPanel.setLayout(new java.awt.BorderLayout());

    jLabel1.setText("Projets");
    projectListPanel.add(jLabel1, java.awt.BorderLayout.NORTH);

    jList1.setPreferredSize(new java.awt.Dimension(0, 100));
    jList1.addListSelectionListener(
        new javax.swing.event.ListSelectionListener() {
          public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jList1ValueChanged(evt);
          }
        });

    projectListPanel.add(jList1, java.awt.BorderLayout.CENTER);

    leftPanel.setTopComponent(projectListPanel);

    treePanel.setLayout(new java.awt.BorderLayout());

    jLabel2.setText("Structure de projet");
    treePanel.add(jLabel2, java.awt.BorderLayout.NORTH);

    jTree1.addTreeSelectionListener(
        new javax.swing.event.TreeSelectionListener() {
          public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
            jTree1ValueChanged(evt);
          }
        });

    treePanel.add(jTree1, java.awt.BorderLayout.CENTER);

    leftPanel.setBottomComponent(treePanel);

    contentPane.setLeftComponent(leftPanel);

    infoPanel.setLayout(new java.awt.BorderLayout());

    contentPane.setRightComponent(infoPanel);

    getContentPane().add(contentPane, java.awt.BorderLayout.CENTER);

    fileMenu.setText("Fichier");

    openMenu.setText("Ouvrir environnement...");
    openMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            openMenuActionPerformed(evt);
          }
        });

    fileMenu.add(openMenu);

    saveMenu.setText("Enregistrer");
    saveMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveMenuActionPerformed(evt);
          }
        });

    fileMenu.add(saveMenu);

    saveAsMenu.setText("Enregistrer sous...");
    saveAsMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveAsMenuActionPerformed(evt);
          }
        });

    fileMenu.add(saveAsMenu);

    fileMenu.add(jSeparator1);

    quitMenu.setText("Quitter");
    quitMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            quitMenuActionPerformed(evt);
          }
        });

    fileMenu.add(quitMenu);

    jMenuBar2.add(fileMenu);

    projectMenu.setText("Projet");
    projectMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            projectMenuActionPerformed(evt);
          }
        });

    newProjectMenu.setText("Ajout projet");
    newProjectMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            newProjectMenuActionPerformed(evt);
          }
        });

    projectMenu.add(newProjectMenu);

    importPSIMenu.setText("Import une étape...");
    importPSIMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            importPSIMenuActionPerformed(evt);
          }
        });

    projectMenu.add(importPSIMenu);

    projectMenu.add(jSeparator2);

    indicsMenu.setText("Indicateurs");

    variationMenu.setText("Variation sur le projet");
    variationMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            variationMenuActionPerformed(evt);
          }
        });

    alertMenu.setText("alertes");
    alertMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            alertMenuActionPerformed(evt);
          }
        });
    projectMenu.add(alertMenu);
    ressourceMenu.setText("Ressources");
    ressourceMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            ressourceMenuActionPerformed(evt);
          }
        });

    projectMenu.add(indicsMenu);

    indicsMenu.add(variationMenu);
    indicsMenu.add(ressourceMenu);

    consoMenu.setText("Consolidation...");
    consoMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            consoMenuActionPerformed(evt);
          }
        });
    projectMenu.add(consoMenu);

    projectMenu.add(jSeparator3);

    compareMenu.setText("Comparer les projets...");
    compareMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            compareMenuActionPerformed(evt);
          }
        });
    projectMenu.add(compareMenu);

    jMenuBar2.add(projectMenu);

    warningSettingMenu.setText("Réglages des seuils d'alertes");
    settingMenu.setText("Réglages");

    warningSettingMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            warningPropertiesMenuActionPerformed(evt);
          }
        });

    settingMenu.add(warningSettingMenu);
    jMenuBar2.add(settingMenu);

    helpMenu.setText("Aide");
    helpContMenu.setText("Sommaire");
    helpContMenu.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            helpContMenuActionPerformed(evt);
          }
        });

    helpMenu.add(helpContMenu);

    jMenuBar2.add(helpMenu);

    setJMenuBar(jMenuBar2);

    pack();
  }
Exemplo n.º 6
0
  private JMenuBar makeMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // File
    JMenu menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FILE")); // $NON-NLS-1$
    menuBar.add(menu);
    menu.addActionListener(this);

    JMenuItem item = addItem("GameInformationFrame.LOAD"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.LOAD"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.FILESAVE"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.FILESAVE"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SETTINGS"); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.PRINT"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.PRINT"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = new JMenuItem(Messages.getString("GameInformationFrame.CLOSESAVE")); // $NON-NLS-1$
    item.setIcon(save.getIcon());
    item.setActionCommand("GameInformationFrame.CLOSESAVE"); // $NON-NLS-1$
    item.addActionListener(this);
    menu.add(item);

    // Edit
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_EDIT")); // $NON-NLS-1$
    menuBar.add(menu);

    item = addItem("GameInformationFrame.CUT"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.CUT"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.COPY"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.COPY"))); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.PASTE"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.PASTE"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = new JMenuItem(undoManager.getUndoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.UNDO"))); // $NON-NLS-1$
    menu.add(item);
    item = new JMenuItem(undoManager.getRedoAction());
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.REDO"))); // $NON-NLS-1$
    menu.add(item);
    menu.addSeparator();
    item = addItem("GameInformationFrame.SELECTALL"); // $NON-NLS-1$
    item.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.SELECTALL"))); // $NON-NLS-1$
    menu.add(item);

    // Format
    menu = new JMenu(Messages.getString("GameInformationFrame.MENU_FORMAT")); // $NON-NLS-1$
    menuBar.add(menu);

    miBold = addItem("GameInformationFrame.BOLD"); // $NON-NLS-1$
    miBold.setActionCommand("GameInformationFrame.MENU_BOLD"); // $NON-NLS-1$
    miBold.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.BOLD"))); // $NON-NLS-1$
    menu.add(miBold);
    miItalic = addItem("GameInformationFrame.ITALIC"); // $NON-NLS-1$
    miItalic.setActionCommand("GameInformationFrame.MENU_ITALIC"); // $NON-NLS-1$
    miItalic.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.ITALIC"))); // $NON-NLS-1$
    menu.add(miItalic);
    miUnderline = addItem("GameInformationFrame.UNDERLINE"); // $NON-NLS-1$
    miUnderline.setActionCommand("GameInformationFrame.MENU_UNDERLINE"); // $NON-NLS-1$
    miUnderline.setAccelerator(
        KeyStroke.getKeyStroke(
            Messages.getKeyboardString("GameInformationFrame.UNDERLINE"))); // $NON-NLS-1$
    menu.add(miUnderline);
    menu.addSeparator();
    miLeft = addItem("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    miLeft.setActionCommand("GameInformationFrame.ALIGN_LEFT"); // $NON-NLS-1$
    miLeft.setSelected(true);
    menu.add(miLeft);
    miCenter = addItem("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    miCenter.setActionCommand("GameInformationFrame.ALIGN_CENTER"); // $NON-NLS-1$
    menu.add(miCenter);
    miRight = addItem("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    miRight.setActionCommand("GameInformationFrame.ALIGN_RIGHT"); // $NON-NLS-1$
    menu.add(miRight);
    menu.addSeparator();
    item = addItem("GameInformationFrame.FONTCOLOR"); // $NON-NLS-1$
    menu.add(item);
    item = addItem("GameInformationFrame.COLOR"); // $NON-NLS-1$
    menu.add(item);

    return menuBar;
  }
Exemplo n.º 7
0
  private void initComponents() {

    // primero el menu
    mIExit = new JMenuItem("Exit", KeyEvent.VK_E);
    mCreateIndex = new JMenuItem("CREATE INDEX", KeyEvent.VK_C);
    mDeleteIndex = new JMenuItem("DELETE INDEX", KeyEvent.VK_D);
    mDeleteIndex.setEnabled(false);
    mExit = new JMenu("Exit");
    mExit.setMnemonic(KeyEvent.VK_X);
    mExit.add(mIExit);
    mIExit.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            System.exit(0);
          }
        });

    mMain = new JMenu("INDEX");
    mMain.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.out.println(
                "Existe el repo " + DemiurgoFacade.getInstance().getService().existRepo());
          }
        });
    mMain.setMnemonic(KeyEvent.VK_I);

    mMain.add(mCreateIndex);
    mCreateIndex.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            JDialog jdialog = new JDialog();
            jdialog.addWindowListener(
                new WindowAdapter() {
                  public void windowClosing(WindowEvent we) {
                    validateMenu();
                  }
                });
            jdialog.setSize(400, 400);
            jdialog.setContentPane(new JINDEXCreator());
            jdialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            jdialog.setModal(true);
            jdialog.setVisible(true);
          }
        });

    mMain.add(mDeleteIndex);

    mDeleteIndex.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent ae) {
            Object[] options = {"Sí", "No"};
            int n =
                JOptionPane.showOptionDialog(
                    null,
                    "¿Desea eliminar el INDEX actual?",
                    "Eliminar el INDEX actual..",
                    JOptionPane.YES_NO_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    options[1]);

            if (n == 0) {
              // se elimina del modelo
              boolean del = DemiurgoFacade.getInstance().getService().deleteRepo();
              if (del) {
                JOptionPane.showMessageDialog(
                    SiSeOnFrame.this,
                    "El INDEX se elimino satisfactoriamente, puedes volver a crear uno.",
                    "INDEX eliminado.",
                    JOptionPane.WARNING_MESSAGE);
                validateMenu();
              } else {
                JOptionPane.showMessageDialog(
                    SiSeOnFrame.this,
                    "El INDEX no se pudo eliminar de manera automática.\n ."
                        + "Borra la carpeta :"
                        + DemiurgoFacade.getInstance().getService().getPathMainRepo()
                        + " para poder crear una nueva.",
                    "INDEX requiere borrado manua..",
                    JOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });

    menuBar = new JMenuBar();
    menuBar.add(mMain);
    menuBar.add(mExit);
    this.setJMenuBar(menuBar);
    // luego el statusbar
    status = new StatusBar();

    modeloGrid = new SingleTableModel();
    modeloGrid.setEditable(false);
    modeloGrid.addColumn("Name:");
    modeloGrid.addColumn("Path");
    modeloGrid.addColumn("Size");
    modeloGrid.addColumn("Modified:");
    grid = new JTable(modeloGrid);
    grid.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    SelectionListener listener = new SelectionListener();
    grid.getSelectionModel().addListSelectionListener(listener);
    DoubleClickMouseListener mouseListener = new DoubleClickMouseListener();
    grid.addMouseListener(mouseListener);
    // grid.getColumnModel().getSelectionModel().addListSelectionListener(listener);
    JScrollPane scroll = new JScrollPane(grid);

    tabbed = new JTabbedPane();
    JPanel tabPanel = new JPanel(new GridLayout(0, 1));
    ActionListener searhActionListener = new searhActionListener();
    labelInput = new JLabelInput("Texto: ", "");
    labelInput.addActionTextInput(searhActionListener);
    tabPanel.add(labelInput);

    // tabPanel.add(comboRepo);
    buttonSearch = new JButton("Buscar dentro del indice existente.");
    buttonSearch.addActionListener(searhActionListener);
    tabPanel.add(buttonSearch);

    tabbed.add("Buscar:", tabPanel);
    // Y ahora el layout Final.
    this.setLayout(new BorderLayout());
    this.add(tabbed, BorderLayout.NORTH);
    this.add(scroll, BorderLayout.CENTER);
    status.setText(FileUtil.getWorkDirectory());
    this.add(status, BorderLayout.SOUTH);
    validateMenu();
  }