コード例 #1
1
  /**
   * 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();
  }
コード例 #2
0
  public static void init(final PApplet sketch) {
    if (application == null) {
      application = Application.getApplication();
    }

    application.setQuitHandler(
        new QuitHandler() {
          public void handleQuitRequestWith(QuitEvent event, QuitResponse response) {
            sketch.exit();
            if (!attemptedQuit) {
              response.cancelQuit(); // we'll quit manually
              attemptedQuit = true;
            } else {
              response.performQuit(); // just force it this time
            }
          }
        });
  }
コード例 #3
0
ファイル: AppleUtil.java プロジェクト: hernad/spa-erp
  /*
   * JVM PARAMS -Xdock:name="Sustav Poslovnih Aplikacija"
   * -Xdock:icon=/path/to/icon
   */
  public static void bootInit() {
    System.out.println("invoking AppleUtil.bootInit ...");
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("apple.awt.showGrowBox", "false");
    // System.setProperty("apple.awt.brushMetalLook","true");
    System.setProperty("com.apple.macos.smallTabs", "true"); // 1.3 only
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "SPA");
    Application app = Application.getApplication();
    if (!app.isAboutMenuItemPresent()) {
      app.addAboutMenuItem();
    }
    app.setEnabledAboutMenu(true);
    if (!app.isPreferencesMenuItemPresent()) {
      app.addPreferencesMenuItem();
    }
    app.setEnabledPreferencesMenu(true);

    app.addApplicationListener(new SPAApplicationListener());
  }
コード例 #4
0
  public void initialiseApplication(final MainWindow mainWindow) {
    Application fApplication = Application.getApplication();
    fApplication.setEnabledPreferencesMenu(true);
    fApplication.setEnabledAboutMenu(true);
    fApplication.addApplicationListener(
        new ApplicationAdapter() {
          public void handleAbout(ApplicationEvent e) {
            mainWindow.getAboutMenuItem().doClick();
            e.setHandled(true);
          }

          public void handlePreferences(ApplicationEvent e) {
            mainWindow.getOptionsButton().doClick();
            e.setHandled(true);
          }

          public void handleQuit(ApplicationEvent e) {
            mainWindow.getExitMenuItem().doClick();
            e.setHandled(true);
          }
        });
  }
コード例 #5
0
 public static void init() {
   Application application = Application.getApplication();
   application.setAboutHandler(
       new AboutHandler() {
         @Override
         public void handleAbout(AppEvent.AboutEvent aboutEvent) {
           new Thread(
                   () -> {
                     if (waitForBase()) {
                       Base.INSTANCE.handleAbout();
                     }
                   })
               .start();
         }
       });
   application.setPreferencesHandler(
       new PreferencesHandler() {
         @Override
         public void handlePreferences(AppEvent.PreferencesEvent preferencesEvent) {
           new Thread(
                   () -> {
                     if (waitForBase()) {
                       Base.INSTANCE.handlePrefs();
                     }
                   })
               .start();
         }
       });
   application.setOpenFileHandler(
       new OpenFilesHandler() {
         @Override
         public void openFiles(final AppEvent.OpenFilesEvent openFilesEvent) {
           new Thread(
                   () -> {
                     if (waitForBase()) {
                       for (File file : openFilesEvent.getFiles()) {
                         System.out.println(file);
                         try {
                           Base.INSTANCE.handleOpen(file);
                           List<Editor> editors = Base.INSTANCE.getEditors();
                           if (editors.size() == 2
                               && editors.get(0).getSketchController().isUntitled()) {
                             Base.INSTANCE.handleClose(editors.get(0));
                           }
                         } catch (Exception e) {
                           throw new RuntimeException(e);
                         }
                       }
                     }
                   })
               .start();
         }
       });
   application.setQuitHandler(
       new QuitHandler() {
         @Override
         public void handleQuitRequestWith(
             AppEvent.QuitEvent quitEvent, QuitResponse quitResponse) {
           new Thread(
                   () -> {
                     if (waitForBase()) {
                       if (Base.INSTANCE.handleQuit()) {
                         quitResponse.performQuit();
                       } else {
                         quitResponse.cancelQuit();
                       }
                     }
                   })
               .start();
         }
       });
 }
コード例 #6
0
 @SuppressWarnings("restriction")
 public static void appleForeground() {
   Application.getApplication().requestForeground(true);
 }
コード例 #7
0
 @SuppressWarnings("restriction")
 public static void doAppleFullscreen(JFrame window) {
   Application.getApplication().requestToggleFullScreen(window);
 }