/**
   * Aware-P Epanet application entry point
   *
   * @param args
   * @throws UnsupportedLookAndFeelException
   */
  public static void main(String[] args) throws UnsupportedLookAndFeelException {
    if (Utilities.isMac()) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Aware-P Epanet");

      Application app = Application.getApplication();
      app.setDockIconImage(
          Toolkit.getDefaultToolkit().getImage(EpanetUI.class.getResource("/uiresources/ae.png")));

      JMenuBar menuBar = new JMenuBar();
      JMenu fileMenu = new JMenu("File");
      menuBar.add(fileMenu);

      openAction = new JMenuItem("Open");
      saveAction = new JMenuItem("Save");
      runAction = new JMenuItem("Run");

      fileMenu.add(openAction);
      fileMenu.add(saveAction);
      fileMenu.add(runAction);
      app.setDefaultMenuBar(menuBar);
    }
    UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    new EpanetUI();
  }
Ejemplo n.º 2
0
 /**
  * Create the menubar for the app. By default this pulls the definition of the menu from the
  * associated resource file.
  */
 protected JMenuBar createMenubar() {
   JMenuBar mb = new JMenuBar();
   for (String menuKey : getMenuBarKeys()) {
     JMenu m = createMenu(menuKey);
     if (m != null) {
       mb.add(m);
     }
   }
   return mb;
 }
Ejemplo n.º 3
0
  private void buildMenu() {
    jMenuBar = new javax.swing.JMenuBar();
    mainMenu = new javax.swing.JMenu();
    mainMenu.setText("Main");

    loginMenuItem = new JMenuItem("Login...");
    loginMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            headerPanel.handleLoginLogout();
          }
        });

    mainMenu.add(loginMenuItem);

    exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (qsadminMain.isConnected() == true) {
              headerPanel.handleLoginLogout();
            }
            System.exit(0);
          }
        });
    mainMenu.add(exitMenuItem);

    helpMenu = new javax.swing.JMenu();
    helpMenu.setText("Help");

    aboutMenuItem = new JMenuItem("About...");
    aboutMenuItem.setEnabled(true);
    aboutMenuItem.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            about();
          }
        });
    helpMenu.add(aboutMenuItem);

    jMenuBar.add(mainMenu);
    jMenuBar.add(helpMenu);

    parentFrame.setJMenuBar(jMenuBar);
  }
Ejemplo n.º 4
0
  /**
   * Modified "Generated Code". Initialize the GUI Components of the program. THIS PART GETS
   * EXTREMELY CONFUSING.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Bull Excrements Code">
  private void initComponents() {
    // MainFrame = new JFrame();

    sb = new StringBuilder(64);

    sb.append(instructions2());

    MessageLabel = new JLabel(sb.toString());

    MainPanel = new JPanel();
    MainMenuBar = new JMenuBar();
    FileMenu = new JMenu();
    NewGameMenu = new JMenu();
    EasyButton = new JMenuItem();
    MediumButton = new JMenuItem();
    HardButton = new JMenuItem();
    QuitButton = new JMenuItem();
    HelpMenu = new JMenu();

    // frame things -- useless!
    /*
    GroupLayout mainFrameLayout = new GroupLayout(MainFrame.getContentPane());
    MainFrame.getContentPane().setLayout(mainFrameLayout);
    mainFrameLayout.setHorizontalGroup(
        mainFrameLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 400, Short.MAX_VALUE)
    );
    mainFrameLayout.setVerticalGroup(
        mainFrameLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );
    */
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            formMouseReleased(evt);
          }
        });
    addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent evt) {
            formKeyPressed(evt);
          }
        });

    GroupLayout mainPanelLayout = new GroupLayout(MainPanel);
    MainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
        mainPanelLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                mainPanelLayout
                    .createSequentialGroup()
                    .addGap(40, 60, 80)
                    .addComponent(MessageLabel)
                    .addContainerGap(50, Short.MAX_VALUE)));
    mainPanelLayout.setVerticalGroup(
        mainPanelLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                mainPanelLayout
                    .createSequentialGroup()
                    .addGap(54, 54, 54)
                    .addComponent(MessageLabel)
                    .addContainerGap(200, Short.MAX_VALUE)));

    FileMenu.setText("File");
    FileMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            FileMenuMouseClicked(evt);
          }
        });

    NewGameMenu.setText("New Game");

    EasyButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    EasyButton.setText("Easy");
    EasyButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            EasyButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(EasyButton);

    MediumButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    MediumButton.setText("Medium");
    MediumButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            MediumButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(MediumButton);

    HardButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
    HardButton.setText("Hard");
    HardButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            HardButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(HardButton);

    FileMenu.add(NewGameMenu);

    QuitButton.setText("Quit");
    QuitButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            QuitButtonMouseReleased(evt);
          }
        });
    FileMenu.add(QuitButton);

    MainMenuBar.add(FileMenu);

    HelpMenu.setText("Help");
    MainMenuBar.add(HelpMenu);

    setJMenuBar(MainMenuBar);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(
                MainPanel,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(
                MainPanel,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));

    // post everything
    this.setTitle("Arcade");

    JLabel label = new JLabel(sb.toString());
    add(label);

    setVisible(true);
    repaint();
    pack();
  } // </editor-fold>
  /** Aware-P Epanet frontend constructor. */
  public EpanetUI() {
    initLogger();

    frame = new JFrame();
    frame.setTitle(APP_TITTLE);
    frame.add(root);

    if (!Utilities.isMac()) {
      JMenuBar menuBar = new JMenuBar();

      JMenu fileMenu = new JMenu("File");
      menuBar.add(fileMenu);

      openAction = new JMenuItem("Open");
      saveAction = new JMenuItem("Save");
      runAction = new JMenuItem("Run");

      fileMenu.add(openAction);
      fileMenu.add(openAction);
      fileMenu.add(runAction);

      frame.setJMenuBar(menuBar);
    }

    openAction.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            openEvent();
            network.repaint();
          }
        });

    saveAction.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            saveEvent();
          }
        });

    runAction.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            runSimulation();
          }
        });

    frame.pack();
    frame.setMinimumSize(new Dimension(848, 500));
    frame.setLocationRelativeTo(null);

    clearInterface();

    frame.setVisible(true);

    openINPButton.addActionListener(this);
    runSimulationButton.addActionListener(this);
    logoB.addActionListener(this);
    checkTanks.addActionListener(this);
    checkNodes.addActionListener(this);
    checkPipes.addActionListener(this);
    saveButton.addActionListener(this);
    // runMSXButton.addActionListener(this);
    // saveReport.addActionListener(this);

    frame.addWindowListener(
        new WindowListener() {
          public void windowOpened(WindowEvent e) {}

          public void windowClosing(WindowEvent e) {
            for (Handler handler : log.getHandlers()) {
              handler.flush();
            }
            System.exit(0);
          }

          public void windowClosed(WindowEvent e) {}

          public void windowIconified(WindowEvent e) {}

          public void windowDeiconified(WindowEvent e) {}

          public void windowActivated(WindowEvent e) {}

          public void windowDeactivated(WindowEvent e) {}
        });
  }