KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mountainminds > eclemma > internal > ui > launching > NoInstrumentedClassesHandler


1 /*******************************************************************************
2  * Copyright (c) 2006 Mountainminds GmbH & Co. KG
3  * This software is provided under the terms of the Eclipse Public License v1.0
4  * See http://www.eclipse.org/legal/epl-v10.html.
5  *
6  * $Id: NoInstrumentedClassesHandler.java 154 2006-10-25 14:57:17Z mtnminds $
7  ******************************************************************************/

8 package com.mountainminds.eclemma.internal.ui.launching;
9
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IStatus;
12 import org.eclipse.debug.core.IStatusHandler;
13 import org.eclipse.debug.ui.DebugUITools;
14 import org.eclipse.jface.dialogs.IDialogConstants;
15 import org.eclipse.jface.dialogs.MessageDialog;
16 import org.eclipse.jface.viewers.StructuredSelection;
17 import org.eclipse.swt.widgets.Shell;
18
19 import com.mountainminds.eclemma.internal.ui.EclEmmaUIPlugin;
20 import com.mountainminds.eclemma.internal.ui.UIMessages;
21
22 /**
23  * Status handler that issues an error message when to launch a configuration
24  * that does not specify any classes for instrumentation. The used may decide
25  * to open the launch dialog directly.
26  *
27  * @author Marc R. Hoffmann
28  * @version $Revision: 154 $
29  */

30 public class NoInstrumentedClassesHandler implements IStatusHandler {
31
32   public Object JavaDoc handleStatus(IStatus status, final Object JavaDoc source)
33       throws CoreException {
34
35     final Shell parent = EclEmmaUIPlugin.getInstance().getShell();
36     String JavaDoc title = UIMessages.NoInstrumentedClassesError_title;
37     String JavaDoc message = UIMessages.NoInstrumentedClassesError_message;
38
39     MessageDialog d = new MessageDialog(parent, title, null, message, MessageDialog.ERROR,
40         new String JavaDoc[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
41     if (d.open() == 0) {
42       parent.getDisplay().asyncExec(new Runnable JavaDoc() {
43         public void run() {
44           DebugUITools.openLaunchConfigurationDialogOnGroup(parent,
45               new StructuredSelection(source), EclEmmaUIPlugin.ID_COVERAGE_LAUNCH_GROUP);
46         }
47       });
48     }
49     return Boolean.FALSE;
50   }
51
52 }
53
Popular Tags