KickJava   Java API By Example, From Geeks To Geeks.

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


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: InplaceInstrumentationHandler.java 12 2006-08-28 20:07:13Z mho $
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.ILaunchConfiguration;
13 import org.eclipse.debug.core.IStatusHandler;
14 import org.eclipse.jface.dialogs.IDialogConstants;
15 import org.eclipse.jface.dialogs.MessageDialog;
16 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
17 import org.eclipse.jface.preference.IPreferenceStore;
18 import org.eclipse.osgi.util.NLS;
19 import org.eclipse.swt.widgets.Shell;
20
21 import com.mountainminds.eclemma.internal.ui.EclEmmaUIPlugin;
22 import com.mountainminds.eclemma.internal.ui.UIMessages;
23 import com.mountainminds.eclemma.internal.ui.UIPreferences;
24
25 /**
26  * Status handler that issues a warning for in place instrumentation.
27  *
28  * @author Marc R. Hoffmann
29  * @version $Revision: 12 $
30  */

31 public class InplaceInstrumentationHandler implements IStatusHandler {
32
33   public Object JavaDoc handleStatus(IStatus status, Object JavaDoc source)
34       throws CoreException {
35
36     ILaunchConfiguration config = (ILaunchConfiguration) source;
37     Shell parent = EclEmmaUIPlugin.getInstance().getShell();
38     String JavaDoc title = UIMessages.InstrumentationWarning_title;
39     String JavaDoc message = NLS.bind(UIMessages.InstrumentationWarning_message, config
40         .getName());
41
42     IPreferenceStore store = EclEmmaUIPlugin.getInstance().getPreferenceStore();
43
44     if (MessageDialogWithToggle.ALWAYS.equals(store
45         .getString(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION))) {
46       return Boolean.TRUE;
47     }
48
49     MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, title,
50         null, message, MessageDialog.WARNING, new String JavaDoc[] {
51             IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
52         null, false);
53     dialog.setPrefKey(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION);
54     dialog.setPrefStore(store);
55     dialog.open();
56
57     return Boolean.valueOf(dialog.getReturnCode() == IDialogConstants.OK_ID);
58   }
59
60 }
61
Popular Tags