コード例 #1
0
 /**
  * @return default LookAndFeelInfo for the running OS. For Win32 and Linux the method returns
  *     Alloy LAF or IDEA LAF if first not found, for Mac OS X it returns Aqua RubyMine uses Native
  *     L&F for linux as well
  */
 private UIManager.LookAndFeelInfo getDefaultLaf() {
   final String systemLafClassName = UIManager.getSystemLookAndFeelClassName();
   if (SystemInfo.isMac) {
     UIManager.LookAndFeelInfo laf = findLaf(systemLafClassName);
     LOG.assertTrue(laf != null);
     return laf;
   }
   if (PlatformUtils.isRubyMine() || PlatformUtils.isPyCharm()) {
     final String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
     if ("gnome".equals(desktop)) {
       UIManager.LookAndFeelInfo laf = findLaf(systemLafClassName);
       if (laf != null) {
         return laf;
       }
       LOG.info("Could not find system look and feel: " + laf);
     }
   }
   // Default
   final String defaultLafName = StartupUtil.getDefaultLAF();
   if (defaultLafName != null) {
     UIManager.LookAndFeelInfo defaultLaf = findLaf(defaultLafName);
     if (defaultLaf != null) {
       return defaultLaf;
     }
   }
   UIManager.LookAndFeelInfo ideaLaf =
       findLaf(
           isIntelliJLafEnabled() ? IntelliJLaf.class.getName() : IdeaLookAndFeelInfo.CLASS_NAME);
   if (ideaLaf != null) {
     return ideaLaf;
   }
   throw new IllegalStateException("No default look&feel found");
 }
コード例 #2
0
  /** Invoked via reflection. */
  LafManagerImpl() {
    myListenerList = new EventListenerList();

    List<UIManager.LookAndFeelInfo> lafList = ContainerUtil.newArrayList();

    if (SystemInfo.isMac) {
      if (Registry.is("ide.mac.yosemite.laf")
          && isIntelliJLafEnabled()
          && SystemInfo.isJavaVersionAtLeast("1.8")) {
        lafList.add(new UIManager.LookAndFeelInfo("Default", IntelliJLaf.class.getName()));
      } else {
        lafList.add(
            new UIManager.LookAndFeelInfo("Default", UIManager.getSystemLookAndFeelClassName()));
      }
    } else {
      if (isIntelliJLafEnabled()) {
        lafList.add(new IntelliJLookAndFeelInfo());
      } else {
        lafList.add(new IdeaLookAndFeelInfo());
      }
      for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        String name = laf.getName();
        if (!"Metal".equalsIgnoreCase(name)
            && !"CDE/Motif".equalsIgnoreCase(name)
            && !"Nimbus".equalsIgnoreCase(name)
            && !"Windows Classic".equalsIgnoreCase(name)
            && !name.startsWith("JGoodies")) {
          lafList.add(laf);
        }
      }
    }

    lafList.add(new DarculaLookAndFeelInfo());

    myLaFs = lafList.toArray(new UIManager.LookAndFeelInfo[lafList.size()]);

    if (!SystemInfo.isMac) {
      // do not sort LaFs on mac - the order is determined as Default, Darcula.
      // when we leave only system LaFs on other OSes, the order also should be determined as
      // Default, Darcula

      Arrays.sort(
          myLaFs,
          new Comparator<UIManager.LookAndFeelInfo>() {
            @Override
            public int compare(UIManager.LookAndFeelInfo obj1, UIManager.LookAndFeelInfo obj2) {
              String name1 = obj1.getName();
              String name2 = obj2.getName();
              return name1.compareToIgnoreCase(name2);
            }
          });
    }

    myCurrentLaf = getDefaultLaf();
  }