1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 import org.eclipse.debug.internal.ui.DebugUIPlugin; 14 import org.eclipse.debug.internal.ui.DefaultLabelProvider; 15 import org.eclipse.debug.internal.ui.SWTFactory; 16 import org.eclipse.jface.dialogs.Dialog; 17 import org.eclipse.jface.dialogs.IDialogSettings; 18 import org.eclipse.jface.viewers.ArrayContentProvider; 19 import org.eclipse.jface.viewers.IBaseLabelProvider; 20 import org.eclipse.jface.viewers.IContentProvider; 21 import org.eclipse.jface.viewers.StructuredViewer; 22 import org.eclipse.swt.graphics.Point; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.swt.widgets.Control; 25 import org.eclipse.swt.widgets.Shell; 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.dialogs.SelectionDialog; 28 29 39 public abstract class AbstractDebugSelectionDialog extends SelectionDialog { 40 41 protected StructuredViewer fViewer = null; 42 43 47 public AbstractDebugSelectionDialog(Shell parentShell) { 48 super(parentShell); 49 } 50 51 55 protected abstract String getDialogSettingsId(); 56 57 61 protected abstract Object getViewerInput(); 62 63 69 protected abstract StructuredViewer createViewer(Composite parent); 70 71 75 protected IContentProvider getContentProvider() { 76 return new ArrayContentProvider(); 78 } 79 80 84 protected IBaseLabelProvider getLabelProvider() { 85 return new DefaultLabelProvider(); 86 } 87 88 92 abstract protected String getHelpContextId(); 93 94 98 104 protected void addViewerListeners(StructuredViewer viewer){ 105 } 107 108 112 protected void addCustomHeaderControls(Composite parent) { 113 } 115 116 120 protected void addCustomFooterControls(Composite parent) { 121 } 123 124 128 protected void initializeControls() { 129 } 131 132 135 protected Control createDialogArea(Composite parent) { 136 initializeDialogUnits(parent); 137 Composite comp = (Composite) super.createDialogArea(parent); 138 addCustomHeaderControls(comp); 139 String label = getMessage(); 140 if(label != null && !"".equals(label)) { SWTFactory.createWrapLabel(comp, label, 1); 142 } 143 label = getViewerLabel(); 144 if(label != null && !"".equals(label)) { SWTFactory.createLabel(comp, label, 1); 146 } 147 fViewer = createViewer(comp); 148 fViewer.setLabelProvider(getLabelProvider()); 149 fViewer.setContentProvider(getContentProvider()); 150 fViewer.setInput(getViewerInput()); 151 addViewerListeners(fViewer); 152 addCustomFooterControls(comp); 153 initializeControls(); 154 Dialog.applyDialogFont(comp); 155 String help = getHelpContextId(); 156 if(help != null) { 157 PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, help); 158 } 159 return comp; 160 } 161 162 167 abstract protected String getViewerLabel(); 168 169 172 protected IDialogSettings getDialogBoundsSettings() { 173 IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); 174 IDialogSettings section = settings.getSection(getDialogSettingsId()); 175 if (section == null) { 176 section = settings.addNewSection(getDialogSettingsId()); 177 } 178 return section; 179 } 180 181 184 protected Point getInitialSize() { 185 IDialogSettings settings = getDialogBoundsSettings(); 186 if(settings != null) { 187 try { 188 int width = settings.getInt("DIALOG_WIDTH"); int height = settings.getInt("DIALOG_HEIGHT"); if(width > 0 & height > 0) { 191 return new Point(width, height); 192 } 193 } 194 catch (NumberFormatException nfe) { 195 return new Point(300, 350); 196 } 197 } 198 return new Point(300, 350); 199 } 200 201 } 202 | Popular Tags |