Commit 61745b29 authored by Yuri Blankenstein's avatar Yuri Blankenstein
Browse files

Merge branch '16-support-java11' into 'develop'

Resolve "Support Java11"

Closes #16

See merge request !14
parents 2ead34f5 7dced18c
Pipeline #4389 passed with stage
in 0 seconds
......@@ -3,7 +3,7 @@ maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved,
maven/mavencentral/com.google.errorprone/error_prone_annotations/2.2.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.google.guava/failureaccess/1.0.1, Apache-2.0, approved, CQ22654
maven/mavencentral/com.google.guava/guava/27.1-jre, Apache-2.0 AND CC0-1.0, approved, CQ19110
maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, NONE, approved, #803
maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, LicenseRef-NONE, approved, #803
maven/mavencentral/com.google.inject/guice/3.0, Apache-2.0, approved, CQ5058
maven/mavencentral/com.google.j2objc/j2objc-annotations/1.1, Apache-2.0, approved, CQ18765
maven/mavencentral/io.github.classgraph/classgraph/4.8.35, MIT, approved, CQ22530
......
/*
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.trace4cps.common.jfreechart.ui.internal;
import static org.eclipse.core.runtime.IStatus.ERROR;
import static org.eclipse.trace4cps.common.jfreechart.ui.JFreeChartUIPlugin.PLUGIN_ID;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Stack;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.trace4cps.common.jfreechart.ui.JFreeChartUIPlugin;
/**
* Workaround for <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377104">Eclipse bug 377104</a> where frame
* activation is not being properly propagated into SWT on Java 7 and higher.
*/
public class SWT_AWT_PATCH_377104 extends WindowAdapter { // ignore checkstyle TypeNameCheck
private static final Method SHELL_SET_ACTIVE_CONTROL_METHOD;
static {
Method setActiveControlMethod = null;
try {
setActiveControlMethod = Shell.class.getDeclaredMethod("setActiveControl", Control.class);
setActiveControlMethod.setAccessible(true);
} catch (NoSuchMethodException | SecurityException e) {
String msg = "Patch for bug 377104 cannot be applied: "
+ "org.eclipse.swt.widgets.Shell#setActiveControl(org.eclipse.swt.widgets.Control) not available or accessible. "
+ "This will result in embedded workbench parts not getting activated.";
IStatus status = new Status(ERROR, PLUGIN_ID, msg, e);
JFreeChartUIPlugin.getDefault().getLog().log(status);
setActiveControlMethod = null;
}
SHELL_SET_ACTIVE_CONTROL_METHOD = setActiveControlMethod;
}
/**
* Creates a new <code>java.awt.Frame</code>. This frame is the root for the AWT components that will be embedded
* within the composite. In order for the embedding to succeed, the composite must have been created with the
* SWT.EMBEDDED style.
* <p>
* This method calls {@link SWT_AWT#new_Frame(Composite)} and applies a workaround for
* <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377104">Eclipse bug 377104</a> where frame activation is
* not being properly propagated into SWT on Java 7 and higher. The current Java version is not checked.
* </p>
*
* @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
* @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
* @exception IllegalArgumentException
* <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
* <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li>
* </ul>
* @see SWT_AWT#new_Frame(Composite)
*/
public static Frame new_Frame(Composite parent) {
Frame frame = SWT_AWT.new_Frame(parent);
// This plug-in requires Java8 or higher and versions higher than Java7 suffer from bug 377104
// So, no need to check Java version.
if (SHELL_SET_ACTIVE_CONTROL_METHOD != null) {
frame.addWindowListener(new SWT_AWT_PATCH_377104(parent));
}
return frame;
}
private final Composite embedded;
private SWT_AWT_PATCH_377104(Composite embedded) {
this.embedded = embedded;
}
@Override
public void windowActivated(WindowEvent event) {
if (!embedded.isDisposed()) {
try {
embedded.getDisplay().asyncExec(this::activateEmbedded);
} catch (SWTException e) {
String msg = "Embedded part was not able to set active control on Shell. "
+ "This will result in other workbench parts not getting activated.";
IStatus status = new Status(ERROR, PLUGIN_ID, msg, e);
JFreeChartUIPlugin.getDefault().getLog().log(status);
}
}
}
private void activateEmbedded() {
try {
if (Display.getCurrent().getFocusControl() != embedded) {
return;
}
Stack<Control> stack = new Stack<Control>();
Control current = embedded;
Shell shell = embedded.getShell();
while (current != null && !(current instanceof Shell)) {
stack.push(current.getParent());
current = current.getParent();
}
while (!stack.isEmpty()) {
SHELL_SET_ACTIVE_CONTROL_METHOD.invoke(shell, stack.pop());
}
} catch (SWTException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
String msg = "Embedded part was not able to set active control on Shell. "
+ "This will result in other workbench parts not getting activated.";
IStatus status = new Status(ERROR, PLUGIN_ID, msg, e);
JFreeChartUIPlugin.getDefault().getLog().log(status);
}
}
}
......@@ -20,23 +20,17 @@ import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Stack;
import javax.swing.JApplet;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.trace4cps.common.jfreechart.ui.JFreeChartUIPlugin;
import org.eclipse.trace4cps.common.jfreechart.ui.internal.ChartPanelFactory;
import org.eclipse.trace4cps.common.jfreechart.ui.internal.ChartPanelScrollbarHandler;
import org.eclipse.trace4cps.common.jfreechart.ui.internal.SWT_AWT_PATCH_377104;
import org.eclipse.ui.statushandlers.StatusManager;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
......@@ -57,7 +51,7 @@ public class ChartPanelComposite extends Composite {
public ChartPanelComposite(ChartPanel chartPanel, Composite parent, int style) {
super(parent, SWT.EMBEDDED | style);
Args.nullNotPermitted(chartPanel, "chartPanel");
this.baseFrame = SWT_AWT.new_Frame(this);
this.baseFrame = SWT_AWT_PATCH_377104.new_Frame(this);
this.chartPanel = chartPanel;
this.scrollbarHandler = new ChartPanelScrollbarHandler(this);
......@@ -78,9 +72,6 @@ public class ChartPanelComposite extends Composite {
JApplet chartApplet = new JApplet();
chartApplet.add(chartPanel);
baseFrame.add(chartApplet);
// Workaround eclipse bug #377104
workaround377104(baseFrame, this);
}
@Override
......@@ -147,60 +138,6 @@ public class ChartPanelComposite extends Composite {
super.setMenu(menu);
}
/**
* <p>
* Workaround for Eclipse bug 377104 where frame activation is not being properly propagated into SWT on Java 7.
* </p>
* <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=377104">
*
* Eclipse Bug 377104</a>
*
* @param frame Swing frame
* @param embedded Composite containing embedded swing components
*/
private static final void workaround377104(final Frame frame, final Composite embedded) {
if (System.getProperty("java.version").startsWith("1.7")
|| System.getProperty("java.version").startsWith("1.8"))
{
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowActivated(java.awt.event.WindowEvent e) {
embedded.getDisplay().asyncExec(() -> {
if (Display.getCurrent().getFocusControl() == embedded) {
Stack<Control> stack = new Stack<Control>();
Control starter = embedded;
Shell shell = embedded.getShell();
while (starter != null && !(starter instanceof Shell)) {
stack.push(starter.getParent());
starter = starter.getParent();
}
Method m = null;
try {
m = shell.getClass().getDeclaredMethod("setActiveControl", Control.class);
m.setAccessible(true);
while (!stack.isEmpty()) {
m.invoke(shell, stack.pop());
}
} catch (NoSuchMethodException | SecurityException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e1)
{
String msg = "Embedded part was not able to set active control on Shell. "
+ "This will result in other workbench parts not getting activated.";
IStatus status = new Status(ERROR, PLUGIN_ID, msg, e1);
JFreeChartUIPlugin.getDefault().getLog().log(status);
} finally {
if (m != null) {
m.setAccessible(false);
}
}
}
});
}
});
}
}
private static java.awt.Color toAwtColor(org.eclipse.swt.graphics.Color color) {
return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
}
......
......@@ -7,12 +7,12 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.13/junit-4.13.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.xbase/2.21.0/org.eclipse.xtext.xbase-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.common.types/2.21.0/org.eclipse.xtext.common.types-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext/2.21.0/org.eclipse.xtext-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.util/2.21.0/org.eclipse.xtext.util-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtend/org.eclipse.xtend.lib/2.21.0/org.eclipse.xtend.lib-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.xbase.lib/2.21.0/org.eclipse.xtext.xbase.lib-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.xbase/2.22.0/org.eclipse.xtext.xbase-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.common.types/2.22.0/org.eclipse.xtext.common.types-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext/2.22.0/org.eclipse.xtext-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.util/2.22.0/org.eclipse.xtext.util-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtend/org.eclipse.xtend.lib/2.22.0/org.eclipse.xtend.lib-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtext/org.eclipse.xtext.xbase.lib/2.22.0/org.eclipse.xtext.xbase.lib-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/27.1-jre/guava-27.1-jre.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar"/>
......@@ -21,20 +21,20 @@
<classpathentry kind="var" path="M2_REPO/com/google/errorprone/error_prone_annotations/2.2.0/error_prone_annotations-2.2.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/codehaus/mojo/animal-sniffer-annotations/1.17/animal-sniffer-annotations-1.17.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtend/org.eclipse.xtend.lib.macro/2.21.0/org.eclipse.xtend.lib.macro-2.21.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/xtend/org.eclipse.xtend.lib.macro/2.22.0/org.eclipse.xtend.lib.macro-2.22.0.jar"/>
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.common/2.17.0/org.eclipse.emf.common-2.17.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.ecore/2.20.0/org.eclipse.emf.ecore-2.20.0.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/inject/guice/3.0/guice-3.0.jar"/>
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/platform/org.eclipse.equinox.common/3.10.600/org.eclipse.equinox.common-3.10.600.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/platform/org.eclipse.osgi/3.15.100/org.eclipse.osgi-3.15.100.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/platform/org.eclipse.equinox.common/3.11.0/org.eclipse.equinox.common-3.11.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/platform/org.eclipse.osgi/3.15.200/org.eclipse.osgi-3.15.200.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/emf/org.eclipse.emf.ecore.xmi/2.16.0/org.eclipse.emf.ecore.xmi-2.16.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-commons/7.2/asm-commons-7.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm/7.2/asm-7.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-tree/7.2/asm-tree-7.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-analysis/7.2/asm-analysis-7.2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-commons/8.0.1/asm-commons-8.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm/8.0.1/asm-8.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-tree/8.0.1/asm-tree-8.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/ow2/asm/asm-analysis/8.0.1/asm-analysis-8.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/io/github/classgraph/classgraph/4.8.35/classgraph-4.8.35.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.trace4cps.core"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.trace4cps.tl"/>
......
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
//outlet.DEFAULT_OUTPUT.sourceFolder.src/main/java.directory=xtend-gen
BuilderConfiguration.is_project_specific=true
eclipse.preferences.version=1
outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true
outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false
outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true
......@@ -432,7 +432,7 @@ public class TracePlotManager implements XYToolTipGenerator, XYItemLabelGenerato
rangeAxis.setAutoRangeAlign(RangeAlign.LOWER);
rangeAxis.setFixedAutoRange(30);
} else {
rangeAxis.setRange(new Range(0d, rangeAxis.getSections().size())); // all sections visible
rangeAxis.setAutoRange(true);
}
if (!firstPlot) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment