Java Code Examples for com.intellij.openapi.util.SystemInfo#isJavaVersionAtLeast()

The following examples show how to use com.intellij.openapi.util.SystemInfo#isJavaVersionAtLeast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemDockImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public SystemDockImpl() {
  if (Platform.current().isWebService()) {
    myDelegate = () -> {
    };
  }
  else if (SystemInfo.isMac) {
    if (SystemInfo.isJavaVersionAtLeast(9, 0, 0)) {
      myDelegate = new Java9DockDelegateImpl();
    }
    else {
      myDelegate = new MacDockDelegate();
    }
  }
  else if (SystemInfo.isWin7OrNewer) {
    myDelegate = new WinDockDelegate();
  }
  else {
    myDelegate = () -> {
    };
  }
}
 
Example 2
Source File: IdeFrameDecorator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@ReviewAfterMigrationToJRE(9)
public static IdeFrameDecorator decorate(@Nonnull IdeFrameEx frame) {
  // we can't use internal api for fullscreen
  if (SystemInfo.isJavaVersionAtLeast(9)) {
    return new AWTFrameDecorator(frame);
  }

  if (SystemInfo.isMac) {
    return new MacMainFrameDecorator(frame, false);
  }
  else if (SystemInfo.isWindows) {
    return new AWTFrameDecorator(frame);
  }
  else if (SystemInfo.isXWindow) {
    if (X11UiUtil.isFullScreenSupported()) {
      return new EWMHFrameDecorator(frame);
    }
  }

  return null;
}
 
Example 3
Source File: MacOSDefaultMenuInitializer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
@ReviewAfterMigrationToJRE(9)
public MacOSDefaultMenuInitializer(AboutManager aboutManager, DataManager dataManager, WindowManager windowManager) {
  myAboutManager = aboutManager;
  myDataManager = dataManager;
  myWindowManager = windowManager;
  if (SystemInfo.isMac) {
    try {
      ThrowableRunnable<Throwable> task = SystemInfo.isJavaVersionAtLeast(9) ? new Java9Worker(this::showAbout) : new PreJava9Worker(this::showAbout);

      task.run();

      installAutoUpdateMenu();
    }
    catch (Throwable t) {
      LOGGER.warn(t);
    }
  }
}
 
Example 4
Source File: SheetController.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * This method is used to show an image during message showing
 * @return image to show
 */
Image getStaticImage() {
  final JFrame myOffScreenFrame = new JFrame() ;
  myOffScreenFrame.add(mySheetPanel);
  myOffScreenFrame.getRootPane().setDefaultButton(myDefaultButton);

  final BufferedImage image = SystemInfo.isJavaVersionAtLeast(7, 0, 0) ?
                              UIUtil.createImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT, BufferedImage.TYPE_INT_ARGB) :
                              GraphicsUtilities.createCompatibleTranslucentImage(SHEET_NC_WIDTH, SHEET_NC_HEIGHT);

  Graphics g = image.createGraphics();
  mySheetPanel.paint(g);

  g.dispose();

  myOffScreenFrame.remove(mySheetPanel);

  myOffScreenFrame.dispose();
  return image;
}
 
Example 5
Source File: AddFilterRuleDialog.java    From AndroidStringsOneTabTranslation with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    if (Messages.isMacSheetEmulation()) {
        setInitialLocationCallback(new Computable<Point>() {
            @Override
            public Point compute() {
                JRootPane rootPane = SwingUtilities.getRootPane(getWindow().getParent());
                if (rootPane == null) {
                    rootPane = SwingUtilities.getRootPane(getWindow().getOwner());
                }

                Point p = rootPane.getLocationOnScreen();
                p.x += (rootPane.getWidth() - getWindow().getWidth()) / 2;
                return p;
            }
        });
        animate();
        if (SystemInfo.isJavaVersionAtLeast("1.7")) {
            try {
                Method method = Class.forName("java.awt.Window").getDeclaredMethod("setOpacity", float.class);
                if (method != null) method.invoke(getPeer().getWindow(), .8f);
            } catch (Exception exception) {
            }
        }
        setAutoAdjustable(false);
        setSize(getPreferredSize().width, 0);//initial state before animation, zero height
    }
    super.show();
}
 
Example 6
Source File: MultiSelectDialog.java    From AndroidStringsOneTabTranslation with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    if (Messages.isMacSheetEmulation()) {
        setInitialLocationCallback(new Computable<Point>() {
            @Override
            public Point compute() {
                JRootPane rootPane = SwingUtilities.getRootPane(getWindow().getParent());
                if (rootPane == null) {
                    rootPane = SwingUtilities.getRootPane(getWindow().getOwner());
                }

                Point p = rootPane.getLocationOnScreen();
                p.x += (rootPane.getWidth() - getWindow().getWidth()) / 2;
                return p;
            }
        });
        animate();
        if (SystemInfo.isJavaVersionAtLeast("1.7")) {
            try {
                Method method = Class.forName("java.awt.Window").getDeclaredMethod("setOpacity", float.class);
                if (method != null) method.invoke(getPeer().getWindow(), .8f);
            } catch (Exception exception) {
            }
        }
        setAutoAdjustable(false);
        setSize(getPreferredSize().width, 0);//initial state before animation, zero height
    }
    super.show();
}
 
Example 7
Source File: SmbDeployerRunner.java    From teamcity-deployer-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected BuildProcess getDeployerProcess(@NotNull final BuildRunnerContext context,
                                          @NotNull final String username,
                                          @NotNull final String password,
                                          @NotNull final String target,
                                          @NotNull final List<ArtifactsCollection> artifactsCollections) {

  try {
    final String domain;
    final String actualUsername;

    if (username.indexOf('\\') > -1) {
      domain = username.substring(0, username.indexOf('\\'));
      actualUsername = username.substring(username.indexOf('\\') + 1);
    } else {
      domain = "";
      actualUsername = username;
    }

    if (shouldEnforceSMBv1(context)) {
      context.getBuild().getBuildLogger().warning("Enforced deprecated SMB v1 usage");
      return getSmbV1Process(context, actualUsername, password, domain, target, artifactsCollections);
    }

    if (SystemInfo.isJavaVersionAtLeast("1.7.0")) {
        context.getBuild().getBuildLogger().message("Using SMB v2/v3 protocol");
        return getSmbV2Process(context, actualUsername, password, domain, target,artifactsCollections);
    } else {
      context.getBuild().getBuildLogger().warning("Falling back to deprecated SMB v1. Update jvm to 1.7+ to use SMB v2");
      return getSmbV1Process(context, actualUsername, password, domain, target, artifactsCollections);
    }

  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example 8
Source File: Messages.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
  if (isMacSheetEmulation()) {
    setInitialLocationCallback(new Computable<Point>() {
      @Override
      public Point compute() {
        JRootPane rootPane = SwingUtilities.getRootPane(getWindow().getParent());
        if (rootPane == null) {
          rootPane = SwingUtilities.getRootPane(getWindow().getOwner());
        }

        Point p = rootPane.getLocationOnScreen();
        p.x += (rootPane.getWidth() - getWindow().getWidth()) / 2;
        return p;
      }
    });
    animate();
    if (SystemInfo.isJavaVersionAtLeast(7, 0, 0)) {
      try {
        Method method = Class.forName("java.awt.Window").getDeclaredMethod("setOpacity", float.class);
        if (method != null) method.invoke(getPeer().getWindow(), .8f);
      }
      catch (Exception exception) {
      }
    }
    setAutoAdjustable(false);
    setSize(getPreferredSize().width, 0);//initial state before animation, zero height
  }
  super.show();
}
 
Example 9
Source File: ActionMenu.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isTopMenuBarAfterOpenJDKMemLeakFix() {
  if (isTopMenuBar()) {
    // looks like openjdk backport fix from jdk 10
    // 181 - when bug from jdk 10 reported. maybe build lower
    if (SystemInfo.isJavaVersionAtLeast(8, 0, 181)) {
      return true;
    }

    // jdk 10 have initial change in screen menu
    if (SystemInfo.isJavaVersionAtLeast(10, 0, 0)) {
      return true;
    }
  }
  return false;
}
 
Example 10
Source File: ToolkitBugsProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean process(Throwable e, StackTraceElement[] stack) {
  if (e instanceof NullPointerException && stack.length > 3) {
    //bombed for possible future fix
    if (SystemInfo.isJavaVersionAtLeast(7, 0, 0)) return false;

    return stack[0].getClassName().equals("java.util.Hashtable")
           && stack[0].getMethodName().equals("put")
           && stack[3].getClassName().equals("javax.swing.JEditorPane")
           && stack[3].getMethodName().equals("loadDefaultKitsIfNecessary");
  }
  return false;
}
 
Example 11
Source File: LafManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void fixGtkPopupStyle() {
  if (!UIUtil.isUnderGTKLookAndFeel()) return;

  // it must be instance of com.sun.java.swing.plaf.gtk.GTKStyleFactory, but class package-local
  if (SystemInfo.isJavaVersionAtLeast(10, 0, 0)) {
    return;
  }

  final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();

  SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {
    @Override
    public SynthStyle getStyle(final JComponent c, final Region id) {
      final SynthStyle style = original.getStyle(c, id);
      if (id == Region.POPUP_MENU) {
        final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
        if (x != null && x == 0) {
          // workaround for Sun bug #6636964
          ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
          ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
        }
      }
      return style;
    }
  });

  new JBPopupMenu();  // invokes updateUI() -> updateStyle()

  SynthLookAndFeel.setStyleFactory(original);
}
 
Example 12
Source File: JDK7WindowReorderingWorkaround.java    From consulo with Apache License 2.0 4 votes vote down vote up
static void disableReordering() {
  if (SystemInfo.isJavaVersionAtLeast(7, 0, 0)) {
    requestorCount.incrementAndGet();
  }
}
 
Example 13
Source File: JDK7WindowReorderingWorkaround.java    From consulo with Apache License 2.0 4 votes vote down vote up
static void enableReordering () {
  if (SystemInfo.isJavaVersionAtLeast(7, 0, 0)) {
    requestorCount.decrementAndGet();
  }
}
 
Example 14
Source File: SubstanceLafProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Consumer<UIManager.LookAndFeelInfo> consumer) {
  if (SystemInfo.isJavaVersionAtLeast(9)) {
    addSubstanceLookAndFeel(consumer);
  }
}