/**
   * 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();
  }
Exemplo n.º 2
1
 static {
   if (Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
Exemplo n.º 3
0
  private static JEditorPane createEditorPane() {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    System.setProperty("http.proxyHost", "cache.univ-lille1.fr");
    System.setProperty("http.proxyPort", "3128");
    editorPane.setPreferredSize(new Dimension(300, 200));

    java.net.URL lille1URL = null;
    try {
      lille1URL = new java.net.URL("http://www.google.com");
    } catch (MalformedURLException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    if (lille1URL != null) {
      try {
        editorPane.setPage(lille1URL);
      } catch (IOException e) {
        System.err.println("Attempted to read a bad URL: " + lille1URL);
      }
    } else {
      System.err.println("Couldn't find file: http://www.google.com");
    }

    return editorPane;
  }
 static {
   if (gov.nasa.worldwind.Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty(
         "com.apple.mrj.application.apple.menu.about.name", "World Wind Multi-Window Analysis");
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
  static {
    // Put JOGL version information into system properties to
    // assist in debugging.
    Package joglPackage = Package.getPackage("javax.media.opengl");
    System.setProperty("jogl.specification.version", joglPackage.getSpecificationVersion());
    System.setProperty("jogl.implementation.version", joglPackage.getImplementationVersion());

    ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
  }
Exemplo n.º 6
0
 private static void setLookAndFeel() {
   OperatingSystem os = OperatingSystem.getOperatingSystem();
   if (os.equals(OperatingSystem.OSX)) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Love Launcher");
   }
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
     logger.log(Level.WARNING, "Failed to setup look and feel", e);
   }
 }
Exemplo n.º 7
0
 private static void initSystemProperties() {
   // currently we support IPv4 only
   System.setProperty("java.net.preferIPv4Stack", "true");
   // disable DNS caches
   Security.setProperty("networkaddress.cache.ttl", "0");
   Security.setProperty("networkaddress.cache.negative.ttl", "0");
 }
  public static void importConfigsTo(@NotNull String newConfigPath) {
    ConfigImportSettings settings = getConfigImportSettings();

    File newConfigDir = new File(newConfigPath);
    File oldConfigDir = findOldConfigDir(newConfigDir, settings.getCustomPathsSelector());
    do {
      ImportOldConfigsPanel dialog = new ImportOldConfigsPanel(oldConfigDir, settings);
      dialog.setModalityType(Dialog.ModalityType.TOOLKIT_MODAL);
      AppUIUtil.updateWindowIcon(dialog);
      dialog.setVisible(true);
      if (dialog.isImportEnabled()) {
        File installationHome = dialog.getSelectedFile();
        oldConfigDir = getOldConfigDir(installationHome, settings);
        if (!validateOldConfigDir(installationHome, oldConfigDir, settings)) {
          continue;
        }

        assert oldConfigDir != null;
        doImport(newConfigDir, oldConfigDir, settings, installationHome);
        settings.importFinished(newConfigPath);
        System.setProperty(CONFIG_IMPORTED_IN_CURRENT_SESSION_KEY, Boolean.TRUE.toString());
      }

      break;
    } while (true);
  }
 private static void patchSystemFileEncoding(String encoding)
     throws NoSuchFieldException, IllegalAccessException {
   Field charset = Charset.class.getDeclaredField("defaultCharset");
   charset.setAccessible(true);
   charset.set(Charset.class, null);
   System.setProperty("file.encoding", encoding);
 }
Exemplo n.º 10
0
 /**
  * Initializes Swing's look and feel to the system native look and feel. On Mac, uses the system
  * menu bar.
  */
 private void initLookAndFeel() {
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception ignored) {
   }
   System.setProperty("apple.laf.useScreenMenuBar", "true");
   UIManager.put("Table.alternateRowColor", new Color(243, 246, 250));
 }
Exemplo n.º 11
0
  private void setLookAndFeel() {
    // TODO: De volgende werkt nog niet (appname in title balk)

    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);

    try {
      // Native platform Look and Feel
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

      // Cross platform Look and Feel
      //            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (ClassNotFoundException
        | InstantiationException
        | UnsupportedLookAndFeelException
        | IllegalAccessException e) {
      System.out.println(e.getMessage());
    }
  }
Exemplo n.º 12
0
  public static void main(String[] args) {
    // Set application name and system menu bar on Mac OS X
    String os = System.getProperty("os.name");
    if (os.contains("Mac OS X")) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
      // The next line doesn't work in recent JVMs on OS X,
      // so we also include -Xdock:name="App name" in the runtime config
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
      // use the Apple/Command key for command shortcuts
      primaryCommandKey = ActionEvent.META_MASK;
      runningOnMacOSX = true;
    } else {
      // use the Control key for command shortcuts
      primaryCommandKey = ActionEvent.CTRL_MASK;
      runningOnMacOSX = false;
    }

    // create main window
    new SudokuSolverApp().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Exemplo n.º 13
0
  public void initGui()
      throws ClassNotFoundException, InstantiationException, IllegalAccessException,
          UnsupportedLookAndFeelException {
    System.setProperty("prism.lcdtext", "false");
    UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    app = new DesktopClientGui(services, runtimeConfiguration);

    cancelButton =
        new ButtonType(getResources().getString("updateCancel"), ButtonBar.ButtonData.CANCEL_CLOSE);
    updateButton =
        new ButtonType(getResources().getString("updateStart"), ButtonBar.ButtonData.APPLY);
  }
Exemplo n.º 14
0
  /**
   * ������ѡ����
   *
   * @param cp ����Ҫ�ı�Ŀؼ�
   * @param style ���ܽ����±�
   * @return ���سɹ��������
   */
  public static boolean setUI(Component cp, int style) {

    try {
      switch (style) {
        case 0:
          UIManager.setLookAndFeel("com.sun.java.swing.plaf." + "windows.WindowsLookAndFeel");
          break;
        case 1:
          UIManager.setLookAndFeel("javax.swing.plaf." + "metal.MetalLookAndFeel");
          break;
        case 2:
          UIManager.setLookAndFeel("com.sun.java.swing.plaf." + "motif.MotifLookAndFeel");
          break;
        case 3:
          UIManager.setLookAndFeel(
              "com.sun.java.swing.plaf." + "windows.WindowsClassicLookAndFeel");
          break;
        case 4:
          UIManager.setLookAndFeel("com.incors.plaf." + "alloy.AlloyLookAndFeel");
          break;
        case 5:
          UIManager.setLookAndFeel("soft.wes.feels." + "GlassThemeAlloyLookAndFeel");
          break;
        case 6:
          UIManager.setLookAndFeel("soft.wes.feels." + "AcidThemeAlloyLookAndFeel");
          break;
        case 7:
          UIManager.setLookAndFeel("soft.wes.feels." + "BedouinThemeAlloyLookAndFeel");
          break;
        case 8:
          UIManager.setLookAndFeel("soft.wes.feels." + "DefaultThemeAlloyLookAndFeel");
          break;
        case 9:
          UIManager.put("swing.boldMetal", Boolean.FALSE);
          // �����öԻ������
          JDialog.setDefaultLookAndFeelDecorated(true);
          // �������������
          JFrame.setDefaultLookAndFeelDecorated(true);
          Toolkit.getDefaultToolkit().setDynamicLayout(true);
          System.setProperty("sun.awt.noerasebackground", "true");
          UIManager.setLookAndFeel(new MetalLookAndFeel());
          break;
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(null, "����ʧ��,��ԭ�����ʾ");
      return false;
    }
    SwingUtilities.updateComponentTreeUI(cp);
    cp.repaint();

    return true;
  }
Exemplo n.º 15
0
 public static void main(String[] args) {
   System.setProperty("java.security.policy", "permissions/PermissionTest.policy");
   System.setSecurityManager(new SecurityManager());
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           JFrame frame = new PermissionTestFrame();
           frame.setTitle("PermissionTest");
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
         }
       });
 }
Exemplo n.º 16
0
 private JWebBrowser createWebBrowser() {
   try {
     if (!NativeInterface.isOpen()) throw new Exception("Native Interface is not initialized");
     JWebBrowser browser;
     if (Platform.isLinux()) {
       if (Platform.is64Bit()) {
         try {
           System.setProperty("org.eclipse.swt.browser.UseWebKitGTK", "true");
           // System.setProperty("nativeswing.webbrowser.runtime", "webkit");
           browser = new JWebBrowser(JWebBrowser.useWebkitRuntime());
           log.info("Using WebKit runtime to create WebBrowser");
         } catch (IllegalStateException e) {
           System.clearProperty("org.eclipse.swt.browser.UseWebKitGTK");
           browser = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
           log.info("Using XULRunner runtime to create WebBrowser: " + e.getMessage());
         }
       } else {
         try {
           System.setProperty("org.eclipse.swt.browser.UseWebKitGTK", "true");
           browser = new JWebBrowser(JWebBrowser.useWebkitRuntime());
           log.info("Using WebKit runtime to create WebBrowser");
         } catch (IllegalStateException e) {
           System.clearProperty("org.eclipse.swt.browser.UseWebKitGTK");
           browser = new JWebBrowser(JWebBrowser.useXULRunnerRuntime());
           log.info("Using XULRunner runtime to create WebBrowser: " + e.getMessage());
         }
       }
     } else {
       browser = new JWebBrowser();
     }
     browser.setBarsVisible(false);
     browser.setJavascriptEnabled(true);
     return browser;
   } catch (Throwable t) {
     log.severe("Cannot create WebBrowser: " + t.getMessage());
     setInitializationCause(t);
     return null;
   }
 }
Exemplo n.º 17
0
  /** 利用属性文件中的信息连接数据库 * */
  public static Connection getConnection() throws SQLException, IOException {
    Properties props = new Properties();
    String fileName = "QueryDB.properties";
    FileInputStream in = new FileInputStream(fileName);
    props.load(in);

    String drivers = props.getProperty("jdbc.drivers");
    if (drivers != null) System.setProperty("jdbc.drivers", drivers);
    String url = props.getProperty("jdbc.url");
    String username = props.getProperty("jdbc.username");
    String password = props.getProperty("jdbc.password");

    return DriverManager.getConnection(url, username, password);
  }
Exemplo n.º 18
0
  private static void initUserInterface() {
    System.setProperty("apple.laf.useScreenMenuBar", "true");
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Draw 9-patch");
    try {
      if (Platform.isWindows()) {
        UIManager.put("RootPane.setupButtonVisible", false);
        BeautyEyeLNFHelper.translucencyAtFrameInactive = false;
        BeautyEyeLNFHelper.launchBeautyEyeLNF();

        // impl a demo PopupFactory
        PopupFactory.setSharedInstance(new CoolPopupFactory());
      } else UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 19
0
  /** Sets some ui properties and loads oroperties from .whatswrong */
  static {
    System.setProperty("apple.laf.useScreenMenuBar", "true");

    try {
      File file = new File(System.getProperty("user.home") + "/.whatswrong");
      if (file.exists()) {
        properties.load(new FileInputStream(file));
      } else {
        properties.setProperty("whatswrong.golddir", System.getProperty("user.dir"));
        properties.setProperty("whatswrong.guessdir", System.getProperty("user.dir"));
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 20
0
  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    LauncherDirectories directories = new LauncherDirectories();
    Directories.instance = directories;

    // Prefer IPv4
    System.setProperty("java.net.preferIPv4Stack", "true");

    params = setupParameters(args);

    cleanup();

    SplashScreen splash =
        new SplashScreen(
            Toolkit.getDefaultToolkit()
                .getImage(
                    SplashScreen.class.getResource(
                        "/org/spoutcraft/launcher/resources/splash.png")));
    splash.setVisible(true);
    directories.setSplashScreen(splash);

    MetalLookAndFeel.setCurrentTheme(new OceanTheme());
    setLookAndFeel();

    console = new Console(params.isConsole());
    SpoutcraftLauncher.logger = setupLogger();
    console.setRotatingFileHandler(SpoutcraftLauncher.handler);

    int launcherBuild = parseInt(getLauncherBuild(), -1);
    logger.info("------------------------------------------");
    logger.info("Love Launcher is starting....");
    logger.info("Launcher Build: " + launcherBuild);

    params.logParameters(logger);

    Runtime.getRuntime().addShutdownHook(new ShutdownThread(console));

    // Set up the launcher and load login frame
    Launcher launcher = new Launcher();

    splash.dispose();
    launcher.startup();

    logger.info("Launcher took: " + (System.currentTimeMillis() - start) + "ms to start");
  }
Exemplo n.º 21
0
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", Boolean.valueOf(myActive).toString());
        if (active) {
          myDispatcher.getMulticaster().applicationActivated(ideFrame);
        } else {
          myDispatcher.getMulticaster().applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", myActive.toString());
        ApplicationActivationListener publisher =
            getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC);
        if (active) {
          publisher.applicationActivated(ideFrame);
        } else {
          publisher.applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
Exemplo n.º 23
0
 /** @param args the command line arguments */
 public static void main(String args[]) {
   System.setProperty("entityExpansionLimit", "1000000");
   try (InputStream is = JmdictToDsl.class.getResourceAsStream("/logging.properties")) {
     LogManager.getLogManager().readConfiguration(is);
   } catch (IOException | SecurityException ex) {
     logger.log(Level.SEVERE, null, ex);
     System.exit(1);
   }
   SwingUtilities.invokeLater(
       () -> {
         try {
           UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
           new JmdictToDsl();
         } catch (ClassNotFoundException
             | InstantiationException
             | IllegalAccessException
             | UnsupportedLookAndFeelException ex) {
           logger.log(Level.SEVERE, null, ex);
         }
       });
 }
Exemplo n.º 24
0
  private DarkBotMCSpambot(
      DarkBot darkBot,
      String server,
      String username,
      String password,
      String sessionId,
      String loginProxy,
      String proxy,
      String owner) {
    synchronized (bots) {
      bots.add(this);
      // slotsTaken.incrementAndGet();
      synchronized (slotsTaken) {
        slotsTaken.notifyAll();
      }
    }
    MinecraftBotData.Builder builder = MinecraftBotData.builder();
    // botData.nickname = "";
    // for(int i = 0; i < 10; i++)
    // botData.nickname += alphas[random.nextInt(alphas.length)];
    if (proxy != null && !proxy.isEmpty()) {
      int port = 80;
      ProxyType type = ProxyType.SOCKS;
      if (proxy.contains(":")) {
        String[] parts = proxy.split(":");
        proxy = parts[0];
        port = Integer.parseInt(parts[1]);
        if (parts.length > 2) type = ProxyType.values()[Integer.parseInt(parts[2]) - 1];
      }
      builder.withSocksProxy(new ProxyData(proxy, port, type));
      this.proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxy, port));
    }
    if (loginProxy != null && !loginProxy.isEmpty()) {
      int port = 80;
      if (loginProxy.contains(":")) {
        String[] parts = loginProxy.split(":");
        loginProxy = parts[0];
        port = Integer.parseInt(parts[1]);
      }
      builder.withHttpProxy(new ProxyData(loginProxy, port, ProxyType.HTTP));
      this.loginProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(loginProxy, port));
    }
    builder.withUsername(username);
    if (sessionId != null) builder.withSessionId(sessionId);
    else builder.withPassword(password);
    if (server != null && !server.isEmpty()) {
      int port = 25565;
      if (server.contains(":")) {
        String[] parts = server.split(":");
        server = parts[0];
        port = Integer.parseInt(parts[1]);
      }
      builder.withServer(server).withPort(port);
    } else throw new IllegalArgumentException("Unknown server!");

    this.owner = owner;
    MinecraftBotData botData = builder.build();
    System.setProperty("socksProxyHost", "");
    System.setProperty("socksProxyPort", "");
    System.out.println("[" + username + "] Connecting...");
    bot = new MinecraftBot(darkBot, botData);
    bot.setMovementDisabled(true);
    connectionHandler = bot.getConnectionHandler();
    Session session = bot.getSession();
    // System.gc();
    System.out.println("[" + username + "] Done! (" + amountJoined.incrementAndGet() + ")");
    bot.getEventManager().registerListener(this);
    bot.getGameHandler().registerListener(this);

    long lastShoutTime = System.currentTimeMillis();
    while (bot.isConnected()) {
      if (die) {
        connectionHandler.sendPacket(new Packet255KickDisconnect("Goodbye"));
        return;
      }
      try {
        Thread.sleep(3000 + random.nextInt(1000));
      } catch (InterruptedException exception) {
        exception.printStackTrace();
      }
      if (!bot.hasSpawned()) continue;
      connectionHandler.sendPacket(new Packet0KeepAlive(random.nextInt()));
      if (spamMessage == null || !canSpam) continue;
      String message = spamMessage;
      if (message.contains("%skill")) message = message.replace("%skill", skills[nextSkill++]);
      if (nextSkill >= skills.length) nextSkill = 0;
      if (message.contains("%bot")) {
        synchronized (bots) {
          message =
              message.replace(
                  "%bot",
                  bots.get(nextBot > bots.size() ? (nextBot = 0) * 0 : nextBot++)
                      .bot
                      .getSession()
                      .getUsername());
        }
      }
      if (message.contains("%spamlist"))
        message = message.replace("%spamlist", spamList[nextSpamList++]);
      if (nextSpamList >= spamList.length) nextSpamList = 0;
      if (message.contains("%rnd")) {
        int length = 1;
        int index = message.indexOf("%rnd") + "%rnd".length();
        int lastIndex;
        for (lastIndex = index; lastIndex < message.length(); lastIndex++)
          if (Character.isDigit(message.charAt(lastIndex))) lastIndex++;
          else break;
        if (lastIndex > message.length()) lastIndex--;
        try {
          System.out.println(index + "," + lastIndex + "," + message.length());
          length = Integer.parseInt(message.substring(index, lastIndex));
        } catch (Exception exception) {
        }

        String randomChars = "";
        for (int i = 0; i < length; i++) randomChars += alphas[random.nextInt(alphas.length)];
        message = message.replace("%rnd", randomChars);
      }
      if (message.contains("%msg"))
        message = "/msg " + msgChars[nextMsgChar++] + " " + message.replace("%msg", "");
      if (message.contains("%ernd")) {
        message = message.replace("%ernd", "");
        int extraMessageLength = 15 + random.nextInt(6);
        message = message.substring(0, Math.min(100 - extraMessageLength, message.length())) + " [";
        extraMessageLength -= 3;
        for (int i = 0; i < extraMessageLength; i++)
          message += alphas[random.nextInt(alphas.length)];
        message += "]";
      } else message = message.substring(0, Math.min(100, message.length()));
      connectionHandler.sendPacket(new Packet3Chat(message));
    }
    synchronized (bots) {
      bots.remove(this);
    }
    amountJoined.decrementAndGet();
    slotsTaken.decrementAndGet();
    synchronized (slotsTaken) {
      slotsTaken.notifyAll();
    }
  }
  /** Create tray icon and register frame listeners. */
  public void init() {
    // register error handler to avoid application crash on concurrent X access from SWT and AWT
    try {
      OS.gdk_error_trap_push();
    } catch (NoClassDefFoundError e) {
      // ignore
    }
    final String systemLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName();
    try {
      // workaround for bug when SWT and AWT both try to access Gtk
      if (systemLookAndFeelClassName.indexOf("gtk") >= 0) {
        System.setProperty("swing.defaultlaf", UIManager.getCrossPlatformLookAndFeelClassName());
      } else {
        System.setProperty("swing.defaultlaf", systemLookAndFeelClassName);
      }
    } catch (Exception e) {
      DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_SET_LOOK_AND_FEEL"));
    }

    new Thread("SWT") {
      @Override
      public void run() {
        try {
          display = new Display();
          shell = new Shell(display);

          final Tray tray = display.getSystemTray();
          if (tray != null) {

            trayItem = new TrayItem(tray, SWT.NONE);
            trayItem.setToolTipText(BundleMessage.format("UI_DAVMAIL_GATEWAY"));

            awtImage = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_PNG);
            image = loadSwtImage(AwtGatewayTray.TRAY_PNG);
            image2 = loadSwtImage(AwtGatewayTray.TRAY_ACTIVE_PNG);
            inactiveImage = loadSwtImage(AwtGatewayTray.TRAY_INACTIVE_PNG);

            trayItem.setImage(image);

            // create a popup menu
            final Menu popup = new Menu(shell, SWT.POP_UP);
            trayItem.addListener(
                SWT.MenuDetect,
                new Listener() {
                  public void handleEvent(Event event) {
                    display.asyncExec(
                        new Runnable() {
                          public void run() {
                            popup.setVisible(true);
                          }
                        });
                  }
                });

            MenuItem aboutItem = new MenuItem(popup, SWT.PUSH);
            aboutItem.setText(BundleMessage.format("UI_ABOUT"));
            aboutItem.addListener(
                SWT.Selection,
                new Listener() {
                  public void handleEvent(Event event) {
                    display.asyncExec(
                        new Runnable() {
                          public void run() {
                            if (aboutFrame == null) {
                              aboutFrame = new AboutFrame();
                            }
                            aboutFrame.update();
                            aboutFrame.setVisible(true);
                            aboutFrame.toFront();
                            aboutFrame.requestFocus();
                          }
                        });
                  }
                });

            trayItem.addListener(
                SWT.DefaultSelection,
                new Listener() {
                  public void handleEvent(Event event) {
                    display.asyncExec(
                        new Runnable() {
                          public void run() {
                            // create frame on first call
                            if (settingsFrame == null) {
                              settingsFrame = new SettingsFrame();
                            }
                            settingsFrame.reload();
                            settingsFrame.setVisible(true);
                            settingsFrame.toFront();
                            settingsFrame.requestFocus();
                          }
                        });
                  }
                });

            // create menu item for the default action
            MenuItem defaultItem = new MenuItem(popup, SWT.PUSH);
            defaultItem.setText(BundleMessage.format("UI_SETTINGS"));
            defaultItem.addListener(
                SWT.Selection,
                new Listener() {
                  public void handleEvent(Event event) {
                    display.asyncExec(
                        new Runnable() {
                          public void run() {
                            // create frame on first call
                            if (settingsFrame == null) {
                              settingsFrame = new SettingsFrame();
                            }
                            settingsFrame.reload();
                            settingsFrame.setVisible(true);
                            settingsFrame.toFront();
                            settingsFrame.requestFocus();
                          }
                        });
                  }
                });

            MenuItem logItem = new MenuItem(popup, SWT.PUSH);
            logItem.setText(BundleMessage.format("UI_SHOW_LOGS"));
            logItem.addListener(
                SWT.Selection,
                new Listener() {
                  public void handleEvent(Event event) {
                    display.asyncExec(
                        new Runnable() {
                          public void run() {

                            Logger rootLogger = Logger.getRootLogger();
                            LF5Appender lf5Appender =
                                (LF5Appender) rootLogger.getAppender("LF5Appender");
                            if (lf5Appender == null) {
                              logBrokerMonitor =
                                  new LogBrokerMonitor(LogLevel.getLog4JLevels()) {
                                    @Override
                                    protected void closeAfterConfirm() {
                                      hide();
                                    }
                                  };
                              lf5Appender = new LF5Appender(logBrokerMonitor);
                              lf5Appender.setName("LF5Appender");
                              rootLogger.addAppender(lf5Appender);
                            }
                            lf5Appender.getLogBrokerMonitor().show();
                          }
                        });
                  }
                });

            MenuItem exitItem = new MenuItem(popup, SWT.PUSH);
            exitItem.setText(BundleMessage.format("UI_EXIT"));
            exitItem.addListener(
                SWT.Selection,
                new Listener() {
                  public void handleEvent(Event event) {
                    DavGateway.stop();
                  }
                });

            // display settings frame on first start
            if (Settings.isFirstStart()) {
              // create frame on first call
              if (settingsFrame == null) {
                settingsFrame = new SettingsFrame();
              }
              settingsFrame.setVisible(true);
              settingsFrame.toFront();
              settingsFrame.requestFocus();
            }

            synchronized (mainThread) {
              // ready
              isReady = true;
              mainThread.notifyAll();
            }

            while (!shell.isDisposed()) {
              if (!display.readAndDispatch()) {
                display.sleep();
              }
            }

            dispose();
          }
        } catch (Exception exc) {
          DavGatewayTray.error(exc);
        }
        // make sure we do exit
        System.exit(0);
      }
    }.start();
    while (true) {
      // wait for SWT init
      try {
        synchronized (mainThread) {
          if (isReady) {
            break;
          }
          mainThread.wait(1000);
        }
      } catch (InterruptedException e) {
        DavGatewayTray.error(new BundleMessage("LOG_ERROR_WAITING_FOR_SWT_INIT"), e);
      }
    }
  }
Exemplo n.º 26
0
 static {
   System.setProperty("jbdt.test.fixture", "com.intellij.designer.dt.IJTestFixture");
 }
 private static void setPlatformPrefix(String prefix) {
   System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, prefix);
   ourPlatformPrefixInitialized = true;
 }
 private void init() {
   System.setProperty("sun.java2d.noddraw", "true");
   System.setProperty("sun.java2d.opengl", "true");
 }
Exemplo n.º 29
0
  protected void createAndShowGUI() {
    System.setProperty("swing.defaultlaf", UIManager.getSystemLookAndFeelClassName());

    image = DavGatewayTray.loadImage("tray.png");
    image2 = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_ACTIVE_PNG);
    inactiveImage = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_INACTIVE_PNG);

    mainFrame = new JFrame();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setTitle(BundleMessage.format("UI_DAVMAIL_GATEWAY"));
    mainFrame.setIconImage(image);

    JPanel errorPanel = new JPanel();
    errorPanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_MESSAGE")));
    errorPanel.setLayout(new BoxLayout(errorPanel, BoxLayout.X_AXIS));
    errorArea = new JTextPane();
    errorArea.setEditable(false);
    errorArea.setBackground(mainFrame.getBackground());
    errorLabel = new JLabel();
    errorPanel.add(errorLabel);
    errorPanel.add(errorArea);

    JPanel messagePanel = new JPanel();
    messagePanel.setBorder(BorderFactory.createTitledBorder(BundleMessage.format("UI_LAST_LOG")));
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.X_AXIS));

    messageArea = new JTextPane();
    messageArea.setText(BundleMessage.format("LOG_STARTING_DAVMAIL"));
    messageArea.setEditable(false);
    messageArea.setBackground(mainFrame.getBackground());
    messagePanel.add(messageArea);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(errorPanel);
    mainPanel.add(messagePanel);
    mainFrame.add(mainPanel);

    aboutFrame = new AboutFrame();
    settingsFrame = new SettingsFrame();
    buildMenu();

    mainFrame.setMinimumSize(new Dimension(400, 180));
    mainFrame.pack();
    // workaround MacOSX
    if (mainFrame.getSize().width < 400 || mainFrame.getSize().height < 180) {
      mainFrame.setSize(
          Math.max(mainFrame.getSize().width, 400), Math.max(mainFrame.getSize().height, 180));
    }
    // center frame
    mainFrame.setLocation(
        mainFrame.getToolkit().getScreenSize().width / 2 - mainFrame.getSize().width / 2,
        mainFrame.getToolkit().getScreenSize().height / 2 - mainFrame.getSize().height / 2);
    mainFrame.setVisible(true);

    // display settings frame on first start
    if (Settings.isFirstStart()) {
      settingsFrame.setVisible(true);
      settingsFrame.toFront();
      settingsFrame.requestFocus();
    }
  }
Exemplo n.º 30
0
  /**
   * Try to determine whether this application is running under Windows or some other platform by
   * examining the "os.name" property.
   */
  static {
    String os = System.getProperty("os.name");
    // String version = System.getProperty("os.version"); // for Win7, reports "6.0" on JDK7, should
    // be "6.1"; for Win8, reports "6.2" as of JDK7u17

    if (SystemUtils.startsWithIgnoreCase(os, "windows 7"))
      isWin7 = true; // reports "Windows Vista" on JDK7
    else if (SystemUtils.startsWithIgnoreCase(os, "windows 8"))
      isWin7 = true; // reports "Windows 8" as of JDK7u17
    else if (SystemUtils.startsWithIgnoreCase(os, "windows vista")) isVista = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows xp")) isWinXP = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows 2000")) isWin2k = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows nt")) isWinNT = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "windows"))
      isWin9X = true; // win95 or win98 (what about WinME?)
    else if (SystemUtils.startsWithIgnoreCase(os, "mac")) isMac = true;
    else if (SystemUtils.startsWithIgnoreCase(os, "so")) isSolaris = true; // sunos or solaris
    else if (os.equalsIgnoreCase("linux")) isLinux = true;
    else isUnix = true; // assume UNIX, e.g. AIX, HP-UX, IRIX

    String osarch = System.getProperty("os.arch");
    String arch = (osarch != null && osarch.contains("64")) ? "_x64" /* eg. 'amd64' */ : "_x32";
    String syslib = SYSLIB + arch;

    try { // loading a native lib in a static initializer ensures that it is available before any
          // method in this class is called:
      System.loadLibrary(syslib);
      System.out.println(
          "Done loading '" + System.mapLibraryName(syslib) + "', PID=" + getProcessID());
    } catch (Error e) {
      System.err.println(
          "Native library '"
              + System.mapLibraryName(syslib)
              + "' not found in 'java.library.path': "
              + System.getProperty("java.library.path"));
      throw e; // re-throw
    }

    if (isWinPlatform()) {
      System.setProperty(
          "line.separator", "\n"); // so we won't have to mess with DOS line endings ever again
      comSpec =
          getEnv(
              "comSpec"); // use native method here since getEnvironmentVariable() needs to know
                          // comSpec
      comSpec = (comSpec != null) ? comSpec + " /c " : "";

      try (BufferedReader br =
          new BufferedReader(
              new InputStreamReader(
                  RUNTIME.exec(comSpec + "ver").getInputStream()))) { // fix for Win7,8
        for (String line = null; (line = br.readLine()) != null; ) {
          if (isVista && (line.contains("6.1" /*Win7*/) || line.contains("6.2" /*Win8*/))) {
            isVista = false;
            isWin7 = true;
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }

      String cygdir = getEnv("cygdir"); // this is set during CygWin install to "?:/cygwin/bin"
      isCygWin = (cygdir != null && !cygdir.equals("%cygdir%"));
      cygstartPath = cygdir + "/cygstart.exe"; // path to CygWin's cygutils' "cygstart" binary

      if (getDebug() && Desktop.isDesktopSupported()) {
        Desktop desktop = Desktop.getDesktop();
        for (Desktop.Action action : Desktop.Action.values())
          System.out.println(
              "Desktop action " + action + " supported?  " + desktop.isSupported(action));
      }
    }
  }