Skip to content

Commit

Permalink
IDEA-113594 (OpenJDK notification refined)
Browse files Browse the repository at this point in the history
  • Loading branch information
trespasserw committed Oct 1, 2013
1 parent f3cc029 commit 91b97ed
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 88 deletions.
18 changes: 0 additions & 18 deletions bin/scripts/unix/idea.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,9 @@ fi

VERSION_LOG=`"$MKTEMP" -t java.version.log.XXXXXX`
"$JDK/bin/java" -version 2> "$VERSION_LOG"
"$GREP" 'OpenJDK' "$VERSION_LOG" > /dev/null
OPEN_JDK=$?
"$GREP" "64-Bit|x86_64" "$VERSION_LOG" > /dev/null
BITS=$?
"$RM" -f "$VERSION_LOG"
if [ $OPEN_JDK -eq 0 ]; then
echo "WARNING: You are launching the IDE using OpenJDK Java runtime."
echo
echo " ITS KNOWN TO HAVE PERFORMANCE AND GRAPHICS ISSUES!"
echo " SWITCH TO THE ORACLE(SUN) JDK BEFORE REPORTING PROBLEMS!"
echo
echo "NOTE: If you have both Oracle (Sun) JDK and OpenJDK installed"
echo " please validate either @@product_uc@@_JDK, JDK_HOME, or JAVA_HOME environment variable points to valid Oracle (Sun) JDK installation."
echo " See http://ow.ly/6TuKQ for more info on switching default JDK."
echo
echo "Press Enter to continue."
# ---------------------------------------------------------------------
# COMMENT LINE BELOW TO REMOVE PAUSE AFTER OPEN JDK WARNING
# ---------------------------------------------------------------------
read IGNORE
fi
if [ $BITS -eq 0 ]; then
BITS="64"
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,25 @@
*/
package com.intellij.openapi.components;

import org.jetbrains.annotations.NotNull;

/**
* Application-level component's implementation class may implement the <code>ApplicationComponent</code> interface.<br>
* It may have constructor with parameters that are also application components.
* See <a href=../../../../../plugins.html>plugins.html</a> for more information.
*/
public interface ApplicationComponent extends BaseComponent {
class Adapter implements ApplicationComponent {
@NotNull
@Override
public String getComponentName() {
return getClass().getSimpleName();
}

@Override
public void disposeComponent() { }

@Override
public void initComponent() { }
}
}
68 changes: 0 additions & 68 deletions platform/platform-impl/src/com/intellij/ide/OpenJdkNotifier.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide;

import com.intellij.openapi.application.Application;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.awt.RelativePoint;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.awt.*;

public class SystemHealthMonitor extends ApplicationComponent.Adapter {
public SystemHealthMonitor(@NotNull Application application) {
checkJdk(application);
}

private static void checkJdk(final Application app) {
String vmName = System.getProperty("java.vm.name");
if (vmName != null && StringUtil.containsIgnoreCase(vmName, "OpenJDK") && !SystemInfo.isJavaVersionAtLeast("1.7")) {
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
@Override
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
app.invokeLater(new Runnable() {
public void run() {
notifyWrongJavaVersion();
}
});
}
});
}
}

private static void notifyWrongJavaVersion() {
JComponent component = WindowManager.getInstance().findVisibleFrame().getRootPane();
if (component != null) {
Rectangle rect = component.getVisibleRect();
JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder(IdeBundle.message("unsupported.jdk.message"), MessageType.WARNING, null)
.setFadeoutTime(-1)
.setHideOnFrameResize(false)
.createBalloon()
.show(new RelativePoint(component, new Point(rect.x + 30, rect.y + rect.height - 10)), Balloon.Position.above);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,8 @@ FileChooser.refreshActionLabelText=Refresh
browsers.settings=Web Browsers
updates.check.period.on.exit=On every exit

use.sun.jdk.prompt=Java version is not supported, please use Sun/Oracle JDK rather than OpenJDK
unsupported.jdk.message=OpenJDK 6 is not supported. Please use Oracle Java or newer OpenJDK.

prompt.goto.inspection.enter.name=Enter inspection name:
goto.inspection.action.text=&Run Inspection by Name...
label.no.inspections.found=No inspections found
Expand Down
4 changes: 4 additions & 0 deletions platform/platform-resources/src/componentSets/Platform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
<implementation-class>com.intellij.util.net.HttpConfigurable</implementation-class>
</component>

<component>
<implementation-class>com.intellij.ide.SystemHealthMonitor</implementation-class>
<headless-implementation-class/>
</component>
</application-components>

<project-components>
Expand Down

0 comments on commit 91b97ed

Please sign in to comment.