diff options
author | Darin Wright | 2005-02-07 15:27:31 +0000 |
---|---|---|
committer | Darin Wright | 2005-02-07 15:27:31 +0000 |
commit | 58fa9b48e27374f2a02837fa6fc978791752ec2b (patch) | |
tree | 4efa34c7d855fdc53a68e598a0da372c33a6f6bf /org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java | |
parent | bea8cbcf25ace8a2d6b2481424261c051770c5be (diff) | |
download | eclipse.platform.debug-58fa9b48e27374f2a02837fa6fc978791752ec2b.tar.gz eclipse.platform.debug-58fa9b48e27374f2a02837fa6fc978791752ec2b.tar.xz eclipse.platform.debug-58fa9b48e27374f2a02837fa6fc978791752ec2b.zip |
Bug 72838 - Say which project in "Errors exist in a required project. Continue to launch?"
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java')
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java new file mode 100644 index 000000000..700098f82 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.launchConfigurations; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.IStatusHandler; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.widgets.Shell; + + +public class CompileErrorProjectPromptStatusHandler implements IStatusHandler { + + /* (non-Javadoc) + * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) + */ + public Object handleStatus(IStatus status, Object source) throws CoreException { + ILaunchConfiguration config = null; + List projects = new ArrayList(); + + if (source instanceof List) { + List args = (List) source; + Iterator iterator = args.iterator(); + while (iterator.hasNext()) { + Object arg = iterator.next(); + if (arg instanceof ILaunchConfiguration) { + config = (ILaunchConfiguration) arg; + if (DebugUITools.isPrivate(config)) { + return new Boolean(true); + } + } else if (arg instanceof IProject) { + projects.add(arg); + } + } + } + + Shell shell = DebugUIPlugin.getShell(); + String title = LaunchConfigurationsMessages.getString("CompileErrorPromptStatusHandler.0"); //$NON-NLS-1$ + StringBuffer projectMessage = new StringBuffer(); + for (int i = 0; i < projects.size(); i++) { + if (i > 0) { + projectMessage.append(", "); //$NON-NLS-1$ + } + projectMessage.append(((IProject)projects.get(i)).getName()); + } + String message = MessageFormat.format(LaunchConfigurationsMessages.getString("CompileErrorPromptStatusHandler.2"), new String[]{projectMessage.toString()}); //$NON-NLS-1$ + IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); + + String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); + if (pref != null) { + if (pref.equals(MessageDialogWithToggle.ALWAYS)) { + return new Boolean(true); + } + } + + MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.WARNING, + new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 1, null, false); + dialog.setPrefKey(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); + dialog.setPrefStore(store); + dialog.open(); + + int returnValue = dialog.getReturnCode(); + if (returnValue == IDialogConstants.OK_ID) { + return new Boolean(true); + } + return new Boolean(false); + } +} |