KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > ui > CompareResultsAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.junit.ui;
12
13
14 import org.eclipse.swt.events.DisposeEvent;
15 import org.eclipse.swt.events.DisposeListener;
16
17 import org.eclipse.jface.action.Action;
18
19 import org.eclipse.jdt.internal.junit.model.TestElement;
20
21 /**
22  * Action to enable/disable stack trace filtering.
23  */

24 public class CompareResultsAction extends Action {
25
26     private FailureTrace fView;
27     private CompareResultDialog fOpenDialog;
28     
29     public CompareResultsAction(FailureTrace view) {
30         super(JUnitMessages.CompareResultsAction_label);
31         setDescription(JUnitMessages.CompareResultsAction_description);
32         setToolTipText(JUnitMessages.CompareResultsAction_tooltip);
33         
34         setDisabledImageDescriptor(JUnitPlugin.getImageDescriptor("dlcl16/compare.gif")); //$NON-NLS-1$
35
setHoverImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/compare.gif")); //$NON-NLS-1$
36
setImageDescriptor(JUnitPlugin.getImageDescriptor("elcl16/compare.gif")); //$NON-NLS-1$
37
//PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJUnitHelpContextIds.ENABLEFILTER_ACTION);
38
fView= view;
39     }
40
41     /*
42      * @see Action#actionPerformed
43      */

44     public void run() {
45         TestElement failedTest= fView.getFailedTest();
46         if (fOpenDialog != null) {
47             fOpenDialog.setInput(failedTest);
48             fOpenDialog.getShell().setActive();
49                 
50         } else {
51             fOpenDialog= new CompareResultDialog(fView.getShell(), failedTest);
52             fOpenDialog.create();
53             fOpenDialog.getShell().addDisposeListener(new DisposeListener() {
54                 public void widgetDisposed(DisposeEvent e) {
55                     fOpenDialog= null;
56                 }
57             });
58             fOpenDialog.setBlockOnOpen(false);
59             fOpenDialog.open();
60         }
61     }
62     
63     public void updateOpenDialog(TestElement failedTest) {
64         if (fOpenDialog != null) {
65             fOpenDialog.setInput(failedTest);
66         }
67     }
68 }
69
Popular Tags