mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-113594 (OpenJDK notification refined)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
@@ -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() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.ApplicationManager;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class OpenJdkNotifier {
|
||||
public static void checkJdk(MessageBus bus) {
|
||||
final String vendor = System.getProperty("java.vendor").toLowerCase();
|
||||
if (!vendor.contains("sun") && !vendor.contains("apple") && !vendor.contains("oracle")) {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
@Override
|
||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
showWrongJavaVersionBaloon();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void showWrongJavaVersionBaloon() {
|
||||
// Just a copy paste from ChangesViewBaloonProblemNotifier
|
||||
final JFrame frame = WindowManager.getInstance().findVisibleFrame();
|
||||
final JComponent component = frame.getRootPane();
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
final Rectangle rect = component.getVisibleRect();
|
||||
final Point p = new Point(rect.x + 30, rect.y + rect.height - 10);
|
||||
final RelativePoint point = new RelativePoint(component, p);
|
||||
|
||||
final MessageType messageType = MessageType.ERROR;
|
||||
final BalloonBuilder builder = JBPopupFactory.getInstance()
|
||||
.createHtmlTextBalloonBuilder(IdeBundle.message("use.sun.jdk.prompt"), messageType.getDefaultIcon(), messageType.getPopupBackground(),
|
||||
null);
|
||||
builder.setFadeoutTime(-1);
|
||||
builder.createBalloon().show(point, Balloon.Position.above);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user