formatting
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 149519c..1357fdc 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
@@ -46,7 +46,6 @@
import org.eclipse.dltk.core.IModelElementDelta;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.internal.testing.Messages;
-import org.eclipse.dltk.internal.testing.launcher.NullTestingEngine;
import org.eclipse.dltk.internal.testing.model.DLTKTestingModel;
import org.eclipse.dltk.internal.testing.model.ITestRunSessionListener;
import org.eclipse.dltk.internal.testing.model.ITestSessionListener;
@@ -56,9 +55,8 @@
import org.eclipse.dltk.testing.DLTKTestingConstants;
import org.eclipse.dltk.testing.DLTKTestingMessages;
import org.eclipse.dltk.testing.DLTKTestingPlugin;
-import org.eclipse.dltk.testing.ITestSession;
-import org.eclipse.dltk.testing.ITestingEngine;
import org.eclipse.dltk.testing.ITestRunnerUI;
+import org.eclipse.dltk.testing.ITestSession;
import org.eclipse.dltk.testing.model.ITestElement.Result;
import org.eclipse.dltk.ui.viewsupport.ViewHistory;
import org.eclipse.jface.action.Action;
@@ -112,33 +110,31 @@
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
import org.eclipse.ui.progress.UIJob;
-
-
-
-/**
+/**
* A ViewPart that shows the results of a test run.
*/
public class TestRunnerViewPart extends ViewPart {
- public static final String NAME= "org.eclipse.dltk.testing.ResultView"; //$NON-NLS-1$
-
+ public static final String NAME = "org.eclipse.dltk.testing.ResultView"; //$NON-NLS-1$
+
private static final String RERUN_LAST_COMMAND = "org.eclipse.dltk.testing.testingShortcut.rerunLast"; //$NON-NLS-1$
//private static final String RERUN_FAILED_FIRST_COMMAND= "org.eclipse.dltk.testing.testingShortcut.rerunFailedFirst"; //$NON-NLS-1$
- static final int REFRESH_INTERVAL= 200;
-
- static final int LAYOUT_FLAT= 0;
- static final int LAYOUT_HIERARCHICAL= 1;
-
+ static final int REFRESH_INTERVAL = 200;
+
+ static final int LAYOUT_FLAT = 0;
+ static final int LAYOUT_HIERARCHICAL = 1;
+
/**
* Whether the output scrolls and reveals tests as they are executed.
*/
protected boolean fAutoScroll = true;
/**
* The current orientation; either <code>VIEW_ORIENTATION_HORIZONTAL</code>
- * <code>VIEW_ORIENTATION_VERTICAL</code>, or <code>VIEW_ORIENTATION_AUTOMATIC</code>.
+ * <code>VIEW_ORIENTATION_VERTICAL</code>, or
+ * <code>VIEW_ORIENTATION_AUTOMATIC</code>.
*/
- private int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
+ private int fOrientation = VIEW_ORIENTATION_AUTOMATIC;
/**
* The current orientation; either <code>VIEW_ORIENTATION_HORIZONTAL</code>
* <code>VIEW_ORIENTATION_VERTICAL</code>.
@@ -147,40 +143,40 @@
/**
* The current layout mode (LAYOUT_FLAT or LAYOUT_HIERARCHICAL).
*/
- private int fLayout= LAYOUT_HIERARCHICAL;
-
-// private boolean fTestIsRunning= false;
+ private int fLayout = LAYOUT_HIERARCHICAL;
+
+ // private boolean fTestIsRunning= false;
protected DLTKTestingProgressBar fProgressBar;
protected ProgressImages fProgressImages;
protected Image fViewImage;
protected CounterPanel fCounterPanel;
- protected boolean fShowOnErrorOnly= false;
+ protected boolean fShowOnErrorOnly = false;
protected Clipboard fClipboard;
protected volatile String fInfoMessage;
private FailureTrace fFailureTrace;
-
+
private TestViewer fTestViewer;
/**
* Is the UI disposed?
*/
- private boolean fIsDisposed= false;
-
+ private boolean fIsDisposed = false;
+
/**
* Actions
*/
private Action fNextAction;
private Action fPreviousAction;
-
+
private StopAction fStopAction;
private DLTKTestingCopyAction fCopyAction;
-
+
private Action fRerunLastTestAction;
private IHandlerActivation fRerunLastActivation;
-// private Action fRerunFailedFirstAction;
-// private IHandlerActivation fRerunFailedFirstActivation;
-
+ // private Action fRerunFailedFirstAction;
+ // private IHandlerActivation fRerunFailedFirstActivation;
+
private Action fFailuresOnlyFilterAction;
private ScrollLockAction fScrollLockAction;
private ToggleOrientationAction[] fToggleOrientationActions;
@@ -190,114 +186,147 @@
private TestRunSession fTestRunSession;
private TestSessionListener fTestSessionListener;
-
+
private RunnerViewHistory fViewHistory;
private TestRunSessionListener fTestRunSessionListener;
- final Image fStackViewIcon= TestRunnerViewPart.createImage("eview16/stackframe.gif");//$NON-NLS-1$
- final Image fTestRunOKIcon= TestRunnerViewPart.createImage("eview16/testsucc.gif"); //$NON-NLS-1$
- final Image fTestRunFailIcon= TestRunnerViewPart.createImage("eview16/testerr.gif"); //$NON-NLS-1$
- final Image fTestRunOKDirtyIcon= TestRunnerViewPart.createImage("eview16/testsuccq.gif"); //$NON-NLS-1$
- final Image fTestRunFailDirtyIcon= TestRunnerViewPart.createImage("eview16/testerrq.gif"); //$NON-NLS-1$
-
- final Image fTestIcon= TestRunnerViewPart.createImage("obj16/test.gif"); //$NON-NLS-1$
- final Image fTestOkIcon= TestRunnerViewPart.createImage("obj16/testok.gif"); //$NON-NLS-1$
- final Image fTestErrorIcon= TestRunnerViewPart.createImage("obj16/testerr.gif"); //$NON-NLS-1$
- final Image fTestFailIcon= TestRunnerViewPart.createImage("obj16/testfail.gif"); //$NON-NLS-1$
- final Image fTestSkippedIcon= TestRunnerViewPart.createImage("obj16/testskipped.gif"); //$NON-NLS-1$
- final Image fTestBlockedIcon= TestRunnerViewPart.createImage("obj16/testblocked.gif"); //$NON-NLS-1$
- final Image fTestAbortedIcon= TestRunnerViewPart.createImage("obj16/testabort.gif"); //$NON-NLS-1$
- final Image fTestRunningIcon= TestRunnerViewPart.createImage("obj16/testrun.gif"); //$NON-NLS-1$
- final Image fTestIgnoredIcon= TestRunnerViewPart.createImage("obj16/testignored.gif"); //$NON-NLS-1$
- final Image fTestUnknownIcon= TestRunnerViewPart.createImage("obj16/testunknown.gif"); //$NON-NLS-1$
-
- final ImageDescriptor fSuiteIconDescriptor= DLTKTestingPlugin.getImageDescriptor("obj16/tsuite.gif"); //$NON-NLS-1$
- final ImageDescriptor fSuiteOkIconDescriptor= DLTKTestingPlugin.getImageDescriptor("obj16/tsuiteok.gif"); //$NON-NLS-1$
- final ImageDescriptor fSuiteErrorIconDescriptor= DLTKTestingPlugin.getImageDescriptor("obj16/tsuiteerror.gif"); //$NON-NLS-1$
- final ImageDescriptor fSuiteFailIconDescriptor= DLTKTestingPlugin.getImageDescriptor("obj16/tsuitefail.gif"); //$NON-NLS-1$
- final ImageDescriptor fSuiteRunningIconDescriptor= DLTKTestingPlugin.getImageDescriptor("obj16/tsuiterun.gif"); //$NON-NLS-1$
-
- final Image fSuiteIcon= fSuiteIconDescriptor.createImage();
- final Image fSuiteOkIcon= fSuiteOkIconDescriptor.createImage();
- final Image fSuiteErrorIcon= fSuiteErrorIconDescriptor.createImage();
- final Image fSuiteFailIcon= fSuiteFailIconDescriptor.createImage();
-
- final Image fSuiteAbortedIcon = TestRunnerViewPart.createImage("obj16/tsuiteabort.gif"); //$NON-NLS-1$
- final Image fSuiteSkippedIcon = TestRunnerViewPart.createImage("obj16/tsuiteskipped.gif"); //$NON-NLS-1$
- final Image fSuiteBlockedIcon = TestRunnerViewPart.createImage("obj16/tsuiteblocked.gif"); //$NON-NLS-1$
- final Image fSuiteUnknownIcon = TestRunnerViewPart.createImage("obj16/tsuiteunknown.gif"); //$NON-NLS-1$
-
- final Image fSuiteRunningIcon= fSuiteRunningIconDescriptor.createImage();
-
+ final Image fStackViewIcon = TestRunnerViewPart
+ .createImage("eview16/stackframe.gif");//$NON-NLS-1$
+ final Image fTestRunOKIcon = TestRunnerViewPart
+ .createImage("eview16/testsucc.gif"); //$NON-NLS-1$
+ final Image fTestRunFailIcon = TestRunnerViewPart
+ .createImage("eview16/testerr.gif"); //$NON-NLS-1$
+ final Image fTestRunOKDirtyIcon = TestRunnerViewPart
+ .createImage("eview16/testsuccq.gif"); //$NON-NLS-1$
+ final Image fTestRunFailDirtyIcon = TestRunnerViewPart
+ .createImage("eview16/testerrq.gif"); //$NON-NLS-1$
+
+ final Image fTestIcon = TestRunnerViewPart.createImage("obj16/test.gif"); //$NON-NLS-1$
+ final Image fTestOkIcon = TestRunnerViewPart
+ .createImage("obj16/testok.gif"); //$NON-NLS-1$
+ final Image fTestErrorIcon = TestRunnerViewPart
+ .createImage("obj16/testerr.gif"); //$NON-NLS-1$
+ final Image fTestFailIcon = TestRunnerViewPart
+ .createImage("obj16/testfail.gif"); //$NON-NLS-1$
+ final Image fTestSkippedIcon = TestRunnerViewPart
+ .createImage("obj16/testskipped.gif"); //$NON-NLS-1$
+ final Image fTestBlockedIcon = TestRunnerViewPart
+ .createImage("obj16/testblocked.gif"); //$NON-NLS-1$
+ final Image fTestAbortedIcon = TestRunnerViewPart
+ .createImage("obj16/testabort.gif"); //$NON-NLS-1$
+ final Image fTestRunningIcon = TestRunnerViewPart
+ .createImage("obj16/testrun.gif"); //$NON-NLS-1$
+ final Image fTestIgnoredIcon = TestRunnerViewPart
+ .createImage("obj16/testignored.gif"); //$NON-NLS-1$
+ final Image fTestUnknownIcon = TestRunnerViewPart
+ .createImage("obj16/testunknown.gif"); //$NON-NLS-1$
+
+ final ImageDescriptor fSuiteIconDescriptor = DLTKTestingPlugin
+ .getImageDescriptor("obj16/tsuite.gif"); //$NON-NLS-1$
+ final ImageDescriptor fSuiteOkIconDescriptor = DLTKTestingPlugin
+ .getImageDescriptor("obj16/tsuiteok.gif"); //$NON-NLS-1$
+ final ImageDescriptor fSuiteErrorIconDescriptor = DLTKTestingPlugin
+ .getImageDescriptor("obj16/tsuiteerror.gif"); //$NON-NLS-1$
+ final ImageDescriptor fSuiteFailIconDescriptor = DLTKTestingPlugin
+ .getImageDescriptor("obj16/tsuitefail.gif"); //$NON-NLS-1$
+ final ImageDescriptor fSuiteRunningIconDescriptor = DLTKTestingPlugin
+ .getImageDescriptor("obj16/tsuiterun.gif"); //$NON-NLS-1$
+
+ final Image fSuiteIcon = fSuiteIconDescriptor.createImage();
+ final Image fSuiteOkIcon = fSuiteOkIconDescriptor.createImage();
+ final Image fSuiteErrorIcon = fSuiteErrorIconDescriptor.createImage();
+ final Image fSuiteFailIcon = fSuiteFailIconDescriptor.createImage();
+
+ final Image fSuiteAbortedIcon = TestRunnerViewPart
+ .createImage("obj16/tsuiteabort.gif"); //$NON-NLS-1$
+ final Image fSuiteSkippedIcon = TestRunnerViewPart
+ .createImage("obj16/tsuiteskipped.gif"); //$NON-NLS-1$
+ final Image fSuiteBlockedIcon = TestRunnerViewPart
+ .createImage("obj16/tsuiteblocked.gif"); //$NON-NLS-1$
+ final Image fSuiteUnknownIcon = TestRunnerViewPart
+ .createImage("obj16/tsuiteunknown.gif"); //$NON-NLS-1$
+
+ final Image fSuiteRunningIcon = fSuiteRunningIconDescriptor.createImage();
+
// Persistence tags.
- static final String TAG_PAGE= "page"; //$NON-NLS-1$
- static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
- static final String TAG_TRACEFILTER= "tracefilter"; //$NON-NLS-1$
- static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
- static final String TAG_SCROLL= "scroll"; //$NON-NLS-1$
+ static final String TAG_PAGE = "page"; //$NON-NLS-1$
+ static final String TAG_RATIO = "ratio"; //$NON-NLS-1$
+ static final String TAG_TRACEFILTER = "tracefilter"; //$NON-NLS-1$
+ static final String TAG_ORIENTATION = "orientation"; //$NON-NLS-1$
+ static final String TAG_SCROLL = "scroll"; //$NON-NLS-1$
/**
* @since 3.2
*/
- static final String TAG_LAYOUT= "layout"; //$NON-NLS-1$
+ static final String TAG_LAYOUT = "layout"; //$NON-NLS-1$
/**
* @since 3.2
*/
- static final String TAG_FAILURES_ONLY= "failuresOnly"; //$NON-NLS-1$
-
- //orientations
- static final int VIEW_ORIENTATION_VERTICAL= 0;
- static final int VIEW_ORIENTATION_HORIZONTAL= 1;
- static final int VIEW_ORIENTATION_AUTOMATIC= 2;
-
- private IMemento fMemento;
+ static final String TAG_FAILURES_ONLY = "failuresOnly"; //$NON-NLS-1$
+
+ // orientations
+ static final int VIEW_ORIENTATION_VERTICAL = 0;
+ static final int VIEW_ORIENTATION_HORIZONTAL = 1;
+ static final int VIEW_ORIENTATION_AUTOMATIC = 2;
+
+ private IMemento fMemento;
Image fOriginalViewImage;
IElementChangedListener fDirtyListener;
-
-
-// private CTabFolder fTabFolder;
+
+ // private CTabFolder fTabFolder;
private SashForm fSashForm;
-
+
private Composite fCounterComposite;
private Composite fParent;
-
+
/**
- * A Job that periodically updates view description, counters, and progress bar.
+ * A Job that periodically updates view description, counters, and progress
+ * bar.
*/
private UpdateUIJob fUpdateJob;
-
+
/**
- * A Job that runs as long as a test run is running.
- * It is used to show busyness for running jobs in the view (title in italics).
+ * A Job that runs as long as a test run is running. It is used to show
+ * busyness for running jobs in the view (title in italics).
*/
private JUnitIsRunningJob fJUnitIsRunningJob;
private ILock fJUnitIsRunningLock;
public static final Object FAMILY_JUNIT_RUN = new Object();
- private IPartListener2 fPartListener= new IPartListener2() {
- public void partActivated(IWorkbenchPartReference ref) { }
- public void partBroughtToTop(IWorkbenchPartReference ref) { }
- public void partInputChanged(IWorkbenchPartReference ref) { }
- public void partClosed(IWorkbenchPartReference ref) { }
- public void partDeactivated(IWorkbenchPartReference ref) { }
- public void partOpened(IWorkbenchPartReference ref) { }
-
+ private IPartListener2 fPartListener = new IPartListener2() {
+ public void partActivated(IWorkbenchPartReference ref) {
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference ref) {
+ }
+
+ public void partInputChanged(IWorkbenchPartReference ref) {
+ }
+
+ public void partClosed(IWorkbenchPartReference ref) {
+ }
+
+ public void partDeactivated(IWorkbenchPartReference ref) {
+ }
+
+ public void partOpened(IWorkbenchPartReference ref) {
+ }
+
public void partVisible(IWorkbenchPartReference ref) {
if (getSite().getId().equals(ref.getId())) {
- fPartIsVisible= true;
+ fPartIsVisible = true;
}
}
-
+
public void partHidden(IWorkbenchPartReference ref) {
if (getSite().getId().equals(ref.getId())) {
- fPartIsVisible= false;
+ fPartIsVisible = false;
}
}
};
-
- protected boolean fPartIsVisible= false;
-
+ protected boolean fPartIsVisible = false;
+
private class RunnerViewHistory extends ViewHistory {
public void configureHistoryListAction(IAction action) {
@@ -305,10 +334,12 @@
}
public void configureHistoryDropDownAction(IAction action) {
- action.setToolTipText(DLTKTestingMessages.TestRunnerViewPart_test_run_history);
- DLTKTestingPlugin.setLocalImageDescriptors(action, "history_list.gif"); //$NON-NLS-1$
+ action
+ .setToolTipText(DLTKTestingMessages.TestRunnerViewPart_test_run_history);
+ DLTKTestingPlugin.setLocalImageDescriptors(action,
+ "history_list.gif"); //$NON-NLS-1$
}
-
+
public Action getClearAction() {
return new ClearAction();
}
@@ -334,34 +365,36 @@
}
public void setActiveEntry(Object entry) {
- TestRunSession deactivatedSession= setActiveTestRunSession((TestRunSession) entry);
+ TestRunSession deactivatedSession = setActiveTestRunSession((TestRunSession) entry);
if (deactivatedSession != null)
deactivatedSession.swapOut();
}
public void setHistoryEntries(List remainingEntries, Object activeEntry) {
setActiveTestRunSession((TestRunSession) activeEntry);
-
- List testRunSessions= DLTKTestingPlugin.getModel().getTestRunSessions();
+
+ List testRunSessions = DLTKTestingPlugin.getModel()
+ .getTestRunSessions();
testRunSessions.removeAll(remainingEntries);
- for (Iterator iter= testRunSessions.iterator(); iter.hasNext();) {
- DLTKTestingPlugin.getModel().removeTestRunSession((TestRunSession) iter.next());
+ for (Iterator iter = testRunSessions.iterator(); iter.hasNext();) {
+ DLTKTestingPlugin.getModel().removeTestRunSession(
+ (TestRunSession) iter.next());
}
- for (Iterator iter= remainingEntries.iterator(); iter.hasNext();) {
- TestRunSession remaining= (TestRunSession) iter.next();
+ for (Iterator iter = remainingEntries.iterator(); iter.hasNext();) {
+ TestRunSession remaining = (TestRunSession) iter.next();
remaining.swapOut();
}
}
public ImageDescriptor getImageDescriptor(Object element) {
- TestRunSession session= (TestRunSession) element;
+ TestRunSession session = (TestRunSession) element;
if (session.isStopped())
return fSuiteIconDescriptor;
-
+
if (session.isRunning())
return fSuiteRunningIconDescriptor;
-
- Result result= session.getTestResult(true);
+
+ Result result = session.getTestResult(true);
if (result == Result.OK)
return fSuiteOkIconDescriptor;
else if (result == Result.ERROR)
@@ -373,19 +406,27 @@
}
public String getText(Object element) {
- TestRunSession session= (TestRunSession) element;
+ TestRunSession session = (TestRunSession) element;
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 });
}
}
-
+
public void addMenuEntries(MenuManager manager) {
- manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new ImportTestRunSessionAction(fParent.getShell()));
+ manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS,
+ new ImportTestRunSessionAction(fParent.getShell()));
if (fTestRunSession != null)
- manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new ExportTestRunSessionAction(fParent.getShell(), fTestRunSession));
+ manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS,
+ new ExportTestRunSessionAction(fParent.getShell(),
+ fTestRunSession));
}
public String getMaxEntriesMessage() {
@@ -393,138 +434,163 @@
}
public int getMaxEntries() {
- IPreferenceStore store= DLTKTestingPlugin.getDefault().getPreferenceStore();
+ IPreferenceStore store = DLTKTestingPlugin.getDefault()
+ .getPreferenceStore();
return store.getInt(DLTKTestingPreferencesConstants.MAX_TEST_RUNS);
}
public void setMaxEntries(int maxEntries) {
- IPreferenceStore store= DLTKTestingPlugin.getDefault().getPreferenceStore();
- store.setValue(DLTKTestingPreferencesConstants.MAX_TEST_RUNS, maxEntries);
+ IPreferenceStore store = DLTKTestingPlugin.getDefault()
+ .getPreferenceStore();
+ store.setValue(DLTKTestingPreferencesConstants.MAX_TEST_RUNS,
+ maxEntries);
}
}
-
+
private static class ImportTestRunSessionAction extends Action {
private final Shell fShell;
public ImportTestRunSessionAction(Shell shell) {
- super(DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_name);
- fShell= shell;
+ super(
+ DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_name);
+ fShell = shell;
}
-
+
public void run() {
- FileDialog importDialog= new FileDialog(fShell, SWT.OPEN);
- importDialog.setText(DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_title);
- importDialog.setFilterExtensions(new String[] {"*.xml", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- String path= importDialog.open();
+ FileDialog importDialog = new FileDialog(fShell, SWT.OPEN);
+ importDialog
+ .setText(DLTKTestingMessages.TestRunnerViewPart_ImportTestRunSessionAction_title);
+ importDialog.setFilterExtensions(new String[] { "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
+ String path = importDialog.open();
if (path == null)
return;
-
- //TODO: MULTI: getFileNames()
- File file= new File(path);
-
+
+ // TODO: MULTI: getFileNames()
+ File file = new File(path);
+
try {
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());
}
}
}
-
+
private static class ExportTestRunSessionAction extends Action {
private final TestRunSession fTestRunSession;
private final Shell fShell;
- public ExportTestRunSessionAction(Shell shell, TestRunSession testRunSession) {
- super(DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_name);
- fShell= shell;
- fTestRunSession= testRunSession;
+ public ExportTestRunSessionAction(Shell shell,
+ TestRunSession testRunSession) {
+ super(
+ DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_name);
+ fShell = shell;
+ fTestRunSession = testRunSession;
}
-
+
public void run() {
- FileDialog exportDialog= new FileDialog(fShell, SWT.SAVE);
- exportDialog.setText(DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_title);
+ FileDialog exportDialog = new FileDialog(fShell, SWT.SAVE);
+ exportDialog
+ .setText(DLTKTestingMessages.TestRunnerViewPart_ExportTestRunSessionAction_title);
exportDialog.setFileName(getFileName());
- exportDialog.setFilterExtensions(new String[] {"*.xml", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
- String path= exportDialog.open();
+ exportDialog.setFilterExtensions(new String[] { "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
+ String path = exportDialog.open();
if (path == null)
return;
-
- //TODO: MULTI: getFileNames()
- File file= new File(path);
-
+
+ // TODO: MULTI: getFileNames()
+ File file = new File(path);
+
try {
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());
}
}
private String getFileName() {
- String testRunName= fTestRunSession.getTestRunName();
- long startTime= fTestRunSession.getStartTime();
+ String testRunName = fTestRunSession.getTestRunName();
+ long startTime = fTestRunSession.getStartTime();
if (startTime == 0)
return testRunName;
-
- String isoTime= new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date(startTime)); //$NON-NLS-1$
+
+ String isoTime = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date(startTime)); //$NON-NLS-1$
return testRunName + " " + isoTime + ".xml"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
private class TestRunSessionListener implements ITestRunSessionListener {
public void sessionAdded(TestRunSession testRunSession) {
- if (getSite().getWorkbenchWindow() == DLTKTestingPlugin.getActiveWorkbenchWindow()) {
- TestRunSession deactivatedSession= setActiveTestRunSession(testRunSession);
+ if (getSite().getWorkbenchWindow() == DLTKTestingPlugin
+ .getActiveWorkbenchWindow()) {
+ TestRunSession deactivatedSession = setActiveTestRunSession(testRunSession);
if (deactivatedSession != null)
deactivatedSession.swapOut();
- String testRunName= fTestRunSession.getTestRunName();
+ String testRunName = fTestRunSession.getTestRunName();
String msg;
if (testRunSession.getLaunch() != null) {
- msg= Messages.format(DLTKTestingMessages.TestRunnerViewPart_Launching, new Object[]{ testRunName });
+ msg = Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_Launching,
+ new Object[] { testRunName });
} else {
- msg= testRunName;
+ msg = testRunName;
}
setContentDescription(msg);
}
}
+
public void sessionRemoved(TestRunSession testRunSession) {
if (testRunSession.equals(fTestRunSession)) {
- List testRunSessions= DLTKTestingPlugin.getModel().getTestRunSessions();
+ List testRunSessions = DLTKTestingPlugin.getModel()
+ .getTestRunSessions();
TestRunSession deactivatedSession;
- if (! testRunSessions.isEmpty()) {
- deactivatedSession= setActiveTestRunSession((TestRunSession) testRunSessions.get(0));
+ if (!testRunSessions.isEmpty()) {
+ deactivatedSession = setActiveTestRunSession((TestRunSession) testRunSessions
+ .get(0));
} else {
- deactivatedSession= setActiveTestRunSession(null);
+ deactivatedSession = setActiveTestRunSession(null);
}
if (deactivatedSession != null)
deactivatedSession.swapOut();
}
}
}
-
+
private class TestSessionListener implements ITestSessionListener {
- public void sessionStarted(){
+ public void sessionStarted() {
fTestViewer.registerViewersRefresh();
- fShowOnErrorOnly= getShowOnErrorOnly();
-
+ fShowOnErrorOnly = getShowOnErrorOnly();
+
startUpdateJobs();
-
+
fStopAction.setEnabled(true);
fRerunLastTestAction.setEnabled(true);
}
- public void sessionEnded(long elapsedTime){
+ public void sessionEnded(long elapsedTime) {
fTestViewer.registerAutoScrollTarget(null);
-
- String[] keys= {elapsedTimeAsString(elapsedTime)};
- String msg= Messages.format(DLTKTestingMessages.TestRunnerViewPart_message_finish, keys);
+
+ String[] keys = { elapsedTimeAsString(elapsedTime) };
+ String msg = Messages
+ .format(
+ DLTKTestingMessages.TestRunnerViewPart_message_finish,
+ keys);
registerInfoMessage(msg);
-
- postSyncRunnable(new Runnable() {
+
+ postSyncRunnable(new Runnable() {
public void run() {
- if (isDisposed())
- return;
+ if (isDisposed())
+ return;
fStopAction.setEnabled(lastLaunchIsKeptAlive());
updateRerunFailedFirstAction();
processChangesInUI();
@@ -532,12 +598,12 @@
selectFirstFailure();
}
if (fDirtyListener == null) {
- fDirtyListener= new DirtyListener();
+ fDirtyListener = new DirtyListener();
DLTKCore.addElementChangedListener(fDirtyListener);
}
warnOfContentChange();
}
- });
+ });
stopUpdateJobs();
}
@@ -552,11 +618,11 @@
fTestViewer.registerAutoScrollTarget(null);
registerInfoMessage(DLTKTestingMessages.TestRunnerViewPart_message_terminated);
- handleStopped();
+ handleStopped();
}
-
+
public void runningBegins() {
- if (!fShowOnErrorOnly)
+ if (!fShowOnErrorOnly)
postShowTestResultsView();
}
@@ -564,58 +630,67 @@
fTestViewer.registerAutoScrollTarget(testCaseElement);
fTestViewer.registerViewerUpdate(testCaseElement);
- String className= testCaseElement.getClassName();
- String method= testCaseElement.getTestMethodName();
- String status= Messages.format(DLTKTestingMessages.TestRunnerViewPart_message_started, new String[] { className, method });
- registerInfoMessage(status);
+ String className = testCaseElement.getClassName();
+ String method = testCaseElement.getTestMethodName();
+ String status = Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_message_started,
+ new String[] { className, method });
+ registerInfoMessage(status);
}
- public void testFailed(TestElement testElement, TestElement.Status status, String trace, String expected, String actual, int code) {
+ public void testFailed(TestElement testElement,
+ TestElement.Status status, String trace, String expected,
+ String actual, int code) {
if (isAutoScroll()) {
fTestViewer.registerFailedForAutoScroll(testElement);
}
fTestViewer.registerViewerUpdate(testElement);
- // show the view on the first error only
- if (fShowOnErrorOnly && (getErrorsPlusFailures() == 1))
- postShowTestResultsView();
-
- //TODO:
- // [Bug 35590] JUnit window doesn't report errors from junit.extensions.TestSetup [JUnit]
- // when a failure occurs in test setup then no test is running
- // to update the views we artificially signal the end of a test run
-// if (!fTestIsRunning) {
-// fTestIsRunning= false;
-// testEnded(testCaseElement);
-// }
+ // show the view on the first error only
+ if (fShowOnErrorOnly && (getErrorsPlusFailures() == 1))
+ postShowTestResultsView();
+
+ // TODO:
+ // [Bug 35590] JUnit window doesn't report errors from
+ // junit.extensions.TestSetup [JUnit]
+ // when a failure occurs in test setup then no test is running
+ // to update the views we artificially signal the end of a test run
+ // if (!fTestIsRunning) {
+ // fTestIsRunning= false;
+ // testEnded(testCaseElement);
+ // }
}
-
- public void testEnded(TestCaseElement testCaseElement){
+
+ public void testEnded(TestCaseElement testCaseElement) {
fTestViewer.registerViewerUpdate(testCaseElement);
}
- public void testReran(TestCaseElement testCaseElement, TestElement.Status status, String trace, String expectedResult, String actualResult) {
- fTestViewer.registerViewerUpdate(testCaseElement); //TODO: autoExpand?
+ public void testReran(TestCaseElement testCaseElement,
+ TestElement.Status status, String trace, String expectedResult,
+ String actualResult) {
+ fTestViewer.registerViewerUpdate(testCaseElement); // TODO:
+ // autoExpand?
postSyncProcessChanges();
showFailure(testCaseElement);
}
-
+
public void testAdded(TestElement testElement) {
fTestViewer.registerTestAdded(testElement);
}
-
+
public boolean acceptsSwapToDisk() {
return false;
}
}
-
+
private class UpdateUIJob extends UIJob {
- private boolean fRunning= true;
-
+ private boolean fRunning = true;
+
public UpdateUIJob(String name) {
super(name);
setSystem(true);
}
+
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!isDisposed()) {
processChangesInUI();
@@ -623,10 +698,11 @@
schedule(REFRESH_INTERVAL);
return Status.OK_STATUS;
}
-
+
public void stop() {
- fRunning= false;
+ fRunning = false;
}
+
public boolean shouldSchedule() {
return fRunning;
}
@@ -637,11 +713,13 @@
super(name);
setSystem(true);
}
+
public IStatus run(IProgressMonitor monitor) {
// wait until the test run terminates
fJUnitIsRunningLock.acquire();
return Status.OK_STATUS;
}
+
public boolean belongsTo(Object family) {
return family == TestRunnerViewPart.FAMILY_JUNIT_RUN;
}
@@ -650,30 +728,33 @@
private class ClearAction extends Action {
public ClearAction() {
setText(DLTKTestingMessages.TestRunnerViewPart_clear_history_label);
-
- boolean enabled= false;
- List testRunSessions= DLTKTestingPlugin.getModel().getTestRunSessions();
- for (Iterator iter= testRunSessions.iterator(); iter.hasNext();) {
- ITestSession testRunSession= (ITestSession) iter.next();
- if (! testRunSession.isRunning() && ! testRunSession.isStarting()) {
- enabled= true;
+
+ boolean enabled = false;
+ List testRunSessions = DLTKTestingPlugin.getModel()
+ .getTestRunSessions();
+ for (Iterator iter = testRunSessions.iterator(); iter.hasNext();) {
+ ITestSession testRunSession = (ITestSession) iter.next();
+ if (!testRunSession.isRunning() && !testRunSession.isStarting()) {
+ enabled = true;
break;
}
}
setEnabled(enabled);
}
-
+
public void run() {
- List testRunSessions= getRunningSessions();
- Object first= testRunSessions.isEmpty() ? null : testRunSessions.get(0);
+ List testRunSessions = getRunningSessions();
+ Object first = testRunSessions.isEmpty() ? null : testRunSessions
+ .get(0);
fViewHistory.setHistoryEntries(testRunSessions, first);
}
private List getRunningSessions() {
- List testRunSessions= DLTKTestingPlugin.getModel().getTestRunSessions();
- for (Iterator iter= testRunSessions.iterator(); iter.hasNext();) {
- ITestSession testRunSession= (ITestSession) iter.next();
- if (! testRunSession.isRunning() && ! testRunSession.isStarting()) {
+ List testRunSessions = DLTKTestingPlugin.getModel()
+ .getTestRunSessions();
+ for (Iterator iter = testRunSessions.iterator(); iter.hasNext();) {
+ ITestSession testRunSession = (ITestSession) iter.next();
+ if (!testRunSession.isRunning() && !testRunSession.isStarting()) {
iter.remove();
}
}
@@ -696,14 +777,14 @@
private class RerunLastAction extends Action {
public RerunLastAction() {
- setText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_label);
- setToolTipText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_tooltip);
+ setText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_label);
+ setToolTipText(DLTKTestingMessages.TestRunnerViewPart_rerunaction_tooltip);
DLTKTestingPlugin.setLocalImageDescriptors(this, "relaunch.gif"); //$NON-NLS-1$
setEnabled(false);
setActionDefinitionId(RERUN_LAST_COMMAND);
}
-
- public void run(){
+
+ public void run() {
rerunTestRun();
}
}
@@ -725,33 +806,41 @@
private class ToggleOrientationAction extends Action {
private final int fActionOrientation;
-
+
public ToggleOrientationAction(int orientation) {
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
if (orientation == TestRunnerViewPart.VIEW_ORIENTATION_HORIZONTAL) {
- setText(DLTKTestingMessages.TestRunnerViewPart_toggle_horizontal_label);
- setImageDescriptor(DLTKTestingPlugin.getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
+ setText(DLTKTestingMessages.TestRunnerViewPart_toggle_horizontal_label);
+ setImageDescriptor(DLTKTestingPlugin
+ .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$
+ setText(DLTKTestingMessages.TestRunnerViewPart_toggle_vertical_label);
+ setImageDescriptor(DLTKTestingPlugin
+ .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$
+ setText(DLTKTestingMessages.TestRunnerViewPart_toggle_automatic_label);
+ setImageDescriptor(DLTKTestingPlugin
+ .getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
}
- fActionOrientation= orientation;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDLTKTestingHelpContextIds.RESULTS_VIEW_TOGGLE_ORIENTATION_ACTION);
+ fActionOrientation = orientation;
+ PlatformUI
+ .getWorkbench()
+ .getHelpSystem()
+ .setHelp(
+ this,
+ IDLTKTestingHelpContextIds.RESULTS_VIEW_TOGGLE_ORIENTATION_ACTION);
}
-
+
public int getOrientation() {
return fActionOrientation;
}
-
+
public void run() {
if (isChecked()) {
- fOrientation= fActionOrientation;
+ fOrientation = fActionOrientation;
computeOrientation();
}
- }
+ }
}
/**
@@ -759,55 +848,60 @@
*/
private class DirtyListener implements IElementChangedListener {
public void elementChanged(ElementChangedEvent event) {
- processDelta(event.getDelta());
+ processDelta(event.getDelta());
}
-
+
private boolean processDelta(IModelElementDelta delta) {
- int kind= delta.getKind();
- int details= delta.getFlags();
- int type= delta.getElement().getElementType();
-
+ int kind = delta.getKind();
+ int details = delta.getFlags();
+ int type = delta.getElement().getElementType();
+
switch (type) {
- // Consider containers for class files.
- case IModelElement.SCRIPT_MODEL:
- case IModelElement.SCRIPT_PROJECT:
- case IModelElement.PROJECT_FRAGMENT:
- case IModelElement.SCRIPT_FOLDER:
- // If we did something different than changing a child we flush the undo / redo stack.
- if (kind != IModelElementDelta.CHANGED || details != IModelElementDelta.F_CHILDREN) {
- codeHasChanged();
- return false;
- }
- break;
- case IModelElement.SOURCE_MODULE:
- // if we have changed a primary working copy (e.g created, removed, ...)
- // then we do nothing.
- if ((details & IModelElementDelta.F_PRIMARY_WORKING_COPY) != 0)
- return true;
+ // Consider containers for class files.
+ case IModelElement.SCRIPT_MODEL:
+ case IModelElement.SCRIPT_PROJECT:
+ case IModelElement.PROJECT_FRAGMENT:
+ case IModelElement.SCRIPT_FOLDER:
+ // If we did something different than changing a child we flush
+ // the undo / redo stack.
+ if (kind != IModelElementDelta.CHANGED
+ || details != IModelElementDelta.F_CHILDREN) {
codeHasChanged();
return false;
- default:
- codeHasChanged();
- return false;
+ }
+ break;
+ case IModelElement.SOURCE_MODULE:
+ // if we have changed a primary working copy (e.g created,
+ // removed, ...)
+ // then we do nothing.
+ if ((details & IModelElementDelta.F_PRIMARY_WORKING_COPY) != 0)
+ return true;
+ codeHasChanged();
+ return false;
+ default:
+ codeHasChanged();
+ return false;
}
-
- IModelElementDelta[] affectedChildren= delta.getAffectedChildren();
+
+ IModelElementDelta[] affectedChildren = delta.getAffectedChildren();
if (affectedChildren == null)
return true;
-
- for (int i= 0; i < affectedChildren.length; i++) {
+
+ for (int i = 0; i < affectedChildren.length; i++) {
if (!processDelta(affectedChildren[i]))
return false;
}
- return true;
+ return true;
}
}
-
+
private class FailuresOnlyFilterAction extends Action {
public FailuresOnlyFilterAction() {
- super(DLTKTestingMessages.TestRunnerViewPart_show_failures_only, AS_CHECK_BOX);
+ super(DLTKTestingMessages.TestRunnerViewPart_show_failures_only,
+ AS_CHECK_BOX);
setToolTipText(DLTKTestingMessages.TestRunnerViewPart_show_failures_only);
- setImageDescriptor(DLTKTestingPlugin.getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
+ setImageDescriptor(DLTKTestingPlugin
+ .getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
}
public void run() {
@@ -818,104 +912,117 @@
private class ShowTestHierarchyAction extends Action {
public ShowTestHierarchyAction() {
- super(DLTKTestingMessages.TestRunnerViewPart_hierarchical_layout, IAction.AS_CHECK_BOX);
- setImageDescriptor(DLTKTestingPlugin.getImageDescriptor("elcl16/hierarchicalLayout.gif")); //$NON-NLS-1$
+ super(DLTKTestingMessages.TestRunnerViewPart_hierarchical_layout,
+ IAction.AS_CHECK_BOX);
+ setImageDescriptor(DLTKTestingPlugin
+ .getImageDescriptor("elcl16/hierarchicalLayout.gif")); //$NON-NLS-1$
}
-
+
public void run() {
- int mode= isChecked() ? LAYOUT_HIERARCHICAL : LAYOUT_FLAT;
+ int mode = isChecked() ? LAYOUT_HIERARCHICAL : LAYOUT_FLAT;
setLayoutMode(mode);
}
}
-
+
private class ActivateOnErrorAction extends Action {
public ActivateOnErrorAction() {
- super(DLTKTestingMessages.TestRunnerViewPart_activate_on_failure_only, IAction.AS_CHECK_BOX);
+ super(
+ DLTKTestingMessages.TestRunnerViewPart_activate_on_failure_only,
+ IAction.AS_CHECK_BOX);
//setImageDescriptor(JUnitPlugin.getImageDescriptor("obj16/failures.gif")); //$NON-NLS-1$
update();
}
+
public void update() {
setChecked(getShowOnErrorOnly());
}
+
public void run() {
- boolean checked= isChecked();
- fShowOnErrorOnly= checked;
- IPreferenceStore store= DLTKTestingPlugin.getDefault().getPreferenceStore();
- store.setValue(DLTKTestingPreferencesConstants.SHOW_ON_ERROR_ONLY, checked);
+ boolean checked = isChecked();
+ fShowOnErrorOnly = checked;
+ IPreferenceStore store = DLTKTestingPlugin.getDefault()
+ .getPreferenceStore();
+ store.setValue(DLTKTestingPreferencesConstants.SHOW_ON_ERROR_ONLY,
+ checked);
}
}
-
+
public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
- fMemento= memento;
- IWorkbenchSiteProgressService progressService= getProgressService();
+ fMemento = memento;
+ IWorkbenchSiteProgressService progressService = getProgressService();
if (progressService != null)
- progressService.showBusyForFamily(TestRunnerViewPart.FAMILY_JUNIT_RUN);
+ progressService
+ .showBusyForFamily(TestRunnerViewPart.FAMILY_JUNIT_RUN);
}
-
+
private IWorkbenchSiteProgressService getProgressService() {
- Object siteService= getSite().getAdapter(IWorkbenchSiteProgressService.class);
+ Object siteService = getSite().getAdapter(
+ IWorkbenchSiteProgressService.class);
if (siteService != null)
return (IWorkbenchSiteProgressService) siteService;
return null;
}
-
public void saveState(IMemento memento) {
if (fSashForm == null) {
// part has not been created
- if (fMemento != null) //Keep the old state;
+ if (fMemento != null) // Keep the old state;
memento.putMemento(fMemento);
return;
}
-
-// int activePage= fTabFolder.getSelectionIndex();
-// memento.putInteger(TAG_PAGE, activePage);
- memento.putString(TAG_SCROLL, fScrollLockAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- int weigths[]= fSashForm.getWeights();
- int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
+
+ // int activePage= fTabFolder.getSelectionIndex();
+ // memento.putInteger(TAG_PAGE, activePage);
+ memento.putString(TAG_SCROLL,
+ fScrollLockAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ int weigths[] = fSashForm.getWeights();
+ int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]);
memento.putInteger(TAG_RATIO, ratio);
memento.putInteger(TAG_ORIENTATION, fOrientation);
-
- 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);
}
-
+
private void restoreLayoutState(IMemento memento) {
-// Integer page= memento.getInteger(TAG_PAGE);
-// if (page != null) {
-// int p= page.intValue();
-// if (p < fTestRunTabs.size()) { // tab count can decrease if a contributing plug-in is removed
-// fTabFolder.setSelection(p);
-// fActiveRunTab= (TestRunTab)fTestRunTabs.get(p);
-// }
-// }
- Integer ratio= memento.getInteger(TAG_RATIO);
- if (ratio != null)
- fSashForm.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue()} );
- Integer orientation= memento.getInteger(TAG_ORIENTATION);
+ // Integer page= memento.getInteger(TAG_PAGE);
+ // if (page != null) {
+ // int p= page.intValue();
+ // if (p < fTestRunTabs.size()) { // tab count can decrease if a
+ // contributing plug-in is removed
+ // fTabFolder.setSelection(p);
+ // fActiveRunTab= (TestRunTab)fTestRunTabs.get(p);
+ // }
+ // }
+ Integer ratio = memento.getInteger(TAG_RATIO);
+ if (ratio != null)
+ fSashForm.setWeights(new int[] { ratio.intValue(),
+ 1000 - ratio.intValue() });
+ Integer orientation = memento.getInteger(TAG_ORIENTATION);
if (orientation != null)
- fOrientation= orientation.intValue();
+ fOrientation = orientation.intValue();
computeOrientation();
- String scrollLock= memento.getString(TAG_SCROLL);
+ String scrollLock = memento.getString(TAG_SCROLL);
if (scrollLock != null) {
fScrollLockAction.setChecked(scrollLock.equals("true")); //$NON-NLS-1$
setAutoScroll(!fScrollLockAction.isChecked());
}
-
- Integer layout= memento.getInteger(TAG_LAYOUT);
- int layoutValue= LAYOUT_HIERARCHICAL;
+
+ Integer layout = memento.getInteger(TAG_LAYOUT);
+ int layoutValue = LAYOUT_HIERARCHICAL;
if (layout != null)
- layoutValue= layout.intValue();
-
- String failuresOnly= memento.getString(TAG_FAILURES_ONLY);
- boolean showFailuresOnly= false;
+ layoutValue = layout.intValue();
+
+ String failuresOnly = memento.getString(TAG_FAILURES_ONLY);
+ boolean showFailuresOnly = false;
if (failuresOnly != null)
- showFailuresOnly= failuresOnly.equals("true"); //$NON-NLS-1$
-
+ showFailuresOnly = failuresOnly.equals("true"); //$NON-NLS-1$
+
setFilterAndLayout(showFailuresOnly, layoutValue);
}
-
+
/**
* Stops the currently running test and shuts down the RemoteTestRunner
*/
@@ -930,83 +1037,93 @@
private void startUpdateJobs() {
postSyncProcessChanges();
-
+
if (fUpdateJob != null) {
return;
}
- fJUnitIsRunningJob= new JUnitIsRunningJob(DLTKTestingMessages.TestRunnerViewPart_wrapperJobName);
- fJUnitIsRunningLock= Job.getJobManager().newLock();
+ fJUnitIsRunningJob = new JUnitIsRunningJob(
+ DLTKTestingMessages.TestRunnerViewPart_wrapperJobName);
+ fJUnitIsRunningLock = Job.getJobManager().newLock();
// acquire lock while a test run is running
// the lock is released when the test run terminates
// the wrapper job will wait on this lock.
fJUnitIsRunningLock.acquire();
getProgressService().schedule(fJUnitIsRunningJob);
-
- fUpdateJob= new UpdateUIJob(DLTKTestingMessages.TestRunnerViewPart_jobName);
+
+ fUpdateJob = new UpdateUIJob(
+ DLTKTestingMessages.TestRunnerViewPart_jobName);
fUpdateJob.schedule(REFRESH_INTERVAL);
}
-
+
private void stopUpdateJobs() {
if (fUpdateJob != null) {
fUpdateJob.stop();
- fUpdateJob= null;
+ fUpdateJob = null;
}
if (fJUnitIsRunningJob != null && fJUnitIsRunningLock != null) {
fJUnitIsRunningLock.release();
- fJUnitIsRunningJob= null;
+ fJUnitIsRunningJob = null;
}
postSyncProcessChanges();
}
-
+
private void processChangesInUI() {
if (fSashForm.isDisposed())
return;
-
+
doShowInfoMessage();
refreshCounters();
-
- if (! fPartIsVisible)
+
+ if (!fPartIsVisible)
updateViewTitleProgress();
else {
updateViewIcon();
}
- boolean hasErrorsOrFailures= hasErrorsOrFailures();
+ boolean hasErrorsOrFailures = hasErrorsOrFailures();
fNextAction.setEnabled(hasErrorsOrFailures);
fPreviousAction.setEnabled(hasErrorsOrFailures);
-
+
fTestViewer.processChangesInUI();
}
-
+
/**
* Stops the currently running test and shuts down the RemoteTestRunner
*/
public void rerunTestRun() {
if (lastLaunchIsKeptAlive()) {
// prompt for terminating the existing run
- if (MessageDialog.openQuestion(getSite().getShell(), DLTKTestingMessages.TestRunnerViewPart_terminate_title, DLTKTestingMessages.TestRunnerViewPart_terminate_message)) {
+ if (MessageDialog.openQuestion(getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_terminate_title,
+ DLTKTestingMessages.TestRunnerViewPart_terminate_message)) {
stopTest(); // TODO: wait for termination
}
}
-
+
if (fTestRunSession == null)
return;
- ILaunch launch= fTestRunSession.getLaunch();
+ ILaunch launch = fTestRunSession.getLaunch();
if (launch == null)
return;
- ILaunchConfiguration launchConfiguration= launch.getLaunchConfiguration();
+ ILaunchConfiguration launchConfiguration = launch
+ .getLaunchConfiguration();
if (launchConfiguration == null)
return;
-
- ILaunchConfiguration configuration= prepareLaunchConfigForRelaunch(launchConfiguration);
+
+ ILaunchConfiguration configuration = prepareLaunchConfigForRelaunch(launchConfiguration);
relaunch(configuration, launch.getLaunchMode());
}
- private ILaunchConfiguration prepareLaunchConfigForRelaunch(ILaunchConfiguration configuration) {
+ 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, configuration.getName());
- ILaunchConfigurationWorkingCopy tmp= configuration.copy(configName);
+ String configName = Messages.format(
+ DLTKTestingMessages.TestRunnerViewPart_configName,
+ configuration.getName());
+ ILaunchConfigurationWorkingCopy tmp = configuration
+ .copy(configName);
tmp.setAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES, ""); //$NON-NLS-1$
return tmp;
}
@@ -1019,40 +1136,54 @@
public void rerunTestFailedFirst() {
if (lastLaunchIsKeptAlive()) {
// prompt for terminating the existing run
- if (MessageDialog.openQuestion(getSite().getShell(), DLTKTestingMessages.TestRunnerViewPart_terminate_title, DLTKTestingMessages.TestRunnerViewPart_terminate_message)) {
+ if (MessageDialog.openQuestion(getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_terminate_title,
+ DLTKTestingMessages.TestRunnerViewPart_terminate_message)) {
if (fTestRunSession != null)
fTestRunSession.stopTestRun();
}
}
- ILaunch launch= fTestRunSession.getLaunch();
+ ILaunch launch = fTestRunSession.getLaunch();
if (launch != null && launch.getLaunchConfiguration() != null) {
- ILaunchConfiguration launchConfiguration= launch.getLaunchConfiguration();
- if (launchConfiguration != null) {
- try {
- String oldName= launchConfiguration.getName();
- String oldFailuresFilename= launchConfiguration.getAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES, (String) null);
- String configName;
- if (oldFailuresFilename != null) {
- configName= oldName;
- } else {
- configName= Messages.format(DLTKTestingMessages.TestRunnerViewPart_rerunFailedFirstLaunchConfigName, oldName);
- }
- ILaunchConfigurationWorkingCopy tmp= launchConfiguration.copy(configName);
- tmp.setAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES, createFailureNamesFile());
- relaunch(tmp, launch.getLaunchMode());
- return;
- } catch (CoreException e) {
- ErrorDialog.openError(getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_error_cannotrerun, e.getMessage(), e.getStatus()
- );
+ ILaunchConfiguration launchConfiguration = launch
+ .getLaunchConfiguration();
+ if (launchConfiguration != null) {
+ try {
+ String oldName = launchConfiguration.getName();
+ String oldFailuresFilename = launchConfiguration
+ .getAttribute(
+ DLTKTestingConstants.ATTR_FAILURES_NAMES,
+ (String) null);
+ String configName;
+ if (oldFailuresFilename != null) {
+ configName = oldName;
+ } else {
+ configName = Messages
+ .format(
+ DLTKTestingMessages.TestRunnerViewPart_rerunFailedFirstLaunchConfigName,
+ oldName);
}
+ ILaunchConfigurationWorkingCopy tmp = launchConfiguration
+ .copy(configName);
+ tmp.setAttribute(DLTKTestingConstants.ATTR_FAILURES_NAMES,
+ createFailureNamesFile());
+ relaunch(tmp, launch.getLaunchMode());
+ return;
+ } catch (CoreException e) {
+ 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) {
DebugUITools.launch(configuration, launchMode);
@@ -1060,14 +1191,14 @@
private String createFailureNamesFile() throws CoreException {
try {
- File file= File.createTempFile("testFailures", ".txt"); //$NON-NLS-1$ //$NON-NLS-2$
+ File file = File.createTempFile("testFailures", ".txt"); //$NON-NLS-1$ //$NON-NLS-2$
file.deleteOnExit();
- TestElement[] failures= fTestRunSession.getAllFailedTestElements();
- BufferedWriter bw= null;
+ TestElement[] failures = fTestRunSession.getAllFailedTestElements();
+ BufferedWriter bw = null;
try {
- bw= new BufferedWriter(new FileWriter(file));
- for (int i= 0; i < failures.length; i++) {
- TestElement testElement= failures[i];
+ bw = new BufferedWriter(new FileWriter(file));
+ for (int i = 0; i < failures.length; i++) {
+ TestElement testElement = failures[i];
bw.write(testElement.getTestName());
bw.newLine();
}
@@ -1078,22 +1209,23 @@
}
return file.getAbsolutePath();
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, DLTKTestingPlugin.PLUGIN_ID, IStatus.ERROR, "", e)); //$NON-NLS-1$
+ throw new CoreException(new Status(IStatus.ERROR,
+ DLTKTestingPlugin.PLUGIN_ID, IStatus.ERROR, "", e)); //$NON-NLS-1$
}
}
public void setAutoScroll(boolean scroll) {
fAutoScroll = scroll;
}
-
+
public boolean isAutoScroll() {
return fAutoScroll;
- }
-
+ }
+
public void selectNextFailure() {
fTestViewer.selectFailure(true);
}
-
+
public void selectPreviousFailure() {
fTestViewer.selectFailure(false);
}
@@ -1110,51 +1242,53 @@
if (fTestRunSession == null)
return 0;
else
- return fTestRunSession.getErrorCount() + fTestRunSession.getFailureCount();
+ return fTestRunSession.getErrorCount()
+ + fTestRunSession.getFailureCount();
}
-
+
private String elapsedTimeAsString(long runTime) {
- return NumberFormat.getInstance().format((double)runTime/1000);
+ return NumberFormat.getInstance().format((double) runTime / 1000);
}
private void handleStopped() {
- postSyncRunnable(new Runnable() {
+ postSyncRunnable(new Runnable() {
public void run() {
- if (isDisposed())
- return;
+ if (isDisposed())
+ return;
resetViewIcon();
fStopAction.setEnabled(false);
updateRerunFailedFirstAction();
}
- });
+ });
stopUpdateJobs();
}
private void resetViewIcon() {
- fViewImage= fOriginalViewImage;
+ fViewImage = fOriginalViewImage;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
private void updateViewIcon() {
-// if (fTestRunSession == null || fTestRunSession.isStopped() || fTestRunSession.isRunning() || fTestRunSession.getStartedCount() == 0)
-// fViewImage= fOriginalViewImage;
-// else if (hasErrorsOrFailures())
-// fViewImage= fTestRunFailIcon;
-// else
-// fViewImage= fTestRunOKIcon;
- firePropertyChange(IWorkbenchPart.PROP_TITLE);
+ // if (fTestRunSession == null || fTestRunSession.isStopped() ||
+ // fTestRunSession.isRunning() || fTestRunSession.getStartedCount() ==
+ // 0)
+ // fViewImage= fOriginalViewImage;
+ // else if (hasErrorsOrFailures())
+ // fViewImage= fTestRunFailIcon;
+ // else
+ // fViewImage= fTestRunOKIcon;
+ firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
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;
+ fViewImage = progress;
firePropertyChange(IWorkbenchPart.PROP_TITLE);
}
} else {
@@ -1164,81 +1298,75 @@
resetViewIcon();
}
}
-
+
/**
- * @param testRunSession new active test run session
- * @return deactivated session, or <code>null</code> iff no session got deactivated
+ * @param testRunSession
+ * new active test run session
+ * @return deactivated session, or <code>null</code> iff no session got
+ * deactivated
*/
private TestRunSession setActiveTestRunSession(TestRunSession testRunSession) {
-/*
-- State:
-fTestRunSession
-fTestSessionListener
-Jobs
-fTestViewer.processChangesInUI();
-- UI:
-fCounterPanel
-fProgressBar
-setContentDescription / fInfoMessage
-setTitleToolTip
-view icons
-statusLine
-fFailureTrace
-
-action enablement
- */
+ /*
+ * - State: fTestRunSession fTestSessionListener Jobs
+ * fTestViewer.processChangesInUI(); - UI: fCounterPanel fProgressBar
+ * setContentDescription / fInfoMessage setTitleToolTip view icons
+ * statusLine fFailureTrace
+ *
+ * action enablement
+ */
if (fTestRunSession == testRunSession)
return null;
-
+
if (fTestRunSession != null && fTestSessionListener != null) {
fTestRunSession.removeTestSessionListener(fTestSessionListener);
- fTestSessionListener= null;
+ fTestSessionListener = null;
}
-
- TestRunSession deactivatedSession= fTestRunSession;
-
- fTestRunSession= testRunSession;
+
+ TestRunSession deactivatedSession = fTestRunSession;
+
+ fTestRunSession = testRunSession;
fTestViewer.registerActiveSession(testRunSession);
-
+
if (fSashForm.isDisposed()) {
stopUpdateJobs();
return deactivatedSession;
}
-
+
if (testRunSession == null) {
setTitleToolTip(null);
resetViewIcon();
clearStatus();
fFailureTrace.clear();
-
+
registerInfoMessage(" "); //$NON-NLS-1$
stopUpdateJobs();
-
+
fStopAction.setEnabled(false);
-// fRerunFailedFirstAction.setEnabled(false);
+ // fRerunFailedFirstAction.setEnabled(false);
fRerunLastTestAction.setEnabled(false);
-
+
} else {
- fTestSessionListener= new TestSessionListener();
+ fTestSessionListener = new TestSessionListener();
fTestRunSession.addTestSessionListener(fTestSessionListener);
-
+
setTitleToolTip();
-
+
clearStatus();
fFailureTrace.clear();
registerInfoMessage(fTestRunSession.getTestRunName());
-
+
updateRerunFailedFirstAction();
- fRerunLastTestAction.setEnabled(fTestRunSession.getLaunch() != null);
-
+ fRerunLastTestAction
+ .setEnabled(fTestRunSession.getLaunch() != null);
+
if (fTestRunSession.isRunning()) {
startUpdateJobs();
-
+
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());
fTestViewer.expandFirstLevel();
}
@@ -1253,37 +1381,44 @@
}
private void setTitleToolTip() {
- String testKindDisplayStr= fTestRunSession.getTestRunnerUI().getDisplayName();
-
+ String testKindDisplayStr = fTestRunSession.getTestRunnerUI()
+ .getDisplayName();
+
if (testKindDisplayStr != null)
- setTitleToolTip(MessageFormat.format(DLTKTestingMessages.TestRunnerViewPart_titleToolTip, new String[] {fTestRunSession.getTestRunName(), testKindDisplayStr}));
+ setTitleToolTip(MessageFormat.format(
+ DLTKTestingMessages.TestRunnerViewPart_titleToolTip,
+ new String[] { fTestRunSession.getTestRunName(),
+ testKindDisplayStr }));
else
setTitleToolTip(fTestRunSession.getTestRunName());
}
-
- public synchronized void dispose(){
- fIsDisposed= true;
+
+ public synchronized void dispose() {
+ fIsDisposed = true;
if (fTestRunSessionListener != null)
- DLTKTestingPlugin.getModel().removeTestRunSessionListener(fTestRunSessionListener);
-
- IHandlerService handlerService= (IHandlerService) getSite().getWorkbenchWindow().getService(IHandlerService.class);
+ DLTKTestingPlugin.getModel().removeTestRunSessionListener(
+ fTestRunSessionListener);
+
+ IHandlerService handlerService = (IHandlerService) getSite()
+ .getWorkbenchWindow().getService(IHandlerService.class);
handlerService.deactivateHandler(fRerunLastActivation);
-// handlerService.deactivateHandler(fRerunFailedFirstActivation);
+ // handlerService.deactivateHandler(fRerunFailedFirstActivation);
setActiveTestRunSession(null);
-
+
if (fProgressImages != null)
fProgressImages.dispose();
getViewSite().getPage().removePartListener(fPartListener);
-
+
disposeImages();
- if (fClipboard != null)
+ if (fClipboard != null)
fClipboard.dispose();
if (fViewMenuListener != null) {
- getViewSite().getActionBars().getMenuManager().removeMenuListener(fViewMenuListener);
+ getViewSite().getActionBars().getMenuManager().removeMenuListener(
+ fViewMenuListener);
}
if (fDirtyListener != null) {
DLTKCore.removeElementChangedListener(fDirtyListener);
- fDirtyListener= null;
+ fDirtyListener = null;
}
}
@@ -1293,14 +1428,14 @@
fStackViewIcon.dispose();
fTestRunOKDirtyIcon.dispose();
fTestRunFailDirtyIcon.dispose();
-
+
fTestIcon.dispose();
fTestRunningIcon.dispose();
fTestOkIcon.dispose();
fTestErrorIcon.dispose();
fTestFailIcon.dispose();
fTestIgnoredIcon.dispose();
-
+
fSuiteIcon.dispose();
fSuiteRunningIcon.dispose();
fSuiteErrorIcon.dispose();
@@ -1313,10 +1448,10 @@
}
private void refreshCounters() {
- // TODO: Inefficient. Either
+ // TODO: Inefficient. Either
// - keep a boolean fHasTestRun and update only on changes, or
// - improve components to only redraw on changes (once!).
-
+
int startedCount;
int ignoredCount;
int totalCount;
@@ -1324,45 +1459,45 @@
int failureCount;
boolean hasErrorsOrFailures;
boolean stopped;
-
+
if (fTestRunSession != null) {
- startedCount= fTestRunSession.getStartedCount();
- ignoredCount= fTestRunSession.getIgnoredCount();
- totalCount= fTestRunSession.getTotalCount();
- errorCount= fTestRunSession.getErrorCount();
- failureCount= fTestRunSession.getFailureCount();
- hasErrorsOrFailures= errorCount + failureCount > 0;
- stopped= fTestRunSession.isStopped();
+ startedCount = fTestRunSession.getStartedCount();
+ ignoredCount = fTestRunSession.getIgnoredCount();
+ totalCount = fTestRunSession.getTotalCount();
+ errorCount = fTestRunSession.getErrorCount();
+ failureCount = fTestRunSession.getFailureCount();
+ hasErrorsOrFailures = errorCount + failureCount > 0;
+ stopped = fTestRunSession.isStopped();
} else {
- startedCount= 0;
- ignoredCount= 0;
- totalCount= 0;
- errorCount= 0;
- failureCount= 0;
- hasErrorsOrFailures= false;
- stopped= false;
+ startedCount = 0;
+ ignoredCount = 0;
+ totalCount = 0;
+ errorCount = 0;
+ failureCount = 0;
+ hasErrorsOrFailures = false;
+ stopped = false;
}
-
+
fCounterPanel.setTotal(totalCount);
fCounterPanel.setRunValue(startedCount, ignoredCount);
fCounterPanel.setErrorValue(errorCount);
fCounterPanel.setFailureValue(failureCount);
-
+
int ticksDone;
if (startedCount == 0)
- ticksDone= 0;
- else if (startedCount == totalCount && ! fTestRunSession.isRunning())
- ticksDone= totalCount;
+ ticksDone = 0;
+ else if (startedCount == totalCount && !fTestRunSession.isRunning())
+ ticksDone = totalCount;
else
- ticksDone= startedCount - 1;
-
+ ticksDone = startedCount - 1;
+
fProgressBar.reset(hasErrorsOrFailures, stopped, ticksDone, totalCount);
}
-
+
protected void postShowTestResultsView() {
postSyncRunnable(new Runnable() {
public void run() {
- if (isDisposed())
+ if (isDisposed())
return;
showTestResultsView();
}
@@ -1370,17 +1505,19 @@
}
public void showTestResultsView() {
- IWorkbenchWindow window= getSite().getWorkbenchWindow();
- IWorkbenchPage page= window.getActivePage();
- TestRunnerViewPart testRunner= null;
-
+ IWorkbenchWindow window = getSite().getWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ TestRunnerViewPart testRunner = null;
+
if (page != null) {
try { // show the result view
- testRunner= (TestRunnerViewPart)page.findView(TestRunnerViewPart.NAME);
- if(testRunner == null) {
- IWorkbenchPart activePart= page.getActivePart();
- testRunner= (TestRunnerViewPart)page.showView(TestRunnerViewPart.NAME);
- //restore focus
+ testRunner = (TestRunnerViewPart) page
+ .findView(TestRunnerViewPart.NAME);
+ if (testRunner == null) {
+ IWorkbenchPart activePart = page.getActivePart();
+ testRunner = (TestRunnerViewPart) page
+ .showView(TestRunnerViewPart.NAME);
+ // restore focus
page.activate(activePart);
} else {
page.bringToTop(testRunner);
@@ -1390,47 +1527,52 @@
}
}
}
-
+
protected void doShowInfoMessage() {
if (fInfoMessage != null) {
setContentDescription(fInfoMessage);
- fInfoMessage= null;
+ fInfoMessage = null;
}
}
protected void registerInfoMessage(String message) {
- fInfoMessage= message;
+ fInfoMessage = message;
}
-
+
private SashForm createSashForm(Composite parent) {
- fSashForm= new SashForm(parent, SWT.VERTICAL);
-
- ViewForm top= new ViewForm(fSashForm, SWT.NONE);
-
- Composite empty= new Composite(top, SWT.NONE);
+ fSashForm = new SashForm(parent, SWT.VERTICAL);
+
+ ViewForm top = new ViewForm(fSashForm, SWT.NONE);
+
+ Composite empty = new Composite(top, SWT.NONE);
empty.setLayout(new Layout() {
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- return new Point(1, 1); // (0, 0) does not work with super-intelligent ViewForm
+ protected Point computeSize(Composite composite, int wHint,
+ int hHint, boolean flushCache) {
+ return new Point(1, 1); // (0, 0) does not work with
+ // super-intelligent ViewForm
}
+
protected void layout(Composite composite, boolean flushCache) {
}
});
- top.setTopLeft(empty); // makes ViewForm draw the horizontal separator line ...
- fTestViewer= new TestViewer(top, fClipboard, this);
+ top.setTopLeft(empty); // makes ViewForm draw the horizontal separator
+ // line ...
+ fTestViewer = new TestViewer(top, fClipboard, this);
top.setContent(fTestViewer.getTestViewerControl());
-
- ViewForm bottom= new ViewForm(fSashForm, SWT.NONE);
-
- CLabel label= new CLabel(bottom, SWT.NONE);
- label.setText(DLTKTestingMessages.TestRunnerViewPart_label_failure);
+
+ ViewForm bottom = new ViewForm(fSashForm, SWT.NONE);
+
+ CLabel label = new CLabel(bottom, SWT.NONE);
+ label.setText(DLTKTestingMessages.TestRunnerViewPart_label_failure);
label.setImage(fStackViewIcon);
bottom.setTopLeft(label);
- ToolBar failureToolBar= new ToolBar(bottom, SWT.FLAT | SWT.WRAP);
+ ToolBar failureToolBar = new ToolBar(bottom, SWT.FLAT | SWT.WRAP);
bottom.setTopCenter(failureToolBar);
- fFailureTrace= new FailureTrace(bottom, fClipboard, this, failureToolBar);
- bottom.setContent(fFailureTrace.getComposite());
-
- fSashForm.setWeights(new int[]{50, 50});
+ fFailureTrace = new FailureTrace(bottom, fClipboard, this,
+ failureToolBar);
+ bottom.setContent(fFailureTrace.getComposite());
+
+ fSashForm.setWeights(new int[] { 50, 50 });
return fSashForm;
}
@@ -1438,54 +1580,59 @@
getStatusLine().setMessage(null);
getStatusLine().setErrorMessage(null);
}
-
+
public void setFocus() {
if (fTestViewer != null)
fTestViewer.getTestViewerControl().setFocus();
}
-
- public void createPartControl(Composite parent) {
- fParent= parent;
- addResizeListener(parent);
- fClipboard= new Clipboard(parent.getDisplay());
- GridLayout gridLayout= new GridLayout();
- gridLayout.marginWidth= 0;
- gridLayout.marginHeight= 0;
+ public void createPartControl(Composite parent) {
+ fParent = parent;
+ addResizeListener(parent);
+ fClipboard = new Clipboard(parent.getDisplay());
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
parent.setLayout(gridLayout);
-
- fViewHistory= new RunnerViewHistory();
+
+ fViewHistory = new RunnerViewHistory();
configureToolBar();
-
- fCounterComposite= createProgressCountPanel(parent);
- fCounterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- SashForm sashForm= createSashForm(parent);
+
+ fCounterComposite = createProgressCountPanel(parent);
+ fCounterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+ | GridData.HORIZONTAL_ALIGN_FILL));
+ SashForm sashForm = createSashForm(parent);
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- IActionBars actionBars= getViewSite().getActionBars();
+
+ IActionBars actionBars = getViewSite().getActionBars();
fCopyAction = new DLTKTestingCopyAction(fFailureTrace, fClipboard);
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
-
- fOriginalViewImage= getTitleImage();
- fProgressImages= new ProgressImages();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDLTKTestingHelpContextIds.RESULTS_VIEW);
-
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
+ fCopyAction);
+
+ fOriginalViewImage = getTitleImage();
+ fProgressImages = new ProgressImages();
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
+ IDLTKTestingHelpContextIds.RESULTS_VIEW);
+
getViewSite().getPage().addPartListener(fPartListener);
setFilterAndLayout(false, LAYOUT_HIERARCHICAL);
if (fMemento != null) {
restoreLayoutState(fMemento);
}
- fMemento= null;
-
- fTestRunSessionListener= new TestRunSessionListener();
- DLTKTestingPlugin.getModel().addTestRunSessionListener(fTestRunSessionListener);
+ fMemento = null;
+
+ fTestRunSessionListener = new TestRunSessionListener();
+ DLTKTestingPlugin.getModel().addTestRunSessionListener(
+ fTestRunSessionListener);
}
private void addResizeListener(Composite parent) {
parent.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
+
public void controlResized(ControlEvent e) {
computeOrientation();
}
@@ -1494,101 +1641,106 @@
void computeOrientation() {
if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
- fCurrentOrientation= fOrientation;
+ fCurrentOrientation = fOrientation;
setOrientation(fCurrentOrientation);
- }
- else {
- Point size= fParent.getSize();
+ } else {
+ Point size = fParent.getSize();
if (size.x != 0 && size.y != 0) {
- if (size.x > size.y)
+ if (size.x > size.y)
setOrientation(VIEW_ORIENTATION_HORIZONTAL);
- else
+ else
setOrientation(VIEW_ORIENTATION_VERTICAL);
}
}
}
private void configureToolBar() {
- IActionBars actionBars= getViewSite().getActionBars();
- IToolBarManager toolBar= actionBars.getToolBarManager();
+ IActionBars actionBars = getViewSite().getActionBars();
+ IToolBarManager toolBar = actionBars.getToolBarManager();
IMenuManager viewMenu = actionBars.getMenuManager();
-
- fNextAction= new ShowNextFailureAction(this);
+
+ fNextAction = new ShowNextFailureAction(this);
fNextAction.setEnabled(false);
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
-
- fPreviousAction= new ShowPreviousFailureAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(),
+ fNextAction);
+
+ fPreviousAction = new ShowPreviousFailureAction(this);
fPreviousAction.setEnabled(false);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
-
- fStopAction= new StopAction();
+ actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(),
+ fPreviousAction);
+
+ fStopAction = new StopAction();
fStopAction.setEnabled(false);
-
- fRerunLastTestAction= new RerunLastAction();
- IHandlerService handlerService= (IHandlerService) getSite().getWorkbenchWindow().getService(IHandlerService.class);
+
+ fRerunLastTestAction = new RerunLastAction();
+ IHandlerService handlerService = (IHandlerService) getSite()
+ .getWorkbenchWindow().getService(IHandlerService.class);
IHandler handler = new AbstractHandler() {
- public Object execute(ExecutionEvent event) throws ExecutionException {
+ public Object execute(ExecutionEvent event)
+ throws ExecutionException {
fRerunLastTestAction.run();
return null;
}
+
public boolean isEnabled() {
return fRerunLastTestAction.isEnabled();
}
};
- fRerunLastActivation= handlerService.activateHandler(RERUN_LAST_COMMAND, handler);
+ fRerunLastActivation = handlerService.activateHandler(
+ RERUN_LAST_COMMAND, handler);
-// fRerunFailedFirstAction= new RerunLastFailedFirstAction();
-// handler = new AbstractHandler() {
-// public Object execute(ExecutionEvent event) throws ExecutionException {
-// fRerunFailedFirstAction.run();
-// return null;
-// }
-// public boolean isEnabled() {
-// return fRerunFailedFirstAction.isEnabled();
-// }
-// };
-// fRerunFailedFirstActivation= handlerService.activateHandler(RERUN_FAILED_FIRST_COMMAND, handler);
-
- fFailuresOnlyFilterAction= new FailuresOnlyFilterAction();
-
- fScrollLockAction= new ScrollLockAction(this);
+ // fRerunFailedFirstAction= new RerunLastFailedFirstAction();
+ // handler = new AbstractHandler() {
+ // public Object execute(ExecutionEvent event) throws ExecutionException
+ // {
+ // fRerunFailedFirstAction.run();
+ // return null;
+ // }
+ // public boolean isEnabled() {
+ // return fRerunFailedFirstAction.isEnabled();
+ // }
+ // };
+ // fRerunFailedFirstActivation=
+ // handlerService.activateHandler(RERUN_FAILED_FIRST_COMMAND, handler);
+
+ fFailuresOnlyFilterAction = new FailuresOnlyFilterAction();
+
+ fScrollLockAction = new ScrollLockAction(this);
fScrollLockAction.setChecked(!fAutoScroll);
-
- fToggleOrientationActions =
- new ToggleOrientationAction[] {
+
+ fToggleOrientationActions = new ToggleOrientationAction[] {
new ToggleOrientationAction(VIEW_ORIENTATION_VERTICAL),
new ToggleOrientationAction(VIEW_ORIENTATION_HORIZONTAL),
- new ToggleOrientationAction(VIEW_ORIENTATION_AUTOMATIC)};
-
- fShowTestHierarchyAction= new ShowTestHierarchyAction();
-
+ new ToggleOrientationAction(VIEW_ORIENTATION_AUTOMATIC) };
+
+ fShowTestHierarchyAction = new ShowTestHierarchyAction();
+
toolBar.add(fNextAction);
toolBar.add(fPreviousAction);
toolBar.add(fFailuresOnlyFilterAction);
toolBar.add(fScrollLockAction);
toolBar.add(new Separator());
toolBar.add(fRerunLastTestAction);
-// toolBar.add(fRerunFailedFirstAction);
+ // toolBar.add(fRerunFailedFirstAction);
toolBar.add(fStopAction);
toolBar.add(fViewHistory.createHistoryDropDownAction());
-
-
+
viewMenu.add(fShowTestHierarchyAction);
viewMenu.add(new Separator());
-
- MenuManager layoutSubMenu= new MenuManager(DLTKTestingMessages.TestRunnerViewPart_layout_menu);
+
+ MenuManager layoutSubMenu = new MenuManager(
+ DLTKTestingMessages.TestRunnerViewPart_layout_menu);
for (int i = 0; i < fToggleOrientationActions.length; ++i) {
layoutSubMenu.add(fToggleOrientationActions[i]);
}
viewMenu.add(layoutSubMenu);
viewMenu.add(new Separator());
-
+
viewMenu.add(fFailuresOnlyFilterAction);
-
-
- fActivateOnErrorAction= new ActivateOnErrorAction();
+
+ fActivateOnErrorAction = new ActivateOnErrorAction();
viewMenu.add(fActivateOnErrorAction);
- fViewMenuListener= new IMenuListener() {
+ fViewMenuListener = new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
fActivateOnErrorAction.update();
}
@@ -1602,38 +1754,40 @@
private IStatusLineManager getStatusLine() {
// we want to show messages globally hence we
// have to go through the active part
- IViewSite site= getViewSite();
- IWorkbenchPage page= site.getPage();
- IWorkbenchPart activePart= page.getActivePart();
-
+ IViewSite site = getViewSite();
+ IWorkbenchPage page = site.getPage();
+ IWorkbenchPart activePart = page.getActivePart();
+
if (activePart instanceof IViewPart) {
- IViewPart activeViewPart= (IViewPart)activePart;
- IViewSite activeViewSite= activeViewPart.getViewSite();
+ IViewPart activeViewPart = (IViewPart) activePart;
+ IViewSite activeViewSite = activeViewPart.getViewSite();
return activeViewSite.getActionBars().getStatusLineManager();
}
-
+
if (activePart instanceof IEditorPart) {
- IEditorPart activeEditorPart= (IEditorPart)activePart;
- IEditorActionBarContributor contributor= activeEditorPart.getEditorSite().getActionBarContributor();
- if (contributor instanceof EditorActionBarContributor)
- return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
+ IEditorPart activeEditorPart = (IEditorPart) activePart;
+ IEditorActionBarContributor contributor = activeEditorPart
+ .getEditorSite().getActionBarContributor();
+ if (contributor instanceof EditorActionBarContributor)
+ return ((EditorActionBarContributor) contributor)
+ .getActionBars().getStatusLineManager();
}
// no active part
return getViewSite().getActionBars().getStatusLineManager();
}
protected Composite createProgressCountPanel(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
composite.setLayout(layout);
- setCounterColumns(layout);
-
+ 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;
}
@@ -1641,14 +1795,14 @@
showFailure(test);
fCopyAction.handleTestSelected(test);
}
-
+
private void showFailure(final TestElement test) {
postSyncRunnable(new Runnable() {
public void run() {
if (!isDisposed())
fFailureTrace.showFailure(test);
}
- });
+ });
}
public ITestRunnerUI getTestRunnerUI() {
@@ -1660,12 +1814,14 @@
* @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() {
return fTestRunSession == null ? null : fTestRunSession.getLaunch();
}
-
+
public static Image createImage(String path) {
return DLTKTestingPlugin.getImageDescriptor(path).createImage();
}
@@ -1677,14 +1833,14 @@
private Display getDisplay() {
return getViewSite().getShell().getDisplay();
}
-
+
/*
* @see IWorkbenchPart#getTitleImage()
*/
public Image getTitleImage() {
if (fOriginalViewImage == null)
- fOriginalViewImage= super.getTitleImage();
-
+ fOriginalViewImage = super.getTitleImage();
+
if (fViewImage == null)
return super.getTitleImage();
return fViewImage;
@@ -1693,14 +1849,14 @@
void codeHasChanged() {
if (fDirtyListener != null) {
DLTKCore.removeElementChangedListener(fDirtyListener);
- fDirtyListener= null;
+ fDirtyListener = null;
}
- if (fViewImage == fTestRunOKIcon)
- fViewImage= fTestRunOKDirtyIcon;
+ if (fViewImage == fTestRunOKIcon)
+ fViewImage = fTestRunOKDirtyIcon;
else if (fViewImage == fTestRunFailIcon)
- fViewImage= fTestRunFailDirtyIcon;
-
- Runnable r= new Runnable() {
+ fViewImage = fTestRunFailDirtyIcon;
+
+ Runnable r = new Runnable() {
public void run() {
if (isDisposed())
return;
@@ -1710,30 +1866,36 @@
if (!isDisposed())
getDisplay().asyncExec(r);
}
-
+
public boolean isCreated() {
return fCounterPanel != null;
}
- public void rerunTest(String testId, String className, String testName, String launchMode) {
+ public void rerunTest(String testId, String className, String testName,
+ String launchMode) {
DebugUITools.saveAndBuildBeforeLaunch();
try {
- boolean couldLaunch= fTestRunSession.rerunTest(testId, className, testName, launchMode);
- if (! couldLaunch) {
- MessageDialog.openInformation(getSite().getShell(),
- DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
- DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
+ boolean couldLaunch = fTestRunSession.rerunTest(testId, className,
+ testName, launchMode);
+ if (!couldLaunch) {
+ MessageDialog
+ .openInformation(
+ getSite().getShell(),
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerun_title,
+ DLTKTestingMessages.TestRunnerViewPart_cannotrerurn_message);
} else if (fTestRunSession.isKeptAlive()) {
- TestCaseElement testCaseElement= (TestCaseElement) fTestRunSession.getTestElement(testId);
- testCaseElement.setStatus(TestElement.Status.RUNNING, null, null, null);
+ TestCaseElement testCaseElement = (TestCaseElement) fTestRunSession
+ .getTestElement(testId);
+ testCaseElement.setStatus(TestElement.Status.RUNNING, null,
+ null, null);
fTestViewer.registerViewerUpdate(testCaseElement);
postSyncProcessChanges();
}
} 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());
}
}
@@ -1746,8 +1908,8 @@
}
public void warnOfContentChange() {
- IWorkbenchSiteProgressService service= getProgressService();
- if (service != null)
+ IWorkbenchSiteProgressService service = getProgressService();
+ if (service != null)
service.warnOfContentChange();
}
@@ -1761,41 +1923,44 @@
boolean horizontal = orientation == VIEW_ORIENTATION_HORIZONTAL;
fSashForm.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
for (int i = 0; i < fToggleOrientationActions.length; ++i)
- fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
+ fToggleOrientationActions[i]
+ .setChecked(fOrientation == fToggleOrientationActions[i]
+ .getOrientation());
fCurrentOrientation = orientation;
- GridLayout layout= (GridLayout) fCounterComposite.getLayout();
- setCounterColumns(layout);
+ GridLayout layout = (GridLayout) fCounterComposite.getLayout();
+ setCounterColumns(layout);
fParent.layout();
}
private void setCounterColumns(GridLayout layout) {
if (fCurrentOrientation == VIEW_ORIENTATION_HORIZONTAL)
- layout.numColumns= 2;
+ layout.numColumns = 2;
else
- layout.numColumns= 1;
+ layout.numColumns = 1;
}
private static boolean getShowOnErrorOnly() {
- IPreferenceStore store= DLTKTestingPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(DLTKTestingPreferencesConstants.SHOW_ON_ERROR_ONLY);
+ IPreferenceStore store = DLTKTestingPlugin.getDefault()
+ .getPreferenceStore();
+ return store
+ .getBoolean(DLTKTestingPreferencesConstants.SHOW_ON_ERROR_ONLY);
}
public FailureTrace getFailureTrace() {
return fFailureTrace;
}
-
-
+
void setShowFailuresOnly(boolean failuresOnly) {
setFilterAndLayout(failuresOnly, fLayout);
}
-
+
private void setLayoutMode(int mode) {
setFilterAndLayout(fFailuresOnlyFilterAction.isChecked(), mode);
}
-
+
private void setFilterAndLayout(boolean failuresOnly, int layoutMode) {
fShowTestHierarchyAction.setChecked(layoutMode == LAYOUT_HIERARCHICAL);
- fLayout= layoutMode;
+ fLayout = layoutMode;
fFailuresOnlyFilterAction.setChecked(failuresOnly);
fTestViewer.setShowFailuresOnly(failuresOnly, layoutMode);
}