1 11 package org.eclipse.debug.internal.ui.actions.breakpoints; 12 13 import org.eclipse.debug.internal.ui.DebugUIPlugin; 14 import org.eclipse.debug.internal.ui.actions.ActionMessages; 15 import org.eclipse.jface.dialogs.IDialogSettings; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.events.SelectionEvent; 19 import org.eclipse.swt.events.SelectionListener; 20 import org.eclipse.swt.graphics.Font; 21 import org.eclipse.swt.graphics.Image; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.Button; 24 import org.eclipse.swt.widgets.Composite; 25 import org.eclipse.swt.widgets.Control; 26 import org.eclipse.swt.widgets.Shell; 27 28 33 public class DeleteWorkingsetsMessageDialog extends MessageDialog { 34 35 38 private boolean fDeleteWorkingsets = false; 39 40 44 private boolean fDeleteBreakpoints = true; 45 46 private Button fDeleteWS; 48 private Button fDeleteBPS; 49 50 private final static String DIALOG_SETTINGS = "DeleteBreakpointsDialogSettings"; private static final String DELETE_BREAKPOINTS = "DeleteBreakpoints"; private static final String DELETE_WORKINGSETS = "DeleteWorkingSets"; 55 public DeleteWorkingsetsMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String [] dialogButtonLabels, int defaultIndex) { 56 super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); 57 IDialogSettings section = getDialogSettings(); 58 fDeleteBreakpoints = section.getBoolean(DELETE_BREAKPOINTS); 59 fDeleteWorkingsets = section.getBoolean(DELETE_WORKINGSETS); 60 } 61 62 65 protected Control createCustomArea(Composite parent) { 66 Composite comp = new Composite(parent, SWT.NONE); 67 comp.setLayout(new GridLayout()); 68 Font font = parent.getFont(); 69 fDeleteWS = new Button(comp, SWT.CHECK); 70 fDeleteWS.setText(ActionMessages.DeleteWorkingsetsMessageDialog_0); 71 fDeleteWS.setFont(font); 72 fDeleteWS.addSelectionListener(new SelectionListener() { 73 public void widgetDefaultSelected(SelectionEvent e) {} 74 public void widgetSelected(SelectionEvent e) { 75 getButton(0).setEnabled(fDeleteWS.getSelection() || fDeleteBPS.getSelection()); 76 } 77 }); 78 79 fDeleteBPS = new Button(comp, SWT.CHECK); 80 fDeleteBPS.setText(ActionMessages.DeleteWorkingsetsMessageDialog_1); 81 fDeleteBPS.setFont(font); 82 fDeleteBPS.addSelectionListener(new SelectionListener() { 83 public void widgetDefaultSelected(SelectionEvent e) {} 84 public void widgetSelected(SelectionEvent e) { 85 getButton(0).setEnabled(fDeleteWS.getSelection() || fDeleteBPS.getSelection()); 86 } 87 }); 88 89 fDeleteWS.setSelection(fDeleteWorkingsets); 90 fDeleteBPS.setSelection(fDeleteBreakpoints); 91 return comp; 92 } 93 94 97 protected void buttonPressed(int buttonId) { 98 if(buttonId == OK) { 99 fDeleteBreakpoints = fDeleteBPS.getSelection(); 100 fDeleteWorkingsets = fDeleteWS.getSelection(); 101 IDialogSettings dialogSettings = getDialogSettings(); 102 dialogSettings.put(DELETE_BREAKPOINTS, fDeleteBreakpoints); 103 dialogSettings.put(DELETE_WORKINGSETS, fDeleteWorkingsets); 104 } 105 super.buttonPressed(buttonId); 106 } 107 108 112 public boolean deleteWorkingset() { 113 return fDeleteWorkingsets; 114 } 115 116 120 public boolean deleteAllBreakpoints() { 121 return fDeleteBreakpoints; 122 } 123 124 129 protected IDialogSettings getDialogSettings() { 130 DebugUIPlugin plugin = DebugUIPlugin.getDefault(); 131 IDialogSettings workbenchSettings = plugin.getDialogSettings(); 132 IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS); 133 if (section == null) { 134 section = workbenchSettings.addNewSection(DIALOG_SETTINGS); 135 section.put(DELETE_BREAKPOINTS, true); 136 section.put(DELETE_WORKINGSETS, false); 137 } 138 return section; 139 } 140 141 142 143 } 144 | Popular Tags |