1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.core.resources.IProject; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IStatus; 20 import org.eclipse.debug.core.ILaunchConfiguration; 21 import org.eclipse.debug.core.IStatusHandler; 22 import org.eclipse.debug.internal.ui.DebugUIPlugin; 23 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 24 import org.eclipse.debug.ui.DebugUITools; 25 import org.eclipse.jface.dialogs.IDialogConstants; 26 import org.eclipse.jface.dialogs.MessageDialog; 27 import org.eclipse.jface.dialogs.MessageDialogWithToggle; 28 import org.eclipse.jface.preference.IPreferenceStore; 29 import org.eclipse.swt.widgets.Shell; 30 31 import com.ibm.icu.text.MessageFormat; 32 33 34 public class CompileErrorProjectPromptStatusHandler implements IStatusHandler { 35 36 39 public Object handleStatus(IStatus status, Object source) throws CoreException { 40 ILaunchConfiguration config = null; 41 List projects = new ArrayList (); 42 43 if (source instanceof List ) { 44 List args = (List ) source; 45 Iterator iterator = args.iterator(); 46 while (iterator.hasNext()) { 47 Object arg = iterator.next(); 48 if (arg instanceof ILaunchConfiguration) { 49 config = (ILaunchConfiguration) arg; 50 if (DebugUITools.isPrivate(config)) { 51 return Boolean.TRUE; 52 } 53 } else if (arg instanceof IProject) { 54 projects.add(arg); 55 } 56 } 57 } 58 Shell shell = DebugUIPlugin.getShell(); 59 StringBuffer projectList = new StringBuffer (); 60 int size = Math.min(20, projects.size()); 62 for (int i = 0; i < size; i++) { 63 if (i > 0) { 64 projectList.append(", "); } 66 projectList.append(((IProject)projects.get(i)).getName()); 67 } 68 String projectMessage = null; 69 if(projects.size() > 20) { 70 projectMessage = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_0, new Object []{projectList.toString()}); 71 } else{ 72 projectMessage = projectList.toString(); 73 } 74 String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0; 75 String message = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_2, new String []{projectMessage}); 76 IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); 77 78 String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); 79 if (pref != null) { 80 if (pref.equals(MessageDialogWithToggle.ALWAYS)) { 81 return Boolean.TRUE; 82 } 83 } 84 MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, 85 title, 86 null, 87 message, 88 MessageDialog.QUESTION, 89 new String [] {IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL}, 90 0, 91 LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_1, 92 false); 93 int open = dialog.open(); 94 if (open == IDialogConstants.PROCEED_ID) { 95 if(dialog.getToggleState()) { 96 store.setValue(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, MessageDialogWithToggle.ALWAYS); 97 } 98 return Boolean.TRUE; 99 } 100 else { 101 return Boolean.FALSE; 102 } 103 } 104 } 105 | Popular Tags |