More Runnable to lambda.
And enable save actions to automate it.
Change-Id: I006d27096d9c456884ab1541f240972c3d3609e1
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
index 586111f..05f4991 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -340,19 +339,16 @@
// taking the workspace lock
// so that there is no concurrency with the builder
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96575
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- @Override
- public void run(IProgressMonitor progressMonitor)
- throws CoreException {
- for (int i = 0; i < length; i++) {
- IProject project = projectsToTouch[i];
- // touch to force a build of this project
- if (DLTKCore.DEBUG) {
- System.out
- .println("Touching project " + project.getName() + " due to external jar file change"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- project.touch(progressMonitor);
+ IWorkspaceRunnable runnable = progressMonitor -> {
+ for (int i = 0; i < length; i++) {
+ IProject project = projectsToTouch[i];
+ // touch to force a build of this project
+ if (DLTKCore.DEBUG) {
+ System.out.println("Touching project " //$NON-NLS-1$
+ + project.getName()
+ + " due to external jar file change"); //$NON-NLS-1$
}
+ project.touch(progressMonitor);
}
};
try {
@@ -1507,31 +1503,26 @@
// RuntimeExceptions)
}
try {
- rootDelta.accept(new IResourceDeltaVisitor() {
- @Override
- public boolean visit(IResourceDelta delta) /*
- * throws
- * CoreException
- */{
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- case IResourceDelta.REMOVED:
+ rootDelta.accept(delta -> {
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED:
+ throw new FoundRelevantDeltaException();
+ case IResourceDelta.CHANGED:
+ // if any flag is set but SYNC or MARKER, this
+ // delta
+ // should be considered
+ if (delta.getAffectedChildren().length == 0 // only
+ // check
+ // leaf
+ // delta
+ // nodes
+ && (delta.getFlags() & ~(IResourceDelta.SYNC
+ | IResourceDelta.MARKERS)) != 0) {
throw new FoundRelevantDeltaException();
- case IResourceDelta.CHANGED:
- // if any flag is set but SYNC or MARKER, this
- // delta
- // should be considered
- if (delta.getAffectedChildren().length == 0 // only
- // check
- // leaf
- // delta
- // nodes
- && (delta.getFlags() & ~(IResourceDelta.SYNC | IResourceDelta.MARKERS)) != 0) {
- throw new FoundRelevantDeltaException();
- }
}
- return true;
}
+ return true;
});
} catch (FoundRelevantDeltaException e) {
// System.out.println("RELEVANT DELTA detected in: "+
@@ -2706,12 +2697,8 @@
final IScriptProject project = (IScriptProject) element;
this.rootsToRefresh.add(project);
this.projectCachesToReset.add(project);
- this.postActions.add(new Runnable() {
- @Override
- public void run() {
- ProjectIndexerManager.indexProject(res);
- }
- });
+ this.postActions.add(() -> ProjectIndexerManager
+ .indexProject(res));
}
} else {
boolean wasDylanProject = this.state.findProject(res
@@ -2787,12 +2774,8 @@
switch (delta.getKind()) {
case IResourceDelta.ADDED:
final IScriptProject scriptProject = element.getScriptProject();
- this.postActions.add(new Runnable() {
- @Override
- public void run() {
- ProjectIndexerManager.indexProject(scriptProject);
- }
- });
+ this.postActions.add(() -> ProjectIndexerManager
+ .indexProject(scriptProject));
break;
case IResourceDelta.REMOVED:
final IPath projectPath = element.getScriptProject()
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
index 749e37f..549b89b 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/display/ScriptDisplayView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2016 xored software, Inc.
+ * Copyright (c) 2008, 2017 xored software, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -75,7 +75,7 @@
/**
* Stack of consoles in MRU order
*/
- private List<IConsole> fStack = new ArrayList<IConsole>();
+ private List<IConsole> fStack = new ArrayList<>();
/**
* The console being displayed, or <code>null</code> if none
@@ -198,7 +198,7 @@
/**
* Activates the participants for the given console, if any.
- *
+ *
* @param console
*/
private void activateParticipants(IConsole console) {
@@ -228,7 +228,7 @@
/**
* Returns a stack of consoles in the view in MRU order.
- *
+ *
* @return a stack of consoles in the view in MRU order
*/
public List<IConsole> getConsoleStack() {
@@ -311,7 +311,7 @@
/**
* Returns the page participants registered for the given console, or
* <code>null</code>
- *
+ *
* @param console
* @return registered page participants or <code>null</code>
*/
@@ -386,7 +386,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.
* console.IConsole[])
@@ -406,31 +406,27 @@
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui
* .console.IConsole[])
*/
public void consolesRemoved(final IConsole[] consoles) {
if (isAvailable()) {
- Runnable r = new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < consoles.length; i++) {
- if (isAvailable()) {
- IConsole console = consoles[i];
- fStack.remove(console);
- ConsoleWorkbenchPart part = fConsoleToPart
- .get(console);
- if (part != null) {
- partClosed(part);
- }
- if (getConsole() == null) {
- IConsole[] available = {}; // FIXME
- // getConsoleManager().getConsoles();
- if (available.length > 0) {
- display(available[available.length - 1]);
- }
+ Runnable r = () -> {
+ for (int i = 0; i < consoles.length; i++) {
+ if (isAvailable()) {
+ IConsole console = consoles[i];
+ fStack.remove(console);
+ ConsoleWorkbenchPart part = fConsoleToPart.get(console);
+ if (part != null) {
+ partClosed(part);
+ }
+ if (getConsole() == null) {
+ IConsole[] available = {}; // FIXME
+ // getConsoleManager().getConsoles();
+ if (available.length > 0) {
+ display(available[available.length - 1]);
}
}
}
@@ -445,9 +441,9 @@
*/
public ScriptDisplayView() {
super();
- fConsoleToPart = new LinkedHashMap<IConsole, ConsoleWorkbenchPart>();
- fPartToConsole = new HashMap<ConsoleWorkbenchPart, IConsole>();
- fConsoleToPageParticipants = new HashMap<IConsole, ListenerList>();
+ fConsoleToPart = new LinkedHashMap<>();
+ fPartToConsole = new HashMap<>();
+ fConsoleToPageParticipants = new HashMap<>();
}
@@ -532,7 +528,7 @@
/**
* Registers the given runnable with the display associated with this view's
* control, if any.
- *
+ *
* @see org.eclipse.swt.widgets.Display#asyncExec(java.lang.Runnable)
*/
public void asyncExec(Runnable r) {
@@ -554,7 +550,7 @@
* <li><code>configureToolBar(IToolBarManager)</code></li>
* <li><code>getHelpContextId()</code></li>
* </ul>
- *
+ *
* @see IWorkbenchPart#createPartControl(Composite)
*/
@Override
@@ -708,7 +704,7 @@
/**
* Returns if the specified part reference is to this view part (if the part
* reference is the console view or not)
- *
+ *
* @param partRef
* @return true if the specified part reference is the console view
*/
@@ -733,7 +729,7 @@
/**
* Deactivates participants for the given console, if any.
- *
+ *
* @param console
* console to deactivate
*/
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ScriptDebugConsolePageParticipant.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ScriptDebugConsolePageParticipant.java
index 06be1da..cf0d4e2 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ScriptDebugConsolePageParticipant.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/console/ScriptDebugConsolePageParticipant.java
@@ -211,12 +211,9 @@
for (int i = 0; i < events.length; i++) {
DebugEvent event = events[i];
if (event.getSource().equals(getProcess())) {
- Runnable r = new Runnable() {
- @Override
- public void run() {
- if (fTerminate != null) {
- fTerminate.update();
- }
+ Runnable r = () -> {
+ if (fTerminate != null) {
+ fTerminate.update();
}
};
DLTKDebugUIPlugin.getStandardDisplay().asyncExec(r);
diff --git a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptBreakpointManager.java b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptBreakpointManager.java
index 0099073..13baa5f 100644
--- a/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptBreakpointManager.java
+++ b/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/internal/debug/core/model/ScriptBreakpointManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -101,7 +101,8 @@
.isWatchpointComplexSupported()) {
return watchpoint.getFieldName() + "|"
+ (watchpoint.getExpressionState()
- ? watchpoint.getExpression() : "");
+ ? watchpoint.getExpression()
+ : "");
}
}
if (debugToolkit.isAccessWatchpointSupported()) {
@@ -338,7 +339,8 @@
if (oldValue == null) {
if (newValue != null) {
return IMarker.LINE_NUMBER.equals(attr)
- ? MAJOR_CHANGE : MINOR_CHANGE;
+ ? MAJOR_CHANGE
+ : MINOR_CHANGE;
}
continue;
}
@@ -514,7 +516,7 @@
private static class TemporaryBreakpoint implements IDebugEventSetListener {
final ScriptBreakpointManager manager;
- final Map<IDbgpSession, String> ids = new IdentityHashMap<IDbgpSession, String>(
+ final Map<IDbgpSession, String> ids = new IdentityHashMap<>(
1);
/**
@@ -587,20 +589,15 @@
final IDbgpSession[] sessions = getSessions();
for (int i = 0; i < sessions.length; ++i) {
final IDbgpSession session = sessions[i];
- scheduleBackgroundOperation(target, new Runnable() {
- @Override
- public void run() {
- try {
- if (breakpoint instanceof IScriptSpawnpoint) {
- addSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- } else {
- addBreakpoint(session,
- (IScriptBreakpoint) breakpoint);
- }
- } catch (Exception e) {
- DLTKDebugPlugin.log(e);
+ scheduleBackgroundOperation(target, () -> {
+ try {
+ if (breakpoint instanceof IScriptSpawnpoint) {
+ addSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
+ } else {
+ addBreakpoint(session, (IScriptBreakpoint) breakpoint);
}
+ } catch (Exception e) {
+ DLTKDebugPlugin.log(e);
}
});
}
@@ -622,28 +619,27 @@
return;
}
if (breakpoint instanceof IScriptSpawnpoint) {
- final int changes = delta != null ? hasSpawnpointChanges(delta,
- (IScriptSpawnpoint) breakpoint) : MAJOR_CHANGE;
+ final int changes = delta != null
+ ? hasSpawnpointChanges(delta,
+ (IScriptSpawnpoint) breakpoint)
+ : MAJOR_CHANGE;
if (changes != NO_CHANGES) {
final IDbgpSession[] sessions = getSessions();
for (int i = 0; i < sessions.length; ++i) {
final IDbgpSession session = sessions[i];
- scheduleBackgroundOperation(target, new Runnable() {
- @Override
- public void run() {
- try {
- if (changes == MAJOR_CHANGE) {
- removeSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- addSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- } else {
- changeSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- }
- } catch (Exception e) {
- DLTKDebugPlugin.logError(e.getMessage(), e);
+ scheduleBackgroundOperation(target, () -> {
+ try {
+ if (changes == MAJOR_CHANGE) {
+ removeSpawnpoint(session,
+ (IScriptSpawnpoint) breakpoint);
+ addSpawnpoint(session,
+ (IScriptSpawnpoint) breakpoint);
+ } else {
+ changeSpawnpoint(session,
+ (IScriptSpawnpoint) breakpoint);
}
+ } catch (Exception e) {
+ DLTKDebugPlugin.logError(e.getMessage(), e);
}
});
}
@@ -656,19 +652,16 @@
final IDbgpSession[] sessions = getSessions();
for (int i = 0; i < sessions.length; ++i) {
final IDbgpSession session = sessions[i];
- scheduleBackgroundOperation(target, new Runnable() {
- @Override
- public void run() {
- try {
- if (changes == MAJOR_CHANGE) {
- removeBreakpoint(session, sbp);
- addBreakpoint(session, sbp);
- } else {
- changeBreakpoint(session, sbp);
- }
- } catch (Exception e) {
- DLTKDebugPlugin.logError(e.getMessage(), e);
+ scheduleBackgroundOperation(target, () -> {
+ try {
+ if (changes == MAJOR_CHANGE) {
+ removeBreakpoint(session, sbp);
+ addBreakpoint(session, sbp);
+ } else {
+ changeBreakpoint(session, sbp);
}
+ } catch (Exception e) {
+ DLTKDebugPlugin.logError(e.getMessage(), e);
}
});
}
@@ -685,20 +678,17 @@
final IDbgpSession[] sessions = getSessions();
for (int i = 0; i < sessions.length; ++i) {
final IDbgpSession session = sessions[i];
- scheduleBackgroundOperation(target, new Runnable() {
- @Override
- public void run() {
- try {
- if (breakpoint instanceof IScriptSpawnpoint) {
- removeSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- } else {
- removeBreakpoint(session,
- (IScriptBreakpoint) breakpoint);
- }
- } catch (Exception e) {
- DLTKDebugPlugin.log(e);
+ scheduleBackgroundOperation(target, () -> {
+ try {
+ if (breakpoint instanceof IScriptSpawnpoint) {
+ removeSpawnpoint(session,
+ (IScriptSpawnpoint) breakpoint);
+ } else {
+ removeBreakpoint(session,
+ (IScriptBreakpoint) breakpoint);
}
+ } catch (Exception e) {
+ DLTKDebugPlugin.log(e);
}
});
}
@@ -714,20 +704,17 @@
final IBreakpoint breakpoint = breakpoints[i];
for (int j = 0; j < sessions.length; ++j) {
final IDbgpSession session = sessions[j];
- scheduleBackgroundOperation(target, new Runnable() {
- @Override
- public void run() {
- try {
- if (breakpoint instanceof IScriptSpawnpoint) {
- changeSpawnpoint(session,
- (IScriptSpawnpoint) breakpoint);
- } else {
- changeBreakpoint(session,
- (IScriptBreakpoint) breakpoint);
- }
- } catch (Exception e) {
- DLTKDebugPlugin.log(e);
+ scheduleBackgroundOperation(target, () -> {
+ try {
+ if (breakpoint instanceof IScriptSpawnpoint) {
+ changeSpawnpoint(session,
+ (IScriptSpawnpoint) breakpoint);
+ } else {
+ changeBreakpoint(session,
+ (IScriptBreakpoint) breakpoint);
}
+ } catch (Exception e) {
+ DLTKDebugPlugin.log(e);
}
});
}
@@ -735,8 +722,7 @@
}
private static void scheduleBackgroundOperation(
- final IScriptDebugTarget target,
- final Runnable runnable) {
+ final IScriptDebugTarget target, final Runnable runnable) {
String name = target.getLaunch().getLaunchConfiguration().getName();
Job breakpointBackgroundJob = new Job("Update target breakpoints: " //$NON-NLS-1$
diff --git a/core/plugins/org.eclipse.dltk.launching/.settings/org.eclipse.jdt.ui.prefs b/core/plugins/org.eclipse.dltk.launching/.settings/org.eclipse.jdt.ui.prefs
index f27f47d..87f112b 100644
--- a/core/plugins/org.eclipse.dltk.launching/.settings/org.eclipse.jdt.ui.prefs
+++ b/core/plugins/org.eclipse.dltk.launching/.settings/org.eclipse.jdt.ui.prefs
@@ -15,7 +15,7 @@
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_functional_interfaces=false
+sp_cleanup.convert_functional_interfaces=true
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
@@ -53,7 +53,7 @@
sp_cleanup.use_anonymous_class_creation=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_lambda=false
+sp_cleanup.use_lambda=true
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
diff --git a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/AbstractInterpreterInstallType.java b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/AbstractInterpreterInstallType.java
index 9b6cdc7..0419658 100644
--- a/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/AbstractInterpreterInstallType.java
+++ b/core/plugins/org.eclipse.dltk.launching/src/org/eclipse/dltk/internal/launching/AbstractInterpreterInstallType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2016 IBM Corporation and others.
+ * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -257,56 +257,53 @@
// final Object lock = new Object();
- Thread tReading = new Thread(new Runnable() {
- @Override
- public void run() {
- boolean workReceived = false;
- try {
- while (true) {
- if (monitor != null && monitor.isCanceled()) {
- monitor.worked(1);
- process.destroy();
- break;
- }
- String line = dataIn.readLine();
- if (line != null && monitor != null && !workReceived) {
- int work = extractWorkFromLine(line);
- if (work != NOT_WORK_COUNT) {
- monitor.beginTask(
- LaunchingMessages.AbstractInterpreterInstallType_fetchingInterpreterLibraryLocations,
- work);
- // monitor.subTask("Featching interpeter library
- // locations");
- workReceived = true;
- }
- }
- if (line != null && monitor != null
- && detectWorkInc(line)) {
- monitor.worked(1);
- }
- if (line != null) {
- result.add(line);
- } else {
- break;
- }
+ Thread tReading = new Thread(() -> {
+ boolean workReceived = false;
+ try {
+ while (true) {
+ if (monitor != null && monitor.isCanceled()) {
+ monitor.worked(1);
+ process.destroy();
+ break;
}
-
- } catch (IOException e) {
- DLTKLaunchingPlugin.log(new Status(IStatus.INFO,
- DLTKLaunchingPlugin.PLUGIN_ID, IStatus.INFO,
- NLS.bind(
- LaunchingMessages.AbstractInterpreterInstallType_failedToReadFromDiscoverScriptOutputStream,
- e.getMessage()),
- e));
- } finally {
- if (monitor != null) {
- if (!workReceived) {
+ String line = dataIn.readLine();
+ if (line != null && monitor != null && !workReceived) {
+ int work = extractWorkFromLine(line);
+ if (work != NOT_WORK_COUNT) {
monitor.beginTask(
LaunchingMessages.AbstractInterpreterInstallType_fetchingInterpreterLibraryLocations,
- 1);
+ work);
+ // monitor.subTask("Featching interpeter library
+ // locations");
+ workReceived = true;
}
- monitor.done();
}
+ if (line != null && monitor != null
+ && detectWorkInc(line)) {
+ monitor.worked(1);
+ }
+ if (line != null) {
+ result.add(line);
+ } else {
+ break;
+ }
+ }
+
+ } catch (IOException e) {
+ DLTKLaunchingPlugin.log(new Status(IStatus.INFO,
+ DLTKLaunchingPlugin.PLUGIN_ID, IStatus.INFO,
+ NLS.bind(
+ LaunchingMessages.AbstractInterpreterInstallType_failedToReadFromDiscoverScriptOutputStream,
+ e.getMessage()),
+ e));
+ } finally {
+ if (monitor != null) {
+ if (!workReceived) {
+ monitor.beginTask(
+ LaunchingMessages.AbstractInterpreterInstallType_fetchingInterpreterLibraryLocations,
+ 1);
+ }
+ monitor.done();
}
}
});
@@ -674,56 +671,51 @@
final IFileHandle installLocation,
final List<LibraryLocation> locations,
final EnvironmentVariable[] variables) {
- return new ILookupRunnable() {
- @Override
- public void run(IProgressMonitor monitor) {
+ return monitor -> {
+ try {
+ IEnvironment env = installLocation.getEnvironment();
+ IExecutionEnvironment exeEnv = env
+ .getAdapter(IExecutionEnvironment.class);
+ if (exeEnv == null)
+ return;
+ IDeployment deployment = exeEnv.createDeployment();
+
+ // handle case where rse is missing required plugins
+ if (deployment == null) {
+ DLTKLaunchingPlugin.logWarning(
+ LaunchingMessages.AbstractInterpreterInstallType_failedToDeployLibraryLocationsScript);
+ return;
+ }
+
try {
- IEnvironment env = installLocation.getEnvironment();
- IExecutionEnvironment exeEnv = env
- .getAdapter(IExecutionEnvironment.class);
- if (exeEnv == null)
- return;
- IDeployment deployment = exeEnv.createDeployment();
-
- // handle case where rse is missing required plugins
- if (deployment == null) {
- DLTKLaunchingPlugin.logWarning(
- LaunchingMessages.AbstractInterpreterInstallType_failedToDeployLibraryLocationsScript);
- return;
- }
-
- try {
- IPath deploymentPath = createPathFile(deployment);
- IFileHandle locator = deployment
- .getFile(deploymentPath);
- String result = retrivePaths(exeEnv, installLocation,
- locations, monitor, locator, variables);
- String message = NLS.bind(
- LaunchingMessages.AbstractInterpreterInstallType_failedToResolveLibraryLocationsForWith,
- installLocation.getName(),
- locator.toOSString());
- if (locations.size() == 0) {
- if (result == null) {
- DLTKLaunchingPlugin.log(message);
- } else {
- DLTKLaunchingPlugin.logWarning(message,
- new Exception(NLS.bind(
- LaunchingMessages.AbstractInterpreterInstallType_output,
- result)));
- }
+ IPath deploymentPath = createPathFile(deployment);
+ IFileHandle locator = deployment.getFile(deploymentPath);
+ String result = retrivePaths(exeEnv, installLocation,
+ locations, monitor, locator, variables);
+ String message = NLS.bind(
+ LaunchingMessages.AbstractInterpreterInstallType_failedToResolveLibraryLocationsForWith,
+ installLocation.getName(), locator.toOSString());
+ if (locations.size() == 0) {
+ if (result == null) {
+ DLTKLaunchingPlugin.log(message);
+ } else {
+ DLTKLaunchingPlugin.logWarning(message,
+ new Exception(NLS.bind(
+ LaunchingMessages.AbstractInterpreterInstallType_output,
+ result)));
}
- } finally {
- // if (deployment != null) {
- deployment.dispose();
- // }
}
- } catch (IOException e) {
- DLTKLaunchingPlugin.log(
- LaunchingMessages.AbstractInterpreterInstallType_problemWhileResolvingInterpreterLibraries,
- e);
- if (DLTKCore.DEBUG) {
- e.printStackTrace();
- }
+ } finally {
+ // if (deployment != null) {
+ deployment.dispose();
+ // }
+ }
+ } catch (IOException e) {
+ DLTKLaunchingPlugin.log(
+ LaunchingMessages.AbstractInterpreterInstallType_problemWhileResolvingInterpreterLibraries,
+ e);
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
}
}
};
diff --git a/core/plugins/org.eclipse.dltk.testing/.settings/org.eclipse.jdt.ui.prefs b/core/plugins/org.eclipse.dltk.testing/.settings/org.eclipse.jdt.ui.prefs
index 2a115cf..2be769c 100644
--- a/core/plugins/org.eclipse.dltk.testing/.settings/org.eclipse.jdt.ui.prefs
+++ b/core/plugins/org.eclipse.dltk.testing/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,61 @@
-#Tue Feb 15 09:07:48 NOVT 2011
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
formatter_settings_version=11
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
index fe96730..5bed60b 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/DLTKTestingModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -72,8 +72,7 @@
* a TestRunner once to a launch. Once a test runner is connected, it is
* removed from the set.
*/
- private final HashSet<ILaunch> fTrackedLaunches = new HashSet<ILaunch>(
- 20);
+ private final HashSet<ILaunch> fTrackedLaunches = new HashSet<>(20);
protected void initialize(ILaunchManager launchManager) {
fTrackedLaunches.clear();
@@ -91,16 +90,6 @@
@Override
public void launchRemoved(final ILaunch launch) {
fTrackedLaunches.remove(launch);
- // TODO: story for removing old test runs?
- // getDisplay().asyncExec(new Runnable() {
- // public void run() {
- // TestRunnerViewPart testRunnerViewPart=
- // findTestRunnerViewPartInActivePage();
- // if (testRunnerViewPart != null && testRunnerViewPart.isCreated()
- // && launch.equals(testRunnerViewPart.getLastLaunch()))
- // testRunnerViewPart.reset();
- // }
- // });
}
@Override
@@ -124,12 +113,8 @@
try {
final int port = Integer.parseInt(portStr);
fTrackedLaunches.remove(launch);
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- connectTestRunner(launch, javaProject, port);
- }
- });
+ getDisplay().asyncExec(
+ () -> connectTestRunner(launch, javaProject, port));
} catch (NumberFormatException e) {
return;
}
@@ -138,12 +123,8 @@
.getAttribute(DLTKTestingConstants.LAUNCH_ATTR_KEY);
if (atr != null) {
fTrackedLaunches.remove(launch);
- getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- connectTestRunner(launch, javaProject);
- }
- });
+ getDisplay().asyncExec(
+ () -> connectTestRunner(launch, javaProject));
}
}
}
@@ -194,7 +175,8 @@
}
public TestRunnerViewPart showTestRunnerViewPartInActivePage() {
- return showTestRunnerViewPartInActivePage(findTestRunnerViewPartInActivePage());
+ return showTestRunnerViewPartInActivePage(
+ findTestRunnerViewPartInActivePage());
}
private TestRunnerViewPart showTestRunnerViewPartInActivePage(
@@ -248,7 +230,7 @@
/**
* Active test run sessions, youngest first.
*/
- private final LinkedList<TestRunSession> fTestRunSessions = new LinkedList<TestRunSession>();
+ private final LinkedList<TestRunSession> fTestRunSessions = new LinkedList<>();
private final DLTKTestingLaunchListener fLaunchListener = new DLTKTestingLaunchListener();
private boolean started = false;
@@ -311,17 +293,6 @@
}
}
- // for (Iterator iter= fTestRunSessions.iterator(); iter.hasNext();) {
- // final TestRunSession session= (TestRunSession) iter.next();
- // SafeRunner.run(new ISafeRunnable() {
- // public void run() throws Exception {
- // session.swapOut();
- // }
- // public void handleException(Throwable exception) {
- // JUnitPlugin.log(exception);
- // }
- // });
- // }
started = false;
}
@@ -344,7 +315,7 @@
@Override
public List<TestRunSession> getTestRunSessions() {
synchronized (fTestRunSessions) {
- return new ArrayList<TestRunSession>(fTestRunSessions);
+ return new ArrayList<>(fTestRunSessions);
}
}
@@ -367,7 +338,7 @@
* <p>
* <b>To be called in the UI thread only!</b>
* </p>
- *
+ *
* @param testRunSession
* the session to add
*/
@@ -383,7 +354,7 @@
/**
* Imports a test run session from the given file.
- *
+ *
* @param file
* a file containing a test run session transcript
* @return the imported test run session
@@ -432,7 +403,7 @@
/**
* Exports the given test run session.
- *
+ *
* @param testRunSession
* the test run session
* @param file
@@ -464,14 +435,14 @@
}
public static void exportTestRunSession(TestRunSession testRunSession,
- OutputStream out) throws TransformerFactoryConfigurationError,
- TransformerException {
+ OutputStream out)
+ throws TransformerFactoryConfigurationError, TransformerException {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer();
InputSource inputSource = new InputSource();
- SAXSource source = new SAXSource(new TestRunSessionSerializer(
- testRunSession), inputSource);
+ SAXSource source = new SAXSource(
+ new TestRunSessionSerializer(testRunSession), inputSource);
StreamResult result = new StreamResult(out);
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
@@ -479,7 +450,7 @@
* Bug in Xalan: Only indents if proprietary property
* org.apache.xalan.templates.OutputProperties.S_KEY_INDENT_AMOUNT is
* set.
- *
+ *
* Bug in Xalan as shipped with J2SE 5.0: Does not read the
* indent-amount property at all >:-(.
*/
@@ -497,7 +468,8 @@
throw new CoreException(new org.eclipse.core.runtime.Status(
IStatus.ERROR, DLTKTestingPlugin.getPluginId(),
Messages.format(ModelMessages.JUnitModel_could_not_write,
- file.getAbsolutePath()), e));
+ file.getAbsolutePath()),
+ e));
}
private static void throwImportError(File file, Exception e)
@@ -505,7 +477,8 @@
throw new CoreException(new org.eclipse.core.runtime.Status(
IStatus.ERROR, DLTKTestingPlugin.getPluginId(),
Messages.format(ModelMessages.JUnitModel_could_not_read,
- file.getAbsolutePath()), e));
+ file.getAbsolutePath()),
+ e));
}
/**
@@ -514,7 +487,7 @@
* <p>
* <b>To be called in the UI thread only!</b>
* </p>
- *
+ *
* @param testRunSession
* the session to remove
*/
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/RemoteTestRunnerClient.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/RemoteTestRunnerClient.java
index 0307c61..0e1abd3 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/RemoteTestRunnerClient.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/model/RemoteTestRunnerClient.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,8 +7,8 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Julien Ruaux: jruaux@octo.com
- * Vincent Massol: vmassol@octo.com
+ * Julien Ruaux: jruaux@octo.com
+ * Vincent Massol: vmassol@octo.com
*******************************************************************************/
package org.eclipse.dltk.internal.testing.model;
@@ -25,20 +25,23 @@
import org.eclipse.dltk.testing.MessageIds;
/**
- * The client side of the RemoteTestRunner. Handles the
- * marshaling of the different messages.
+ * The client side of the RemoteTestRunner. Handles the marshaling of the
+ * different messages.
*/
-public class RemoteTestRunnerClient implements ITestingClient, ITestRunnerClient {
+public class RemoteTestRunnerClient
+ implements ITestingClient, ITestRunnerClient {
public RemoteTestRunnerClient() {
- operationsThread= new Thread(runner);
+ operationsThread = new Thread(runner);
operationsThread.start();
}
+
public abstract class ListenerSafeRunnable implements ISafeRunnable {
@Override
public void handleException(Throwable exception) {
DLTKTestingPlugin.log(exception);
}
}
+
/**
* A simple state machine to process requests from the RemoteTestRunner
*/
@@ -65,19 +68,19 @@
fFailedRerunTrace.setLength(0);
return fRerunState;
}
- String arg= message.substring(MessageIds.MSG_HEADER_LENGTH);
+ String arg = message.substring(MessageIds.MSG_HEADER_LENGTH);
if (message.startsWith(MessageIds.TEST_RUN_START)) {
// version < 2 format: count
// version >= 2 format: count+" "+version
- int count= 0;
- int v= arg.indexOf(' ');
+ int count = 0;
+ int v = arg.indexOf(' ');
if (v == -1) {
- fVersion= "v1"; //$NON-NLS-1$
- count= Integer.parseInt(arg);
+ fVersion = "v1"; //$NON-NLS-1$
+ count = Integer.parseInt(arg);
} else {
- fVersion= arg.substring(v + 1);
- String sc= arg.substring(0, v);
- count= Integer.parseInt(sc);
+ fVersion = arg.substring(v + 1);
+ String sc = arg.substring(0, v);
+ count = Integer.parseInt(sc);
}
notifyTestRunStarted(count);
return this;
@@ -99,14 +102,14 @@
return this;
}
if (message.startsWith(MessageIds.TEST_RUN_END)) {
- long elapsedTime= Long.parseLong(arg);
+ long elapsedTime = Long.parseLong(arg);
testRunEnded(elapsedTime);
return this;
}
if (message.startsWith(MessageIds.TEST_STOPPED)) {
- long elapsedTime= Long.parseLong(arg);
+ long elapsedTime = Long.parseLong(arg);
notifyTestRunStopped(elapsedTime);
-// shutDown();
+ // shutDown();
return this;
}
if (message.startsWith(MessageIds.TEST_TREE)) {
@@ -133,8 +136,8 @@
private String fEndString;
AppendingProcessingState(StringBuffer buffer, String endString) {
- this.fBuffer= buffer;
- this.fEndString= endString;
+ this.fBuffer = buffer;
+ this.fEndString = endString;
}
@Override
@@ -184,27 +187,29 @@
/**
* The failed trace that is currently reported from the RemoteTestRunner
*/
- private final StringBuffer fFailedTrace= new StringBuffer();
+ private final StringBuffer fFailedTrace = new StringBuffer();
/**
* The expected test result
*/
- private final StringBuffer fExpectedResult= new StringBuffer();
+ private final StringBuffer fExpectedResult = new StringBuffer();
/**
* The actual test result
*/
- private final StringBuffer fActualResult= new StringBuffer();
+ private final StringBuffer fActualResult = new StringBuffer();
/**
* The failed trace of a reran test
*/
- private final StringBuffer fFailedRerunTrace= new StringBuffer();
+ private final StringBuffer fFailedRerunTrace = new StringBuffer();
-
- ProcessingState fDefaultState= new DefaultProcessingState();
- ProcessingState fTraceState= new TraceProcessingState();
- ProcessingState fExpectedState= new AppendingProcessingState(fExpectedResult, MessageIds.EXPECTED_END);
- ProcessingState fActualState= new AppendingProcessingState(fActualResult, MessageIds.ACTUAL_END);
- ProcessingState fRerunState= new AppendingProcessingState(fFailedRerunTrace, MessageIds.RTRACE_END);
- ProcessingState fCurrentState= fDefaultState;
+ ProcessingState fDefaultState = new DefaultProcessingState();
+ ProcessingState fTraceState = new TraceProcessingState();
+ ProcessingState fExpectedState = new AppendingProcessingState(
+ fExpectedResult, MessageIds.EXPECTED_END);
+ ProcessingState fActualState = new AppendingProcessingState(fActualResult,
+ MessageIds.ACTUAL_END);
+ ProcessingState fRerunState = new AppendingProcessingState(
+ fFailedRerunTrace, MessageIds.RTRACE_END);
+ ProcessingState fCurrentState = fDefaultState;
/**
* An array of listeners that are informed about test events.
@@ -214,9 +219,9 @@
/**
* The server socket
*/
-// private ServerSocket fServerSocket;
-// private Socket fSocket;
-// private int fPort= -1;
+ // private ServerSocket fServerSocket;
+ // private Socket fSocket;
+ // private int fPort= -1;
private PrintWriter fWriter;
private BufferedReader fBufferedReader;
/**
@@ -231,32 +236,32 @@
* The Id of the failed test
*/
private String fFailedTestId;
-
+
private int fFailedCode;
/**
* The kind of failure of the test that is currently reported as failed
*/
private int fFailureKind;
- private boolean fDebug= false;
+ private boolean fDebug = false;
/**
* Reads the message stream from the RemoteTestRunner
*/
/**
- * Start listening to a test run. Start a server connection that
- * the RemoteTestRunner can connect to.
- *
- * @param listeners
- * @param port
+ * Start listening to a test run. Start a server connection that the
+ * RemoteTestRunner can connect to.
+ *
+ * @param listeners
+ * @param port
*/
@Override
public synchronized void startListening(ITestRunListener2 listener) {
fListeners = new ITestRunListener2[] { listener };
-// fPort= port;
-// ServerConnection connection= new ServerConnection(port);
-// connection.start();
+ // fPort= port;
+ // ServerConnection connection= new ServerConnection(port);
+ // connection.start();
}
/**
@@ -264,89 +269,92 @@
*/
@Override
public synchronized void stopTest() {
-// if (isRunning()) {
-// fWriter.println(MessageIds.TEST_STOP);
-// fWriter.flush();
-// }
+ // if (isRunning()) {
+ // fWriter.println(MessageIds.TEST_STOP);
+ // fWriter.flush();
+ // }
}
-
private String readMessage(BufferedReader in) throws IOException {
return in.readLine();
}
private void receiveMessage(String message) {
- fCurrentState= fCurrentState.readMessage(message);
+ fCurrentState = fCurrentState.readMessage(message);
}
private void scanOldReranMessage(String arg) {
// OLD V1 format
// format: className" "testName" "status
// status: FAILURE, ERROR, OK
- int c= arg.indexOf(" "); //$NON-NLS-1$
- int t= arg.indexOf(" ", c + 1); //$NON-NLS-1$
- String className= arg.substring(0, c);
- String testName= arg.substring(c + 1, t);
- String status= arg.substring(t + 1);
- String testId= className + testName;
+ int c = arg.indexOf(" "); //$NON-NLS-1$
+ int t = arg.indexOf(" ", c + 1); //$NON-NLS-1$
+ String className = arg.substring(0, c);
+ String testName = arg.substring(c + 1, t);
+ String status = arg.substring(t + 1);
+ String testId = className + testName;
notifyTestReran(testId, className, testName, status);
}
private void scanReranMessage(String arg) {
// format: testId" "className" "testName" "status
// status: FAILURE, ERROR, OK
- int i= arg.indexOf(' ');
- int c= arg.indexOf(' ', i + 1);
- int t= arg.indexOf(' ', c + 1);
- String testId= arg.substring(0, i);
- String className= arg.substring(i + 1, c);
- String testName= arg.substring(c + 1, t);
- String status= arg.substring(t + 1);
+ int i = arg.indexOf(' ');
+ int c = arg.indexOf(' ', i + 1);
+ int t = arg.indexOf(' ', c + 1);
+ String testId = arg.substring(0, i);
+ String className = arg.substring(i + 1, c);
+ String testName = arg.substring(c + 1, t);
+ String status = arg.substring(t + 1);
notifyTestReran(testId, className, testName, status);
}
- private void notifyTestReran(String testId, String className, String testName, String status) {
- int statusCode= ITestRunListener2.STATUS_OK;
+ private void notifyTestReran(String testId, String className,
+ String testName, String status) {
+ int statusCode = ITestRunListener2.STATUS_OK;
if (status.equals("FAILURE")) //$NON-NLS-1$
- statusCode= ITestRunListener2.STATUS_FAILURE;
+ statusCode = ITestRunListener2.STATUS_FAILURE;
else if (status.equals("ERROR")) //$NON-NLS-1$
- statusCode= ITestRunListener2.STATUS_ERROR;
+ statusCode = ITestRunListener2.STATUS_ERROR;
- String trace= ""; //$NON-NLS-1$
+ String trace = ""; //$NON-NLS-1$
if (statusCode != ITestRunListener2.STATUS_OK)
- trace= fFailedRerunTrace.toString();
+ trace = fFailedRerunTrace.toString();
// assumption a rerun trace was sent before
notifyTestReran(testId, className, testName, statusCode, trace);
}
private void extractFailure(String arg, int status) {
- String s[]= extractTestId(arg);
- fFailedTestId= s[0];
- fFailedTest= s[1];
- fFailureKind= status;
+ String s[] = extractTestId(arg);
+ fFailedTestId = s[0];
+ fFailedTest = s[1];
+ fFailureKind = status;
}
+
private void extractFailure(String arg, int code, int status) {
- String s[]= extractTestId(arg);
- fFailedTestId= s[0];
- fFailedTest= s[1];
+ String s[] = extractTestId(arg);
+ fFailedTestId = s[0];
+ fFailedTest = s[1];
fFailedCode = code;
- fFailureKind= status;
+ fFailureKind = status;
}
/**
- * @param arg test name
- * @return an array with two elements. The first one is the testId, the second one the testName.
+ * @param arg
+ * test name
+ * @return an array with two elements. The first one is the testId, the
+ * second one the testName.
*/
String[] extractTestId(String arg) {
- String[] result= new String[2];
+ String[] result = new String[2];
if (!hasTestId()) {
- result[0]= arg; // use the test name as the test Id
- result[1]= arg;
+ result[0] = arg; // use the test name as the test Id
+ result[1] = arg;
return result;
}
- int i= arg.indexOf(',');
- result[0]= arg.substring(0, i);
- result[1]= arg.substring(i + 1, arg.length());
+ int i = arg.indexOf(',');
+ result[0] = arg.substring(0, i);
+ result[1] = arg.substring(i + 1, arg.length());
return result;
}
@@ -356,21 +364,24 @@
return fVersion.equals("v2"); //$NON-NLS-1$
}
- private void notifyTestReran(final String testId, final String className, final String testName, final int statusCode, final String trace) {
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ private void notifyTestReran(final String testId, final String className,
+ final String testName, final int statusCode, final String trace) {
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
- listener.testReran(testId, className, testName, statusCode, trace, fExpectedResult.toString(), fActualResult.toString());
+ listener.testReran(testId, className, testName, statusCode,
+ trace, fExpectedResult.toString(),
+ fActualResult.toString());
}
});
}
}
private void notifyTestTreeEntry(final String treeEntry) {
- for (int i= 0; i < fListeners.length; i++) {
- ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ ITestRunListener2 listener = fListeners[i];
if (!hasTestId())
listener.testTreeEntry(fakeTestId(treeEntry));
else
@@ -380,16 +391,16 @@
private String fakeTestId(String treeEntry) {
// extract the test name and add it as the testId
- int index0= treeEntry.indexOf(',');
- String testName= treeEntry.substring(0, index0).trim();
+ int index0 = treeEntry.indexOf(',');
+ String testName = treeEntry.substring(0, index0).trim();
return testName + "," + treeEntry; //$NON-NLS-1$
}
private void notifyTestRunStopped(final long elapsedTime) {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
@@ -402,8 +413,8 @@
private void testRunEnded(final long elapsedTime) {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
@@ -417,12 +428,12 @@
private void notifyTestEnded(final String test) {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
- String s[]= extractTestId(test);
+ String s[] = extractTestId(test);
listener.testEnded(s[0], s[1]);
}
});
@@ -432,12 +443,12 @@
private void notifyTestStarted(final String test) {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
- String s[]= extractTestId(test);
+ String s[] = extractTestId(test);
listener.testStarted(s[0], s[1]);
}
});
@@ -447,8 +458,8 @@
private void notifyTestRunStarted(final int count) {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
@@ -462,23 +473,27 @@
private void notifyTestFailed() {
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
- listener.testFailed(fFailureKind, fFailedTestId, fFailedTest, fFailedTrace.toString(), fExpectedResult.toString(), fActualResult.toString(), fFailedCode);
+ listener.testFailed(fFailureKind, fFailedTestId,
+ fFailedTest, fFailedTrace.toString(),
+ fExpectedResult.toString(),
+ fActualResult.toString(), fFailedCode);
}
});
}
}
private void notifyTestRunTerminated() {
- // fix for 77771 RemoteTestRunnerClient doing work after junit shutdown [JUnit]
+ // fix for 77771 RemoteTestRunnerClient doing work after junit shutdown
+ // [JUnit]
if (DLTKTestingPlugin.isStopped())
return;
- for (int i= 0; i < fListeners.length; i++) {
- final ITestRunListener2 listener= fListeners[i];
+ for (int i = 0; i < fListeners.length; i++) {
+ final ITestRunListener2 listener = fListeners[i];
SafeRunner.run(new ListenerSafeRunnable() {
@Override
public void run() {
@@ -490,12 +505,13 @@
@Override
public void rerunTest(String testId, String className, String testName) {
-// if (isRunning()) {
-// fActualResult.setLength(0);
-// fExpectedResult.setLength(0);
-// fWriter.println(MessageIds.TEST_RERUN+testId+" "+className+" "+testName); //$NON-NLS-1$ //$NON-NLS-2$
-// fWriter.flush();
-// }
+ // if (isRunning()) {
+ // fActualResult.setLength(0);
+ // fExpectedResult.setLength(0);
+ // fWriter.println(MessageIds.TEST_RERUN+testId+" "+className+"
+ // "+testName); //$NON-NLS-1$ //$NON-NLS-2$
+ // fWriter.flush();
+ // }
}
@Override
@@ -512,25 +528,22 @@
@Override
public void testRunStart(final int count) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
- notifyTestRunStarted(count);
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ notifyTestRunStarted(count);
});
}
}
@Override
- public void testTree(final int testId, final String testName, final boolean issuite, final int testCound) {
+ public void testTree(final int testId, final String testName,
+ final boolean issuite, final int testCound) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
- notifyTestTreeEntry(Integer.toString(testId) + "," + testName + "," + Boolean.toString(issuite) + "," + Integer.toString(testCound)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ notifyTestTreeEntry(Integer.toString(testId) + "," + testName //$NON-NLS-1$
+ + "," + Boolean.toString(issuite) + "," //$NON-NLS-1$ //$NON-NLS-2$
+ + Integer.toString(testCound));
});
}
}
@@ -538,12 +551,9 @@
@Override
public void testTerminated(final int elapse) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
- testRunEnded(elapse);
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ testRunEnded(elapse);
});
}
}
@@ -551,12 +561,9 @@
@Override
public void testStarted(final int id, final String name) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
- notifyTestStarted(Integer.toString(id) + "," + name); //$NON-NLS-1$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ notifyTestStarted(Integer.toString(id) + "," + name); //$NON-NLS-1$
});
}
}
@@ -564,12 +571,9 @@
@Override
public void testEnded(final int id, final String name) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
- notifyTestEnded(Integer.toString(id) + "," + name); //$NON-NLS-1$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ notifyTestEnded(Integer.toString(id) + "," + name); //$NON-NLS-1$
});
}
}
@@ -577,26 +581,23 @@
@Override
public void testFailed(final int id, final String name) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
- extractFailure(Integer.toString(id) + "," + name, ITestRunListener2.STATUS_FAILURE, -1); //$NON-NLS-1$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ // notifyTestFailed();(Integer.toString(id) + "," + name);
+ extractFailure(Integer.toString(id) + "," + name, //$NON-NLS-1$
+ ITestRunListener2.STATUS_FAILURE, -1);
});
}
}
+
@Override
- public void testFailed(final int code,final int id, final String name) {
+ public void testFailed(final int code, final int id, final String name) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
- extractFailure(Integer.toString(id) + "," + name, code, ITestRunListener2.STATUS_FAILURE); //$NON-NLS-1$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ // notifyTestFailed();(Integer.toString(id) + "," + name);
+ extractFailure(Integer.toString(id) + "," + name, code, //$NON-NLS-1$
+ ITestRunListener2.STATUS_FAILURE);
});
}
}
@@ -604,83 +605,59 @@
@Override
public void traceMessage(final String message) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
-// fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
-// receiveMessage(MessageIds.TRACE_START);
- receiveMessage(message);
-// receiveMessage(MessageIds.TRACE_END);
- }
- });
+ addOperation(() -> receiveMessage(message));
}
}
@Override
public void testError(final int id, final String name) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
- extractFailure(Integer.toString(id) + "," + name, ITestRunListener2.STATUS_ERROR); //$NON-NLS-1$
- }
+ addOperation(() -> {
+ fCurrentState = fDefaultState;
+ // notifyTestFailed();(Integer.toString(id) + "," + name);
+ extractFailure(Integer.toString(id) + "," + name, //$NON-NLS-1$
+ ITestRunListener2.STATUS_ERROR);
});
}
}
-
+
@Override
public void testActual(final String actual) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
-// fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
- receiveMessage(MessageIds.ACTUAL_START);
- receiveMessage(actual);
- receiveMessage(MessageIds.ACTUAL_END);
- }
+ addOperation(() -> {
+ // fCurrentState= fDefaultState;
+ // notifyTestFailed();(Integer.toString(id) + "," + name);
+ receiveMessage(MessageIds.ACTUAL_START);
+ receiveMessage(actual);
+ receiveMessage(MessageIds.ACTUAL_END);
});
}
}
+
@Override
public void testExpected(final String expected) {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
-// fCurrentState= fDefaultState;
-// notifyTestFailed();(Integer.toString(id) + "," + name);
- receiveMessage(MessageIds.EXPECTED_START);
- receiveMessage(expected);
- receiveMessage(MessageIds.EXPECTED_END);
- }
+ addOperation(() -> {
+ // fCurrentState= fDefaultState;
+ // notifyTestFailed();(Integer.toString(id) + "," + name);
+ receiveMessage(MessageIds.EXPECTED_START);
+ receiveMessage(expected);
+ receiveMessage(MessageIds.EXPECTED_END);
});
}
}
+
@Override
public void traceStart() {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- receiveMessage(MessageIds.TRACE_START);
- }
- });
+ addOperation(() -> receiveMessage(MessageIds.TRACE_START));
}
}
+
@Override
public void traceEnd() {
if (!isTerminated) {
- addOperation(new Runnable() {
- @Override
- public void run() {
- receiveMessage(MessageIds.TRACE_END);
- }
- });
+ addOperation(() -> receiveMessage(MessageIds.TRACE_END));
}
}
@@ -691,34 +668,31 @@
}
}
- private List<Runnable> operations= new ArrayList<Runnable>();
+ private List<Runnable> operations = new ArrayList<>();
private Thread operationsThread;
private boolean isTerminated = false;
- private Runnable runner= new Runnable() {
- @Override
- public void run() {
- while (!isTerminated || operations.size() > 0) {
- Runnable operation= null;
- synchronized (operations) {
- if (operations.size() > 0) {
- operation= operations.get(0);
- operations.remove(0);
- } else {
- try {
- operations.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ private Runnable runner = () -> {
+ while (!isTerminated || operations.size() > 0) {
+ Runnable operation = null;
+ synchronized (operations) {
+ if (operations.size() > 0) {
+ operation = operations.get(0);
+ operations.remove(0);
+ } else {
+ try {
+ operations.wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
}
- if (operation != null) {
- try {
-// System.out.println("Exec operation");
-// System.out.flush();
- operation.run();
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ }
+ if (operation != null) {
+ try {
+ // System.out.println("Exec operation");
+ // System.out.flush();
+ operation.run();
+ } catch (Throwable t) {
+ t.printStackTrace();
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
index cbc9bd9..4a402a5 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/ui/TestRunnerViewPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Julien Ruaux: jruaux@octo.com see bug 25324 Ability to know when tests are finished [junit]
+ * Julien Ruaux: jruaux@octo.com see bug 25324 Ability to know when tests are finished [junit]
* Vincent Massol: vmassol@octo.com 25324 Ability to know when tests are finished [junit]
* Sebastian Davids: sdavids@gmx.de 35762 JUnit View wasting a lot of screen space [JUnit]
*******************************************************************************/
@@ -52,8 +52,8 @@
import org.eclipse.dltk.testing.ITestRunnerUI;
import org.eclipse.dltk.testing.ITestSession;
import org.eclipse.dltk.testing.model.ITestElement;
-import org.eclipse.dltk.testing.model.ITestRunSession;
import org.eclipse.dltk.testing.model.ITestElement.Result;
+import org.eclipse.dltk.testing.model.ITestRunSession;
import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.dltk.ui.viewsupport.ViewHistory;
import org.eclipse.jface.action.Action;
@@ -149,7 +149,6 @@
*/
private int fLayout = LAYOUT_HIERARCHICAL;
-
private int fSortDirection = SORT_DIRECTION_NO_SORT;
// private boolean fTestIsRunning= false;
@@ -280,7 +279,7 @@
static final String TAG_RATIO = "ratio"; //$NON-NLS-1$
static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$
static final String TAG_SORT_DIRECTION = "sort_direction"; //$NON-NLS-1$
-
+
static final String TAG_SCROLL = "scroll"; //$NON-NLS-1$
/**
* @since 3.2
@@ -290,19 +289,19 @@
* @since 3.2
*/
static final String TAG_FAILURES_ONLY = "failuresOnly"; //$NON-NLS-1$
-
- static final String TAG_SHOW_TIME= "time";
+
+ static final String TAG_SHOW_TIME = "time";
// orientations
static final int VIEW_ORIENTATION_VERTICAL = 0;
static final int VIEW_ORIENTATION_HORIZONTAL = 1;
static final int VIEW_ORIENTATION_AUTOMATIC = 2;
- //sort direction
+ // sort direction
static final int SORT_DIRECTION_NO_SORT = 0;
static final int SORT_DIRECTION_ASCENDING = 1;
static final int SORT_DIRECTION_DESCENDING = 2;
-
+
private IMemento fMemento;
Image fOriginalViewImage;
@@ -380,8 +379,8 @@
@Override
public void configureHistoryDropDownAction(IAction action) {
- action
- .setToolTipText(DLTKTestingMessages.TestRunnerViewPart_test_run_history);
+ action.setToolTipText(
+ DLTKTestingMessages.TestRunnerViewPart_test_run_history);
DLTKTestingPlugin.setLocalImageDescriptors(action,
"history_list.gif"); //$NON-NLS-1$
}
@@ -424,16 +423,19 @@
}
@Override
- public void setHistoryEntries(List<TestRunSession> remainingEntries, TestRunSession activeEntry) {
+ public void setHistoryEntries(List<TestRunSession> remainingEntries,
+ TestRunSession activeEntry) {
setActiveTestRunSession(activeEntry);
List<TestRunSession> testRunSessions = DLTKTestingPlugin.getModel()
.getTestRunSessions();
testRunSessions.removeAll(remainingEntries);
- for (Iterator<TestRunSession> iter = testRunSessions.iterator(); iter.hasNext();) {
+ for (Iterator<TestRunSession> iter = testRunSessions
+ .iterator(); iter.hasNext();) {
DLTKTestingPlugin.getModel().removeTestRunSession(iter.next());
}
- for (Iterator<TestRunSession> iter = remainingEntries.iterator(); iter.hasNext();) {
+ for (Iterator<TestRunSession> iter = remainingEntries
+ .iterator(); iter.hasNext();) {
TestRunSession remaining = iter.next();
remaining.swapOut();
}
@@ -463,13 +465,11 @@
if (session.getStartTime() == 0) {
return session.getTestRunName();
} else {
- String startTime = DateFormat.getDateTimeInstance().format(
- new Date(session.getStartTime()));
- return Messages
- .format(
- DLTKTestingMessages.TestRunnerViewPart_testName_startTime,
- new Object[] { session.getTestRunName(),
- startTime });
+ String startTime = DateFormat.getDateTimeInstance()
+ .format(new Date(session.getStartTime()));
+ return Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_testName_startTime,
+ new Object[] { session.getTestRunName(), startTime });
}
}
@@ -508,16 +508,15 @@
private final Shell fShell;
public ImportTestRunSessionAction(Shell shell) {
- super(
- DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_name);
+ super(DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_name);
fShell = shell;
}
@Override
public void run() {
FileDialog importDialog = new FileDialog(fShell, SWT.OPEN);
- importDialog
- .setText(DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_title);
+ importDialog.setText(
+ DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_title);
importDialog.setFilterExtensions(new String[] { "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
String path = importDialog.open();
if (path == null)
@@ -530,11 +529,9 @@
DLTKTestingModel.importTestRunSession(file);
} catch (CoreException e) {
DLTKTestingPlugin.log(e);
- ErrorDialog
- .openError(
- fShell,
- DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_error_title,
- e.getStatus().getMessage(), e.getStatus());
+ ErrorDialog.openError(fShell,
+ DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_error_title,
+ e.getStatus().getMessage(), e.getStatus());
}
}
}
@@ -545,8 +542,7 @@
public ExportTestRunSessionAction(Shell shell,
TestRunSession testRunSession) {
- super(
- DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_name);
+ super(DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_name);
fShell = shell;
fTestRunSession = testRunSession;
}
@@ -554,8 +550,8 @@
@Override
public void run() {
FileDialog exportDialog = new FileDialog(fShell, SWT.SAVE);
- exportDialog
- .setText(DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_title);
+ exportDialog.setText(
+ DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_title);
exportDialog.setFileName(getFileName());
exportDialog.setFilterExtensions(new String[] { "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
String path = exportDialog.open();
@@ -569,11 +565,9 @@
DLTKTestingModel.exportTestRunSession(fTestRunSession, file);
} catch (CoreException e) {
DLTKTestingPlugin.log(e);
- ErrorDialog
- .openError(
- fShell,
- DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_error_title,
- e.getStatus().getMessage(), e.getStatus());
+ ErrorDialog.openError(fShell,
+ DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_error_title,
+ e.getStatus().getMessage(), e.getStatus());
}
}
@@ -583,7 +577,8 @@
if (startTime == 0)
return testRunName;
- String isoTime = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date(startTime)); //$NON-NLS-1$
+ String isoTime = new SimpleDateFormat("yyyyMMdd-HHmmss") //$NON-NLS-1$
+ .format(new Date(startTime));
return testRunName + " " + isoTime + ".xml"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -593,7 +588,8 @@
public void sessionAdded(TestRunSession testRunSession) {
if (getSite().getWorkbenchWindow() == DLTKTestingPlugin
.getActiveWorkbenchWindow()) {
- TestRunSession deactivatedSession = setActiveTestRunSession(testRunSession);
+ TestRunSession deactivatedSession = setActiveTestRunSession(
+ testRunSession);
if (deactivatedSession != null)
deactivatedSession.swapOut();
String testRunName = fTestRunSession.getTestRunName();
@@ -612,11 +608,12 @@
@Override
public void sessionRemoved(TestRunSession testRunSession) {
if (testRunSession.equals(fTestRunSession)) {
- List<TestRunSession> testRunSessions = DLTKTestingPlugin.getModel()
- .getTestRunSessions();
+ List<TestRunSession> testRunSessions = DLTKTestingPlugin
+ .getModel().getTestRunSessions();
TestRunSession deactivatedSession;
if (!testRunSessions.isEmpty()) {
- deactivatedSession = setActiveTestRunSession(testRunSessions.get(0));
+ deactivatedSession = setActiveTestRunSession(
+ testRunSessions.get(0));
} else {
deactivatedSession = setActiveTestRunSession(null);
}
@@ -643,29 +640,25 @@
fTestViewer.registerAutoScrollTarget(null);
String[] keys = { elapsedTimeAsString(elapsedTime) };
- String msg = Messages
- .format(
- DLTKTestingMessages.TestRunnerViewPart_message_finish,
- keys);
+ String msg = Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_message_finish,
+ keys);
registerInfoMessage(msg);
- postSyncRunnable(new Runnable() {
- @Override
- public void run() {
- if (isDisposed())
- return;
- fStopAction.setEnabled(lastLaunchIsKeptAlive());
- updateRerunFailedFirstAction();
- processChangesInUI();
- if (hasErrorsOrFailures()) {
- selectFirstFailure();
- }
- if (fDirtyListener == null) {
- fDirtyListener = new DirtyListener();
- DLTKCore.addElementChangedListener(fDirtyListener);
- }
- warnOfContentChange();
+ postSyncRunnable(() -> {
+ if (isDisposed())
+ return;
+ fStopAction.setEnabled(lastLaunchIsKeptAlive());
+ updateRerunFailedFirstAction();
+ processChangesInUI();
+ if (hasErrorsOrFailures()) {
+ selectFirstFailure();
}
+ if (fDirtyListener == null) {
+ fDirtyListener = new DirtyListener();
+ DLTKCore.addElementChangedListener(fDirtyListener);
+ }
+ warnOfContentChange();
});
stopUpdateJobs();
}
@@ -674,7 +667,8 @@
public void sessionStopped(final long elapsedTime) {
fTestViewer.registerAutoScrollTarget(null);
- registerInfoMessage(DLTKTestingMessages.TestRunnerViewPart_message_stopped);
+ registerInfoMessage(
+ DLTKTestingMessages.TestRunnerViewPart_message_stopped);
handleStopped();
}
@@ -682,7 +676,8 @@
public void sessionTerminated() {
fTestViewer.registerAutoScrollTarget(null);
- registerInfoMessage(DLTKTestingMessages.TestRunnerViewPart_message_terminated);
+ registerInfoMessage(
+ DLTKTestingMessages.TestRunnerViewPart_message_terminated);
handleStopped();
}
@@ -696,8 +691,8 @@
public void testStarted(TestCaseElement testCaseElement) {
fTestViewer.registerAutoScrollTarget(testCaseElement);
fTestViewer.registerViewerUpdate(testCaseElement);
- registerInfoMessage(getTestRunnerUI().getTestStartedMessage(
- testCaseElement));
+ registerInfoMessage(
+ getTestRunnerUI().getTestStartedMessage(testCaseElement));
}
@Override
@@ -803,9 +798,11 @@
boolean enabled = false;
List<TestRunSession> testRunSessions = DLTKTestingPlugin.getModel()
.getTestRunSessions();
- for (Iterator<TestRunSession> iter = testRunSessions.iterator(); iter.hasNext();) {
+ for (Iterator<TestRunSession> iter = testRunSessions
+ .iterator(); iter.hasNext();) {
ITestSession testRunSession = iter.next();
- if (!testRunSession.isRunning() && !testRunSession.isStarting()) {
+ if (!testRunSession.isRunning()
+ && !testRunSession.isStarting()) {
enabled = true;
break;
}
@@ -824,9 +821,11 @@
private List<TestRunSession> getRunningSessions() {
List<TestRunSession> testRunSessions = DLTKTestingPlugin.getModel()
.getTestRunSessions();
- for (Iterator<TestRunSession> iter = testRunSessions.iterator(); iter.hasNext();) {
+ for (Iterator<TestRunSession> iter = testRunSessions
+ .iterator(); iter.hasNext();) {
ITestSession testRunSession = iter.next();
- if (!testRunSession.isRunning() && !testRunSession.isStarting()) {
+ if (!testRunSession.isRunning()
+ && !testRunSession.isStarting()) {
iter.remove();
}
}
@@ -837,7 +836,8 @@
private class StopAction extends Action {
public StopAction() {
setText(DLTKTestingMessages.TestRunnerViewPart_stopaction_text);
- setToolTipText(DLTKTestingMessages.TestRunnerViewPart_stopaction_tooltip);
+ setToolTipText(
+ DLTKTestingMessages.TestRunnerViewPart_stopaction_tooltip);
DLTKTestingPlugin.setLocalImageDescriptors(this, "stop.gif"); //$NON-NLS-1$
}
@@ -851,7 +851,8 @@
private class RerunLastAction extends Action {
public RerunLastAction() {
setText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_label);
- setToolTipText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_tooltip);
+ setToolTipText(
+ DLTKTestingMessages.TestRunnerViewPart_rerunaction_tooltip);
DLTKTestingPlugin.setLocalImageDescriptors(this, "relaunch.gif"); //$NON-NLS-1$
setEnabled(false);
setActionDefinitionId(RERUN_LAST_COMMAND);
@@ -866,7 +867,8 @@
private class RerunLastFailedFirstAction extends Action {
public RerunLastFailedFirstAction() {
setText(DLTKTestingMessages.TestRunnerViewPart_rerunfailuresaction_label);
- setToolTipText(DLTKTestingMessages.TestRunnerViewPart_rerunfailuresaction_tooltip);
+ setToolTipText(
+ DLTKTestingMessages.TestRunnerViewPart_rerunfailuresaction_tooltip);
DLTKTestingPlugin.setLocalImageDescriptors(this, "relaunchf.gif"); //$NON-NLS-1$
setEnabled(false);
setActionDefinitionId(RERUN_FAILED_FIRST_COMMAND);
@@ -907,23 +909,19 @@
if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_HORIZONTAL) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_horizontal_label);
setImageDescriptor(DLTKTestingPlugin
- .getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
+ .getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
} else if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_VERTICAL) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_vertical_label);
setImageDescriptor(DLTKTestingPlugin
- .getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
+ .getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
} else if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_AUTOMATIC) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_automatic_label);
setImageDescriptor(DLTKTestingPlugin
- .getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
+ .getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
}
fActionOrientation = orientation;
- PlatformUI
- .getWorkbench()
- .getHelpSystem()
- .setHelp(
- this,
- IDLTKTestingHelpContextIds.RESULTS_VIEW_TOGGLE_ORIENTATION_ACTION);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ IDLTKTestingHelpContextIds.RESULTS_VIEW_TOGGLE_ORIENTATION_ACTION);
}
public int getOrientation() {
@@ -938,7 +936,7 @@
}
}
}
-
+
private class ToggleSortDirectionAction extends Action {
private final int fActionSortDirection;
@@ -946,26 +944,29 @@
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
if (sortDirection == TestRunnerViewPart.SORT_DIRECTION_NO_SORT) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_sort_no_sort);
-// setImageDescriptor(DLTKTestingPlugin
-// .getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
+ // setImageDescriptor(DLTKTestingPlugin
+ // .getImageDescriptor("elcl16/th_horizontal.gif"));
+ // //$NON-NLS-1$
} else if (sortDirection == TestRunnerViewPart.SORT_DIRECTION_ASCENDING) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_sort_ascending);
-// setImageDescriptor(DLTKTestingPlugin
-// .getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
+ // setImageDescriptor(DLTKTestingPlugin
+ // .getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
} else if (sortDirection == TestRunnerViewPart.SORT_DIRECTION_DESCENDING) {
setText(DLTKTestingMessages.TestRunnerViewPart_toggle_sort_descending);
-// setImageDescriptor(DLTKTestingPlugin
-// .getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
+ // setImageDescriptor(DLTKTestingPlugin
+ // .getImageDescriptor("elcl16/th_automatic.gif"));
+ // //$NON-NLS-1$
}
- fActionSortDirection = sortDirection;
+ fActionSortDirection = sortDirection;
}
- public int getSortDirection(){
+
+ public int getSortDirection() {
return fActionSortDirection;
}
@Override
public void run() {
- fSortDirection =fActionSortDirection;
+ fSortDirection = fActionSortDirection;
fTestViewer.setSortDirection(fActionSortDirection);
}
}
@@ -1027,9 +1028,10 @@
public FailuresOnlyFilterAction() {
super(DLTKTestingMessages.TestRunnerViewPart_show_failures_only,
AS_CHECK_BOX);
- setToolTipText(DLTKTestingMessages.TestRunnerViewPart_show_failures_only);
- setImageDescriptor(DLTKTestingPlugin
- .getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
+ setToolTipText(
+ DLTKTestingMessages.TestRunnerViewPart_show_failures_only);
+ setImageDescriptor(
+ DLTKTestingPlugin.getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
}
@Override
@@ -1037,12 +1039,14 @@
setShowFailuresOnly(isChecked());
}
}
+
private class ShowTimeAction extends Action {
-
+
public ShowTimeAction() {
- super(DLTKTestingMessages.TestRunnerViewPart_show_execution_time, IAction.AS_CHECK_BOX);
+ super(DLTKTestingMessages.TestRunnerViewPart_show_execution_time,
+ IAction.AS_CHECK_BOX);
}
-
+
@Override
public void run() {
setShowExecutionTime(isChecked());
@@ -1067,10 +1071,10 @@
private class ActivateOnErrorAction extends Action {
public ActivateOnErrorAction() {
- super(
- DLTKTestingMessages.TestRunnerViewPart_activate_on_failure_only,
+ super(DLTKTestingMessages.TestRunnerViewPart_activate_on_failure_only,
IAction.AS_CHECK_BOX);
- //setImageDescriptor(JUnitPlugin.getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
+ // setImageDescriptor(JUnitPlugin.getImageDescriptor("obj16/failures.gif"));
+ // //$NON-NLS-1$
update();
}
@@ -1090,7 +1094,8 @@
}
@Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
+ public void init(IViewSite site, IMemento memento)
+ throws PartInitException {
super.init(site, memento);
fMemento = memento;
IWorkbenchSiteProgressService progressService = getProgressService();
@@ -1100,8 +1105,8 @@
}
private IWorkbenchSiteProgressService getProgressService() {
- IWorkbenchSiteProgressService siteService = getSite().getAdapter(
- IWorkbenchSiteProgressService.class);
+ IWorkbenchSiteProgressService siteService = getSite()
+ .getAdapter(IWorkbenchSiteProgressService.class);
if (siteService != null)
return siteService;
return null;
@@ -1125,11 +1130,12 @@
memento.putInteger(TAG_RATIO, ratio);
memento.putInteger(TAG_ORIENTATION, fOrientation);
memento.putInteger(TAG_SORT_DIRECTION, fSortDirection);
-
- memento.putString(TAG_FAILURES_ONLY, fFailuresOnlyFilterAction
- .isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ memento.putString(TAG_FAILURES_ONLY,
+ fFailuresOnlyFilterAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
memento.putInteger(TAG_LAYOUT, fLayout);
- memento.putString(TAG_SHOW_TIME, fShowTimeAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ memento.putString(TAG_SHOW_TIME,
+ fShowTimeAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1145,26 +1151,26 @@
// }
Integer ratio = memento.getInteger(TAG_RATIO);
if (ratio != null)
- fSashForm.setWeights(new int[] { ratio.intValue(),
- 1000 - ratio.intValue() });
+ fSashForm.setWeights(
+ new int[] { ratio.intValue(), 1000 - ratio.intValue() });
Integer orientation = memento.getInteger(TAG_ORIENTATION);
if (orientation != null)
fOrientation = orientation.intValue();
computeOrientation();
Integer sortDirection = memento.getInteger(TAG_SORT_DIRECTION);
- if(sortDirection !=null) {
+ if (sortDirection != null) {
fSortDirection = sortDirection.intValue();
fTestViewer.setSortDirection(fSortDirection);
- for(ToggleSortDirectionAction act :fToggleSortDirectionActions){
- if(act.getSortDirection() ==fSortDirection){
+ for (ToggleSortDirectionAction act : fToggleSortDirectionActions) {
+ if (act.getSortDirection() == fSortDirection) {
act.setChecked(true);
break;
}
}
- }else{
+ } else {
fToggleSortDirectionActions[0].setChecked(true);
}
-
+
String scrollLock = memento.getString(TAG_SCROLL);
if (scrollLock != null) {
fScrollLockAction.setChecked(scrollLock.equals("true")); //$NON-NLS-1$
@@ -1181,12 +1187,12 @@
if (failuresOnly != null)
showFailuresOnly = failuresOnly.equals("true"); //$NON-NLS-1$
- String time= memento.getString(TAG_SHOW_TIME);
- boolean showTime= true;
+ String time = memento.getString(TAG_SHOW_TIME);
+ boolean showTime = true;
if (time != null)
- showTime= time.equals("true"); //$NON-NLS-1$
-
- setFilterAndLayout(showFailuresOnly, layoutValue);
+ showTime = time.equals("true"); //$NON-NLS-1$
+
+ setFilterAndLayout(showFailuresOnly, layoutValue);
setShowExecutionTime(showTime);
}
@@ -1196,7 +1202,8 @@
public void stopTest() {
if (fTestRunSession != null) {
if (fTestRunSession.isRunning()) {
- setContentDescription(DLTKTestingMessages.TestRunnerViewPart_message_stopping);
+ setContentDescription(
+ DLTKTestingMessages.TestRunnerViewPart_message_stopping);
}
fTestRunSession.stopTestRun();
}
@@ -1276,23 +1283,24 @@
if (launchConfiguration == null)
return;
try {
- if (launchConfiguration.getAttribute(
- IDebugUIConstants.ATTR_PRIVATE, false)) {
+ if (launchConfiguration.getAttribute(IDebugUIConstants.ATTR_PRIVATE,
+ false)) {
return;
}
} catch (CoreException e) {
DLTKTestingPlugin.log(e);
}
- ILaunchConfiguration configuration = prepareLaunchConfigForRelaunch(launchConfiguration);
+ ILaunchConfiguration configuration = prepareLaunchConfigForRelaunch(
+ launchConfiguration);
relaunch(configuration, launch.getLaunchMode());
}
private ILaunchConfiguration prepareLaunchConfigForRelaunch(
ILaunchConfiguration configuration) {
try {
- String attribute = configuration.getAttribute(
- DLTKTestingConstants.ATTR_FAILURES_NAMES, ""); //$NON-NLS-1$
+ String attribute = configuration
+ .getAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES, ""); //$NON-NLS-1$
if (attribute.length() != 0) {
String configName = Messages.format(
DLTKTestingMessages.TestRunnerViewPart_configName,
@@ -1333,35 +1341,31 @@
if (oldFailuresFilename != null) {
configName = oldName;
} else {
- configName = Messages
- .format(
- DLTKTestingMessages.TestRunnerViewPart_rerunFailedFirstLaunchConfigName,
- oldName);
+ configName = Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_rerunFailedFirstLaunchConfigName,
+ oldName);
}
ILaunchConfigurationWorkingCopy tmp = launchConfiguration
.copy(configName);
tmp.setAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES,
- fTestRunSession.getTestRunnerUI().collectFailures(
- fTestRunSession));
+ fTestRunSession.getTestRunnerUI()
+ .collectFailures(fTestRunSession));
relaunch(tmp, launch.getLaunchMode());
return;
} catch (CoreException e) {
- ErrorDialog
- .openError(
- getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_error_cannotrerun,
- e.getMessage(), e.getStatus());
+ ErrorDialog.openError(getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_error_cannotrerun,
+ e.getMessage(), e.getStatus());
}
}
- MessageDialog
- .openInformation(
- getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
- DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
+ MessageDialog.openInformation(getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
}
}
- private void relaunch(ILaunchConfiguration configuration, String launchMode) {
+ private void relaunch(ILaunchConfiguration configuration,
+ String launchMode) {
DebugUITools.launch(configuration, launchMode);
}
@@ -1402,15 +1406,12 @@
}
private void handleStopped() {
- postSyncRunnable(new Runnable() {
- @Override
- public void run() {
- if (isDisposed())
- return;
- resetViewIcon();
- fStopAction.setEnabled(false);
- updateRerunFailedFirstAction();
- }
+ postSyncRunnable(() -> {
+ if (isDisposed())
+ return;
+ resetViewIcon();
+ fStopAction.setEnabled(false);
+ updateRerunFailedFirstAction();
});
stopUpdateJobs();
}
@@ -1435,10 +1436,11 @@
private void updateViewTitleProgress() {
if (fTestRunSession != null) {
if (fTestRunSession.isRunning()) {
- Image progress = fProgressImages.getImage(fTestRunSession
- .getStartedCount(), fTestRunSession.getTotalCount(),
- fTestRunSession.getErrorCount(), fTestRunSession
- .getFailureCount());
+ Image progress = fProgressImages.getImage(
+ fTestRunSession.getStartedCount(),
+ fTestRunSession.getTotalCount(),
+ fTestRunSession.getErrorCount(),
+ fTestRunSession.getFailureCount());
if (progress != fViewImage) {
fViewImage = progress;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
@@ -1457,13 +1459,14 @@
* @return deactivated session, or <code>null</code> iff no session got
* deactivated
*/
- private TestRunSession setActiveTestRunSession(TestRunSession testRunSession) {
+ private TestRunSession setActiveTestRunSession(
+ TestRunSession testRunSession) {
/*
* - State: fTestRunSession fTestSessionListener Jobs
* fTestViewer.processChangesInUI(); - UI: fCounterPanel fProgressBar
* setContentDescription / fInfoMessage setTitleToolTip view icons
* statusLine fFailureTrace
- *
+ *
* action enablement
*/
if (fTestRunSession == testRunSession)
@@ -1516,7 +1519,7 @@
fStopAction.setEnabled(true);
- } else /* old or fresh session: don't want jobs at this stage */{
+ } else /* old or fresh session: don't want jobs at this stage */ {
stopUpdateJobs();
fStopAction.setEnabled(fTestRunSession.isKeptAlive());
@@ -1556,11 +1559,11 @@
}
}
if (fTestRunSessionListener != null)
- DLTKTestingPlugin.getModel().removeTestRunSessionListener(
- fTestRunSessionListener);
+ DLTKTestingPlugin.getModel()
+ .removeTestRunSessionListener(fTestRunSessionListener);
- IHandlerService handlerService = getSite()
- .getWorkbenchWindow().getService(IHandlerService.class);
+ IHandlerService handlerService = getSite().getWorkbenchWindow()
+ .getService(IHandlerService.class);
handlerService.deactivateHandler(fRerunLastActivation);
handlerService.deactivateHandler(fRerunFailedFirstActivation);
setActiveTestRunSession(null);
@@ -1573,8 +1576,8 @@
if (fClipboard != null)
fClipboard.dispose();
if (fViewMenuListener != null) {
- getViewSite().getActionBars().getMenuManager().removeMenuListener(
- fViewMenuListener);
+ getViewSite().getActionBars().getMenuManager()
+ .removeMenuListener(fViewMenuListener);
}
if (fDirtyListener != null) {
DLTKCore.removeElementChangedListener(fDirtyListener);
@@ -1665,13 +1668,10 @@
}
protected void postShowTestResultsView() {
- postSyncRunnable(new Runnable() {
- @Override
- public void run() {
- if (isDisposed())
- return;
- showTestResultsView();
- }
+ postSyncRunnable(() -> {
+ if (isDisposed())
+ return;
+ showTestResultsView();
});
}
@@ -1775,8 +1775,8 @@
configureToolBar();
fCounterComposite = createProgressCountPanel(parent);
- fCounterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
- | GridData.HORIZONTAL_ALIGN_FILL));
+ fCounterComposite.setLayoutData(new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
SashForm sashForm = createSashForm(parent);
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -1800,10 +1800,10 @@
fMemento = null;
fTestRunSessionListener = new TestRunSessionListener();
- DLTKTestingPlugin.getModel().addTestRunSessionListener(
- fTestRunSessionListener);
- IContextService ctxService = getSite().getService(
- IContextService.class);
+ DLTKTestingPlugin.getModel()
+ .addTestRunSessionListener(fTestRunSessionListener);
+ IContextService ctxService = getSite()
+ .getService(IContextService.class);
if (ctxService != null) {
fContextActivation = ctxService
.activateContext(DLTKUIPlugin.CONTEXT_VIEWS);
@@ -1857,16 +1857,16 @@
fStopAction.setEnabled(false);
fRerunLastTestAction = new RerunLastAction();
- IHandlerService handlerService = getSite()
- .getWorkbenchWindow().getService(IHandlerService.class);
+ IHandlerService handlerService = getSite().getWorkbenchWindow()
+ .getService(IHandlerService.class);
fRerunLastActivation = handlerService.activateHandler(
- RERUN_LAST_COMMAND, new ActionHandlerWrapper(
- fRerunLastTestAction));
+ RERUN_LAST_COMMAND,
+ new ActionHandlerWrapper(fRerunLastTestAction));
fRerunFailedFirstAction = new RerunLastFailedFirstAction();
fRerunFailedFirstActivation = handlerService.activateHandler(
- RERUN_FAILED_FIRST_COMMAND, new ActionHandlerWrapper(
- fRerunFailedFirstAction));
+ RERUN_FAILED_FIRST_COMMAND,
+ new ActionHandlerWrapper(fRerunFailedFirstAction));
fFailuresOnlyFilterAction = new FailuresOnlyFilterAction();
@@ -1878,15 +1878,14 @@
new ToggleOrientationAction(VIEW_ORIENTATION_HORIZONTAL),
new ToggleOrientationAction(VIEW_ORIENTATION_AUTOMATIC) };
- fToggleSortDirectionActions = new ToggleSortDirectionAction[]{
+ fToggleSortDirectionActions = new ToggleSortDirectionAction[] {
new ToggleSortDirectionAction(SORT_DIRECTION_NO_SORT),
new ToggleSortDirectionAction(SORT_DIRECTION_ASCENDING),
- new ToggleSortDirectionAction(SORT_DIRECTION_DESCENDING)
- };
-
+ new ToggleSortDirectionAction(SORT_DIRECTION_DESCENDING) };
+
fShowTestHierarchyAction = new ShowTestHierarchyAction();
- fShowTimeAction= new ShowTimeAction();
-
+ fShowTimeAction = new ShowTimeAction();
+
toolBar.add(fNextAction);
toolBar.add(fPreviousAction);
toolBar.add(fFailuresOnlyFilterAction);
@@ -1919,12 +1918,7 @@
fActivateOnErrorAction = new ActivateOnErrorAction();
viewMenu.add(fActivateOnErrorAction);
- fViewMenuListener = new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- fActivateOnErrorAction.update();
- }
- };
+ fViewMenuListener = manager -> fActivateOnErrorAction.update();
viewMenu.addMenuListener(fViewMenuListener);
@@ -1963,11 +1957,11 @@
setCounterColumns(layout);
fCounterPanel = new CounterPanel(composite);
- fCounterPanel.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
- | GridData.HORIZONTAL_ALIGN_FILL));
+ fCounterPanel.setLayoutData(new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
fProgressBar = new DLTKTestingProgressBar(composite);
- fProgressBar.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
- | GridData.HORIZONTAL_ALIGN_FILL));
+ fProgressBar.setLayoutData(new GridData(
+ GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
return composite;
}
@@ -1977,12 +1971,9 @@
}
private void showFailure(final TestElement test) {
- postSyncRunnable(new Runnable() {
- @Override
- public void run() {
- if (!isDisposed())
- fFailureTrace.showFailure(test);
- }
+ postSyncRunnable(() -> {
+ if (!isDisposed())
+ fFailureTrace.showFailure(test);
});
}
@@ -1995,8 +1986,8 @@
* @return the Java project, or <code>null</code>
*/
public IScriptProject getLaunchedProject() {
- return fTestRunSession == null ? null : fTestRunSession
- .getLaunchedProject();
+ return fTestRunSession == null ? null
+ : fTestRunSession.getLaunchedProject();
}
public ILaunch getLaunch() {
@@ -2038,13 +2029,10 @@
else if (fViewImage == fTestRunFailIcon)
fViewImage = fTestRunFailDirtyIcon;
- Runnable r = new Runnable() {
- @Override
- public void run() {
- if (isDisposed())
- return;
- firePropertyChange(IWorkbenchPart.PROP_TITLE);
- }
+ Runnable r = () -> {
+ if (isDisposed())
+ return;
+ firePropertyChange(IWorkbenchPart.PROP_TITLE);
};
if (!isDisposed())
getDisplay().asyncExec(r);
@@ -2060,11 +2048,9 @@
boolean couldLaunch = fTestRunSession.rerunTest(testElement,
launchMode);
if (!couldLaunch) {
- MessageDialog
- .openInformation(
- getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
- DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
+ MessageDialog.openInformation(getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
} else if (fTestRunSession.isKeptAlive()) {
TestCaseElement testCaseElement = (TestCaseElement) fTestRunSession
.getTestElement(testElement.getId());
@@ -2076,18 +2062,13 @@
} catch (CoreException e) {
ErrorDialog.openError(getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_error_cannotrerun, e
- .getMessage(), e.getStatus());
+ DLTKTestingMessages.TestRunnerViewPart_error_cannotrerun,
+ e.getMessage(), e.getStatus());
}
}
private void postSyncProcessChanges() {
- postSyncRunnable(new Runnable() {
- @Override
- public void run() {
- processChangesInUI();
- }
- });
+ postSyncRunnable(() -> processChangesInUI());
}
public void warnOfContentChange() {
@@ -2136,11 +2117,11 @@
void setShowFailuresOnly(boolean failuresOnly) {
setFilterAndLayout(failuresOnly, fLayout);
}
-
+
private void setShowExecutionTime(boolean showTime) {
fTestViewer.setShowTime(showTime);
fShowTimeAction.setChecked(showTime);
-
+
}
private void setLayoutMode(int mode) {
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/util/CheckedTableSelectionDialog.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/util/CheckedTableSelectionDialog.java
index d4b3a32..0d4c8a4 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/util/CheckedTableSelectionDialog.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/util/CheckedTableSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,7 +16,13 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-
+import org.eclipse.dltk.internal.testing.wizards.WizardMessages;
+import org.eclipse.dltk.testing.DLTKTestingPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.SelectionAdapter;
@@ -30,183 +36,182 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ViewerFilter;
-
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
-import org.eclipse.dltk.internal.testing.wizards.WizardMessages;
-import org.eclipse.dltk.testing.DLTKTestingPlugin;
-
-
/**
* A dialog with checked table viewer.
*/
public class CheckedTableSelectionDialog extends SelectionStatusDialog {
-
+
private CheckboxTableViewer fViewer;
-
+
private ILabelProvider fLabelProvider;
private IStructuredContentProvider fContentProvider;
-
- private ISelectionStatusValidator fValidator= null;
- private String fEmptyListMessage= WizardMessages.CheckedTableSelectionDialog_emptyListMessage;
-
- private IStatus fCurrStatus= Status.OK_STATUS;
+
+ private ISelectionStatusValidator fValidator = null;
+ private String fEmptyListMessage = WizardMessages.CheckedTableSelectionDialog_emptyListMessage;
+
+ private IStatus fCurrStatus = Status.OK_STATUS;
private List<ViewerFilter> fFilters;
- private Object fInput;
+ private Object fInput;
private boolean fIsEmpty;
-
- private int fWidth= 40;
- private int fHeight= 18;
-
+
+ private int fWidth = 40;
+ private int fHeight = 18;
+
/**
* Constructs an instance of <code>ElementTreeSelectionDialog</code>.
- * @param labelProvider the label provider to render the entries
- * @param contentProvider the content provider to evaluate the tree structure
- */
- public CheckedTableSelectionDialog(Shell parent, ILabelProvider labelProvider,
- IStructuredContentProvider contentProvider) {
+ *
+ * @param labelProvider
+ * the label provider to render the entries
+ * @param contentProvider
+ * the content provider to evaluate the tree structure
+ */
+ public CheckedTableSelectionDialog(Shell parent,
+ ILabelProvider labelProvider,
+ IStructuredContentProvider contentProvider) {
super(parent);
-
- fLabelProvider= labelProvider;
- fContentProvider= contentProvider;
+
+ fLabelProvider = labelProvider;
+ fContentProvider = contentProvider;
setResult(new ArrayList(0));
setStatusLineAboveButtons(true);
}
/**
- * Sets the initial selection.
- * Convenience method.
- * @param selection the initial selection.
+ * Sets the initial selection. Convenience method.
+ *
+ * @param selection
+ * the initial selection.
*/
public void setInitialSelection(Object selection) {
- setInitialSelections(new Object[] {selection});
+ setInitialSelections(new Object[] { selection });
}
/**
* Sets the message to be displayed if the list is empty.
- * @param message the message to be displayed.
- */
+ *
+ * @param message
+ * the message to be displayed.
+ */
public void setEmptyListMessage(String message) {
- fEmptyListMessage= message;
- }
-
+ fEmptyListMessage = message;
+ }
+
/**
* Adds a filter to the tree viewer.
- * @param filter a filter.
+ *
+ * @param filter
+ * a filter.
*/
public void addFilter(ViewerFilter filter) {
if (fFilters == null)
- fFilters= new ArrayList<ViewerFilter>(4);
-
+ fFilters = new ArrayList<>(4);
+
fFilters.add(filter);
}
-
+
/**
- * Sets an optional validator to check if the selection is valid.
- * The validator is invoked whenever the selection changes.
- * @param validator the validator to validate the selection.
+ * Sets an optional validator to check if the selection is valid. The
+ * validator is invoked whenever the selection changes.
+ *
+ * @param validator
+ * the validator to validate the selection.
*/
public void setValidator(ISelectionStatusValidator validator) {
- fValidator= validator;
- }
-
+ fValidator = validator;
+ }
+
/**
* Sets the tree input.
- * @param input the tree input.
+ *
+ * @param input
+ * the tree input.
*/
public void setInput(Object input) {
- fInput= input;
+ fInput = input;
}
/**
* Sets the size of the tree in unit of characters.
- * @param width the width of the tree.
- * @param height the height of the tree.
+ *
+ * @param width
+ * the width of the tree.
+ * @param height
+ * the height of the tree.
*/
public void setSize(int width, int height) {
- fWidth= width;
- fHeight= height;
+ fWidth = width;
+ fHeight = height;
}
protected void updateOKStatus() {
if (!fIsEmpty) {
if (fValidator != null) {
- fCurrStatus= fValidator.validate(fViewer.getCheckedElements());
+ fCurrStatus = fValidator.validate(fViewer.getCheckedElements());
updateStatus(fCurrStatus);
} else if (!fCurrStatus.isOK()) {
- fCurrStatus= Status.CANCEL_STATUS;
+ fCurrStatus = Status.CANCEL_STATUS;
}
} else {
- fCurrStatus= new Status(IStatus.ERROR, DLTKTestingPlugin.PLUGIN_ID, fEmptyListMessage, null);
+ fCurrStatus = new Status(IStatus.ERROR, DLTKTestingPlugin.PLUGIN_ID,
+ fEmptyListMessage, null);
}
updateStatus(fCurrStatus);
}
-
+
@Override
public int open() {
- fIsEmpty= evaluateIfTableEmpty(fInput);
- BusyIndicator.showWhile(null, new Runnable() {
- @Override
- public void run() {
- access$superOpen();
- }
- });
+ fIsEmpty = evaluateIfTableEmpty(fInput);
+ BusyIndicator.showWhile(null, () -> access$superOpen());
return getReturnCode();
}
private void access$superOpen() {
super.open();
- }
-
+ }
+
/**
* Handles cancel button pressed event.
- */
+ */
@Override
protected void cancelPressed() {
setResult(null);
super.cancelPressed();
- }
+ }
@Override
protected void computeResult() {
setResult(Arrays.asList(fViewer.getCheckedElements()));
- }
-
+ }
+
@Override
public void create() {
super.create();
- List initialSelections= getInitialElementSelections();
+ List initialSelections = getInitialElementSelections();
if (initialSelections.size() > 0) {
- fViewer.setCheckedElements(initialSelections.toArray());
+ fViewer.setCheckedElements(initialSelections.toArray());
}
-
+
updateOKStatus();
- }
-
+ }
+
@Override
protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Label messageLabel= createMessageArea(composite);
- Control treeWidget= createTableViewer(composite);
- Control buttonComposite= createSelectionButtons(composite);
+ Composite composite = (Composite) super.createDialogArea(parent);
- GridData data= new GridData(GridData.FILL_BOTH);
- data.widthHint= convertWidthInCharsToPixels(fWidth);
- data.heightHint= convertHeightInCharsToPixels(fHeight);
+ Label messageLabel = createMessageArea(composite);
+ Control treeWidget = createTableViewer(composite);
+ Control buttonComposite = createSelectionButtons(composite);
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = convertWidthInCharsToPixels(fWidth);
+ data.heightHint = convertHeightInCharsToPixels(fHeight);
treeWidget.setLayoutData(data);
-
+
if (fIsEmpty) {
messageLabel.setEnabled(false);
treeWidget.setEnabled(false);
@@ -215,55 +220,58 @@
applyDialogFont(composite);
return composite;
}
-
+
private Table createTableViewer(Composite parent) {
- fViewer= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
-
+ fViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
+
fViewer.setContentProvider(fContentProvider);
fViewer.setLabelProvider(fLabelProvider);
- fViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- updateOKStatus();
- }
- });
-
+ fViewer.addCheckStateListener(event -> updateOKStatus());
+
if (fFilters != null) {
- for (int i= 0; i != fFilters.size(); i++)
+ for (int i = 0; i != fFilters.size(); i++)
fViewer.addFilter(fFilters.get(i));
}
-
+
fViewer.setInput(fInput);
- return fViewer.getTable();
+ return fViewer.getTable();
}
-
+
/**
* Add the selection and deselection buttons to the dialog.
- * @param composite org.eclipse.swt.widgets.Composite
+ *
+ * @param composite
+ * org.eclipse.swt.widgets.Composite
*/
private Composite createSelectionButtons(Composite composite) {
- Composite buttonComposite= new Composite(composite, SWT.RIGHT);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ Composite buttonComposite = new Composite(composite, SWT.RIGHT);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
buttonComposite.setLayout(layout);
- GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
- data.grabExcessHorizontalSpace= true;
+ GridData data = new GridData(
+ GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
+ data.grabExcessHorizontalSpace = true;
composite.setData(data);
- Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, WizardMessages.CheckedTableSelectionDialog_selectAll, false);
+ Button selectButton = createButton(buttonComposite,
+ IDialogConstants.SELECT_ALL_ID,
+ WizardMessages.CheckedTableSelectionDialog_selectAll, false);
- SelectionListener listener= new SelectionAdapter() {
+ SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- fViewer.setCheckedElements(fContentProvider.getElements(fInput));
+ fViewer.setCheckedElements(
+ fContentProvider.getElements(fInput));
updateOKStatus();
}
};
selectButton.addSelectionListener(listener);
- Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, WizardMessages.CheckedTableSelectionDialog_deselectAll, false);
+ Button deselectButton = createButton(buttonComposite,
+ IDialogConstants.DESELECT_ALL_ID,
+ WizardMessages.CheckedTableSelectionDialog_deselectAll, false);
- listener= new SelectionAdapter() {
+ listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fViewer.setCheckedElements(new Object[0]);
@@ -273,14 +281,14 @@
deselectButton.addSelectionListener(listener);
return buttonComposite;
}
-
+
private boolean evaluateIfTableEmpty(Object input) {
- Object[] elements= fContentProvider.getElements(input);
+ Object[] elements = fContentProvider.getElements(input);
if (elements.length > 0) {
if (fFilters != null) {
- for (int i= 0; i < fFilters.size(); i++) {
- ViewerFilter curr= fFilters.get(i);
- elements= curr.filter(fViewer, input, elements);
+ for (int i = 0; i < fFilters.size(); i++) {
+ ViewerFilter curr = fFilters.get(i);
+ elements = curr.filter(fViewer, input, elements);
}
}
}
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/DLTKTestingWizard.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/DLTKTestingWizard.java
index fe3a603..b890b80 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/DLTKTestingWizard.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/DLTKTestingWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,29 +15,23 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
+import org.eclipse.dltk.internal.testing.util.ExceptionHandler;
+import org.eclipse.dltk.testing.DLTKTestingPlugin;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
-
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-
import org.eclipse.ui.ide.IDE;
-
-import org.eclipse.dltk.internal.testing.util.ExceptionHandler;
-import org.eclipse.dltk.testing.DLTKTestingPlugin;
-
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
/**
* The wizard base class for JUnit creation wizards.
@@ -45,35 +39,35 @@
public abstract class DLTKTestingWizard extends Wizard implements INewWizard {
private IWorkbench fWorkbench;
- protected static final String DIALOG_SETTINGS_KEY= "JUnitWizards"; //$NON-NLS-1$
+ protected static final String DIALOG_SETTINGS_KEY = "JUnitWizards"; //$NON-NLS-1$
private IStructuredSelection fSelection;
public DLTKTestingWizard() {
setNeedsProgressMonitor(true);
initializeDefaultPageImageDescriptor();
}
-
- /*
- * @see IWizard#performFinish()
- */
+
@Override
public abstract boolean performFinish();
/*
* Run a runnable
- */
+ */
protected boolean finishPage(IRunnableWithProgress runnable) {
- IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+ IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(
+ runnable);
try {
- PlatformUI.getWorkbench().getProgressService().runInUI(getContainer(), op, ResourcesPlugin.getWorkspace().getRoot());
-
+ PlatformUI.getWorkbench().getProgressService().runInUI(
+ getContainer(), op,
+ ResourcesPlugin.getWorkspace().getRoot());
+
} catch (InvocationTargetException e) {
- Shell shell= getShell();
- String title= WizardMessages.NewJUnitWizard_op_error_title;
- String message= WizardMessages.NewJUnitWizard_op_error_message;
+ Shell shell = getShell();
+ String title = WizardMessages.NewJUnitWizard_op_error_title;
+ String message = WizardMessages.NewJUnitWizard_op_error_message;
ExceptionHandler.handle(e, shell, title, message);
return false;
- } catch (InterruptedException e) {
+ } catch (InterruptedException e) {
return false;
}
return true;
@@ -81,18 +75,15 @@
protected void openResource(final IResource resource) {
if (resource.getType() == IResource.FILE) {
- final IWorkbenchPage activePage= DLTKTestingPlugin.getActivePage();
+ final IWorkbenchPage activePage = DLTKTestingPlugin.getActivePage();
if (activePage != null) {
- final Display display= Display.getDefault();
+ final Display display = Display.getDefault();
if (display != null) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- IDE.openEditor(activePage, (IFile)resource, true);
- } catch (PartInitException e) {
- DLTKTestingPlugin.log(e);
- }
+ display.asyncExec(() -> {
+ try {
+ IDE.openEditor(activePage, (IFile) resource, true);
+ } catch (PartInitException e) {
+ DLTKTestingPlugin.log(e);
}
});
}
@@ -101,24 +92,28 @@
}
@Override
- public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
- fWorkbench= workbench;
- fSelection= currentSelection;
+ public void init(IWorkbench workbench,
+ IStructuredSelection currentSelection) {
+ fWorkbench = workbench;
+ fSelection = currentSelection;
}
-
+
public IStructuredSelection getSelection() {
return fSelection;
}
protected void selectAndReveal(IResource newResource) {
- BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
- }
-
+ BasicNewResourceWizard.selectAndReveal(newResource,
+ fWorkbench.getActiveWorkbenchWindow());
+ }
+
protected void initDialogSettings() {
- IDialogSettings pluginSettings= DLTKTestingPlugin.getDefault().getDialogSettings();
- IDialogSettings wizardSettings= pluginSettings.getSection(DIALOG_SETTINGS_KEY);
+ IDialogSettings pluginSettings = DLTKTestingPlugin.getDefault()
+ .getDialogSettings();
+ IDialogSettings wizardSettings = pluginSettings
+ .getSection(DIALOG_SETTINGS_KEY);
if (wizardSettings == null) {
- wizardSettings= new DialogSettings(DIALOG_SETTINGS_KEY);
+ wizardSettings = new DialogSettings(DIALOG_SETTINGS_KEY);
pluginSettings.addSection(wizardSettings);
}
setDialogSettings(wizardSettings);
diff --git a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/MethodStubsSelectionButtonGroup.java b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/MethodStubsSelectionButtonGroup.java
index e90f367..52aef90 100755
--- a/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/MethodStubsSelectionButtonGroup.java
+++ b/core/plugins/org.eclipse.dltk.testing/src/org/eclipse/dltk/internal/testing/wizards/MethodStubsSelectionButtonGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,7 @@
package org.eclipse.dltk.internal.testing.wizards;
import org.eclipse.core.runtime.Assert;
-
+import org.eclipse.dltk.internal.testing.util.LayoutUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -24,204 +24,207 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.dltk.internal.testing.util.LayoutUtil;
-
-
-
/**
- * A group of controls used in the JUnit TestCase and TestSuite wizards
- * for selecting method stubs to create.
+ * A group of controls used in the JUnit TestCase and TestSuite wizards for
+ * selecting method stubs to create.
*/
public class MethodStubsSelectionButtonGroup {
private Label fLabel;
protected String fLabelText;
-
+
private SelectionButtonGroupListener fGroupListener;
-
+
private boolean fEnabled;
private Composite fButtonComposite;
-
+
private Button[] fButtons;
private String[] fButtonNames;
private boolean[] fButtonsSelected;
private boolean[] fButtonsEnabled;
-
+
private int fGroupBorderStyle;
private int fGroupNumberOfColumns;
- private int fButtonsStyle;
-
+ private int fButtonsStyle;
public interface SelectionButtonGroupListener {
/**
* The dialog field has changed.
- * @param field The changed dialog field
+ *
+ * @param field
+ * The changed dialog field
*/
void groupChanged(MethodStubsSelectionButtonGroup field);
}
-
+
/**
* Creates a group without border.
*/
- public MethodStubsSelectionButtonGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
- this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
- }
-
- /**
- * Creates a group with border (label in border).
- * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
- * For border styles see <code>Group</code>
- */
- public MethodStubsSelectionButtonGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
- fEnabled= true;
- fLabel= null;
- fLabelText= ""; //$NON-NLS-1$
-
- Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
- fButtonNames= buttonNames;
-
- int nButtons= buttonNames.length;
- fButtonsSelected= new boolean[nButtons];
- fButtonsEnabled= new boolean[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtonsSelected[i]= false;
- fButtonsEnabled[i]= true;
- }
-
- if (buttonsStyle == SWT.RADIO) {
- fButtonsSelected[0]= true;
- }
-
- fGroupBorderStyle= borderStyle;
- fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-
- fButtonsStyle= buttonsStyle;
+ public MethodStubsSelectionButtonGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns) {
+ this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
}
-
+
+ /**
+ * Creates a group with border (label in border). Accepted button styles
+ * are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see
+ * <code>Group</code>
+ */
+ public MethodStubsSelectionButtonGroup(int buttonsStyle,
+ String[] buttonNames, int nColumns, int borderStyle) {
+ fEnabled = true;
+ fLabel = null;
+ fLabelText = ""; //$NON-NLS-1$
+
+ Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK
+ || buttonsStyle == SWT.TOGGLE);
+ fButtonNames = buttonNames;
+
+ int nButtons = buttonNames.length;
+ fButtonsSelected = new boolean[nButtons];
+ fButtonsEnabled = new boolean[nButtons];
+ for (int i = 0; i < nButtons; i++) {
+ fButtonsSelected[i] = false;
+ fButtonsEnabled[i] = true;
+ }
+
+ if (buttonsStyle == SWT.RADIO) {
+ fButtonsSelected[0] = true;
+ }
+
+ fGroupBorderStyle = borderStyle;
+ fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
+
+ fButtonsStyle = buttonsStyle;
+ }
+
/*
* @see DialogField#doFillIntoGrid
*/
public Control[] doFillIntoGrid(Composite parent, int nColumns) {
assertEnoughColumns(nColumns);
-
+
if (fGroupBorderStyle == SWT.NONE) {
- Label label= getLabelControl(parent);
+ Label label = getLabelControl(parent);
label.setLayoutData(gridDataForLabel(1));
-
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns - 1;
+
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns - 1;
buttonsgroup.setLayoutData(gd);
return new Control[] { label, buttonsgroup };
} else {
- Composite buttonsgroup= getSelectionButtonsGroup(parent);
- GridData gd= new GridData();
- gd.horizontalSpan= nColumns;
+ Composite buttonsgroup = getSelectionButtonsGroup(parent);
+ GridData gd = new GridData();
+ gd.horizontalSpan = nColumns;
buttonsgroup.setLayoutData(gd);
return new Control[] { buttonsgroup };
}
- }
+ }
/*
* @see DialogField#doFillIntoGrid
- */
+ */
public int getNumberOfControls() {
return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
}
-
- private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
- Button button= new Button(group, fButtonsStyle | SWT.LEFT);
- button.setFont(group.getFont());
+
+ private Button createSelectionButton(int index, Composite group,
+ SelectionListener listener) {
+ Button button = new Button(group, fButtonsStyle | SWT.LEFT);
+ button.setFont(group.getFont());
button.setText(fButtonNames[index]);
button.setEnabled(isEnabled() && isEnabled(index));
button.setSelection(isSelected(index));
button.addSelectionListener(listener);
return button;
}
-
/**
- * Returns the group widget. When called the first time, the widget will be created.
- * @param parent composite when called the first time, or <code>null</code>
- * after.
+ * Returns the group widget. When called the first time, the widget will be
+ * created.
+ *
+ * @param parent
+ * composite when called the first time, or <code>null</code>
+ * after.
*/
public Composite getSelectionButtonsGroup(Composite parent) {
if (fButtonComposite == null) {
assertCompositeNotNull(parent);
-
- GridLayout layout= new GridLayout();
- //layout.makeColumnsEqualWidth= true;
- layout.numColumns= fGroupNumberOfColumns;
-
+
+ GridLayout layout = new GridLayout();
+ // layout.makeColumnsEqualWidth= true;
+ layout.numColumns = fGroupNumberOfColumns;
+
if (fGroupBorderStyle != SWT.NONE) {
- Group group= new Group(parent, fGroupBorderStyle);
+ Group group = new Group(parent, fGroupBorderStyle);
if (fLabelText != null && fLabelText.length() > 0) {
group.setText(fLabelText);
}
- fButtonComposite= group;
+ fButtonComposite = group;
} else {
- fButtonComposite= new Composite(parent, SWT.NULL);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
+ fButtonComposite = new Composite(parent, SWT.NULL);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
}
fButtonComposite.setLayout(layout);
-
- SelectionListener listener= new SelectionListener() {
+
+ SelectionListener listener = new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
doWidgetSelected(e);
}
+
@Override
public void widgetSelected(SelectionEvent e) {
doWidgetSelected(e);
}
};
- int nButtons= fButtonNames.length;
- fButtons= new Button[nButtons];
+ int nButtons = fButtonNames.length;
+ fButtons = new Button[nButtons];
- for (int i= 0; i < nButtons; i++) {
- fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+ for (int i = 0; i < nButtons; i++) {
+ fButtons[i] = createSelectionButton(i, fButtonComposite,
+ listener);
}
- int nRows= nButtons / fGroupNumberOfColumns;
- int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
- for (int i= 0; i < nFillElements; i++) {
+ int nRows = nButtons / fGroupNumberOfColumns;
+ int nFillElements = nRows * fGroupNumberOfColumns - nButtons;
+ for (int i = 0; i < nFillElements; i++) {
createEmptySpace(fButtonComposite);
}
- setSelectionGroupListener(new SelectionButtonGroupListener() {
- @Override
- public void groupChanged(MethodStubsSelectionButtonGroup field) {
- field.setEnabled(1, isEnabled() && field.isSelected(0));
- }
- });
+ setSelectionGroupListener(field -> field.setEnabled(1,
+ isEnabled() && field.isSelected(0)));
}
return fButtonComposite;
}
/**
* Returns a button from the group or <code>null</code> if not yet created.
- */
+ */
public Button getSelectionButton(int index) {
if (index >= 0 && index < fButtons.length) {
return fButtons[index];
}
return null;
}
-
+
private void doWidgetSelected(SelectionEvent e) {
- Button button= (Button)e.widget;
- for (int i= 0; i < fButtons.length; i++) {
+ Button button = (Button) e.widget;
+ for (int i = 0; i < fButtons.length; i++) {
if (fButtons[i] == button) {
- fButtonsSelected[i]= button.getSelection();
+ fButtonsSelected[i] = button.getSelection();
dialogFieldChanged();
return;
}
}
- }
-
+ }
+
/**
* Returns the selection state of a button contained in the group.
- * @param index of the button
+ *
+ * @param index
+ * of the button
*/
public boolean isSelected(int index) {
if (index >= 0 && index < fButtonsSelected.length) {
@@ -229,16 +232,16 @@
}
return false;
}
-
+
/**
* Sets the selection state of a button contained in the group.
*/
public void setSelection(int index, boolean selected) {
if (index >= 0 && index < fButtonsSelected.length) {
if (fButtonsSelected[index] != selected) {
- fButtonsSelected[index]= selected;
+ fButtonsSelected[index] = selected;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button) && button.isEnabled()) {
button.setSelection(selected);
}
@@ -249,7 +252,9 @@
/**
* Returns the enabled state of a button contained in the group.
- * @param index of the button
+ *
+ * @param index
+ * of the button
*/
public boolean isEnabled(int index) {
if (index >= 0 && index < fButtonsEnabled.length) {
@@ -257,16 +262,16 @@
}
return false;
}
-
+
/**
* Sets the selection state of a button contained in the group.
*/
public void setEnabled(int index, boolean enabled) {
if (index >= 0 && index < fButtonsEnabled.length) {
if (fButtonsEnabled[index] != enabled) {
- fButtonsEnabled[index]= enabled;
+ fButtonsEnabled[index] = enabled;
if (fButtons != null) {
- Button button= fButtons[index];
+ Button button = fButtons[index];
if (isOkToUse(button)) {
button.setEnabled(enabled);
if (!enabled) {
@@ -285,9 +290,9 @@
fLabel.setEnabled(fEnabled);
}
if (fButtons != null) {
- boolean enabled= isEnabled();
- for (int i= 0; i < fButtons.length; i++) {
- Button button= fButtons[i];
+ boolean enabled = isEnabled();
+ for (int i = 0; i < fButtons.length; i++) {
+ Button button = fButtons[i];
if (isOkToUse(button)) {
button.setEnabled(enabled && fButtonsEnabled[i]);
}
@@ -299,29 +304,30 @@
* Sets the label of the dialog field.
*/
public void setLabelText(String labeltext) {
- fLabelText= labeltext;
+ fLabelText = labeltext;
}
-
+
/**
* Defines the listener for this dialog field.
- */
- public final void setSelectionGroupListener(SelectionButtonGroupListener listener) {
- fGroupListener= listener;
+ */
+ public final void setSelectionGroupListener(
+ SelectionButtonGroupListener listener) {
+ fGroupListener = listener;
}
/**
* A dialog field has changed.
- */
+ */
public void dialogFieldChanged() {
if (fGroupListener != null) {
fGroupListener.groupChanged(this);
}
- }
-
+ }
+
/**
- * Tries to set the focus to the dialog field.
- * Returns <code>true</code> if the dialog field can take focus.
- * To be re-implemented by dialog field implementors.
+ * Tries to set the focus to the dialog field. Returns <code>true</code> if
+ * the dialog field can take focus. To be re-implemented by dialog field
+ * implementors.
*/
public boolean setFocus() {
return false;
@@ -329,98 +335,98 @@
/**
* Posts <code>setFocus</code> to the display event queue.
- */
+ */
public void postSetFocusOnDialogField(Display display) {
if (display != null) {
- display.asyncExec(
- new Runnable() {
- @Override
- public void run() {
- setFocus();
- }
- }
- );
+ display.asyncExec(() -> setFocus());
}
- }
-
+ }
+
protected static GridData gridDataForLabel(int span) {
- GridData gd= new GridData();
- gd.horizontalSpan= span;
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
return gd;
}
-
+
/**
* Creates or returns the created label widget.
- * @param parent The parent composite or <code>null</code> if the widget has
- * already been created.
- */
+ *
+ * @param parent
+ * The parent composite or <code>null</code> if the widget has
+ * already been created.
+ */
public Label getLabelControl(Composite parent) {
if (fLabel == null) {
assertCompositeNotNull(parent);
-
- fLabel= new Label(parent, SWT.LEFT | SWT.WRAP);
+
+ fLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
fLabel.setFont(parent.getFont());
- fLabel.setEnabled(fEnabled);
+ fLabel.setEnabled(fEnabled);
if (fLabelText != null && !"".equals(fLabelText)) { //$NON-NLS-1$
fLabel.setText(fLabelText);
} else {
// XXX: to avoid a 16 pixel wide empty label - revisit
fLabel.setText("."); //$NON-NLS-1$
fLabel.setVisible(false);
- }
+ }
}
return fLabel;
}
/**
* Creates a spacer control.
- * @param parent The parent composite
- */
+ *
+ * @param parent
+ * The parent composite
+ */
public static Control createEmptySpace(Composite parent) {
return createEmptySpace(parent, 1);
}
/**
- * Creates a spacer control with the given span.
- * The composite is assumed to have <code>MGridLayout</code> as
- * layout.
- * @param parent The parent composite
- */
+ * Creates a spacer control with the given span. The composite is assumed to
+ * have <code>MGridLayout</code> as layout.
+ *
+ * @param parent
+ * The parent composite
+ */
public static Control createEmptySpace(Composite parent, int span) {
return LayoutUtil.createEmptySpace(parent, span);
}
-
+
/**
* Tests is the control is not <code>null</code> and not disposed.
- */
+ */
protected final boolean isOkToUse(Control control) {
return (control != null) && !(control.isDisposed());
}
-
+
// --------- enable / disable management
-
+
/**
* Sets the enable state of the dialog field.
*/
public final void setEnabled(boolean enabled) {
if (enabled != fEnabled) {
- fEnabled= enabled;
+ fEnabled = enabled;
updateEnableState();
}
}
-
+
/**
* Gets the enable state of the dialog field.
- */
+ */
public final boolean isEnabled() {
return fEnabled;
}
protected final void assertCompositeNotNull(Composite comp) {
- Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
+ Assert.isNotNull(comp,
+ "uncreated control requested with composite null"); //$NON-NLS-1$
}
-
+
protected final void assertEnoughColumns(int nColumns) {
- Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$
+ Assert.isTrue(nColumns >= getNumberOfControls(),
+ "given number of columns is too small"); //$NON-NLS-1$
}
}