KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > CompileErrorPromptStatusHandler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.internal.ui.launchConfigurations;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.debug.core.IStatusHandler;
17 import org.eclipse.debug.internal.ui.DebugUIPlugin;
18 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19 import org.eclipse.debug.ui.DebugUITools;
20 import org.eclipse.jface.dialogs.IDialogConstants;
21 import org.eclipse.jface.dialogs.MessageDialog;
22 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
23 import org.eclipse.jface.preference.IPreferenceStore;
24 import org.eclipse.swt.widgets.Shell;
25
26
27 public class CompileErrorPromptStatusHandler implements IStatusHandler {
28
29     /* (non-Javadoc)
30      * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
31      */

32     public Object JavaDoc handleStatus(IStatus status, Object JavaDoc source) throws CoreException {
33         if (source instanceof ILaunchConfiguration) {
34             ILaunchConfiguration config = (ILaunchConfiguration)source;
35             if (DebugUITools.isPrivate(config)) {
36                 return Boolean.TRUE;
37             }
38         }
39         
40         Shell shell = DebugUIPlugin.getShell();
41         String JavaDoc title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0;
42         String JavaDoc message = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_1;
43         IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
44         
45         String JavaDoc pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR);
46         if (pref != null) {
47             if (pref.equals(MessageDialogWithToggle.ALWAYS)) {
48                 return Boolean.TRUE;
49             }
50         }
51
52         MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.WARNING,
53                 new String JavaDoc[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 1, null, false);
54         dialog.setPrefKey(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR);
55         dialog.setPrefStore(store);
56         dialog.open();
57         
58         int returnValue = dialog.getReturnCode();
59         if (returnValue == IDialogConstants.YES_ID) {
60             return Boolean.TRUE;
61         }
62         return Boolean.FALSE;
63     }
64 }
65
Popular Tags