1 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 31 public class InplaceInstrumentationHandler implements IStatusHandler { 32 33 public Object handleStatus(IStatus status, Object source) 34 throws CoreException { 35 36 ILaunchConfiguration config = (ILaunchConfiguration) source; 37 Shell parent = EclEmmaUIPlugin.getInstance().getShell(); 38 String title = UIMessages.InstrumentationWarning_title; 39 String 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 [] { 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 |