1 11 package org.eclipse.debug.ui.sourcelookup; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.ILaunchConfiguration; 15 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 16 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 17 import org.eclipse.debug.internal.ui.DebugPluginImages; 18 import org.eclipse.debug.internal.ui.DebugUIPlugin; 19 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 20 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 21 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupPanel; 22 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; 23 import org.eclipse.jface.dialogs.Dialog; 24 import org.eclipse.jface.dialogs.IDialogConstants; 25 import org.eclipse.jface.dialogs.IDialogSettings; 26 import org.eclipse.jface.dialogs.TitleAreaDialog; 27 import org.eclipse.swt.SWT; 28 import org.eclipse.swt.layout.GridData; 29 import org.eclipse.swt.layout.GridLayout; 30 import org.eclipse.swt.widgets.Composite; 31 import org.eclipse.swt.widgets.Control; 32 import org.eclipse.swt.widgets.Shell; 33 import org.eclipse.ui.PlatformUI; 34 35 44 public class SourceLookupDialog extends TitleAreaDialog { 45 46 private SourceLookupPanel fPanel; 47 private ISourceLookupDirector fDirector; 48 49 59 public SourceLookupDialog(Shell shell, ISourceLookupDirector director) { 60 super(shell); 61 setShellStyle(getShellStyle() | SWT.RESIZE); 62 fDirector = director; 63 } 64 65 68 protected Control createDialogArea(Composite parent) { 69 setTitle(SourceLookupUIMessages.manageSourceDialog_description); 71 setTitleImage(DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_EDIT_SRC_LOC_WIZ)); 72 Composite composite = new Composite(parent, SWT.NONE); 73 74 GridLayout layout = new GridLayout(); 75 layout.marginHeight = 76 convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); 77 layout.marginWidth = 78 convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); 79 layout.verticalSpacing = 80 convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); 81 layout.horizontalSpacing = 82 convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); 83 composite.setLayout(layout); 84 GridData data = new GridData(GridData.FILL_BOTH); 85 composite.setLayoutData(data); 86 composite.setFont(parent.getFont()); 87 fPanel = new SourceLookupPanel(); 88 fPanel.createControl(composite); 89 fPanel.initializeFrom(fDirector); 90 Dialog.applyDialogFont(composite); 91 ILaunchConfiguration config = fDirector.getLaunchConfiguration(); 92 if(config != null && config.isReadOnly()) { 93 setErrorMessage(SourceLookupUIMessages.SourceLookupDialog_0+config.getName()+SourceLookupUIMessages.SourceLookupDialog_1); 94 } 95 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IDebugHelpContextIds.EDIT_SOURCELOOKUP_DIALOG); 96 97 return composite; 98 } 99 100 103 protected void okPressed() { 104 ILaunchConfiguration config = fDirector.getLaunchConfiguration(); 105 ILaunchConfigurationWorkingCopy copy = null; 106 if(config != null) { 107 try { 108 copy = config.getWorkingCopy(); 109 fPanel.performApply(copy); 110 copy.doSave(); 111 } 112 catch (CoreException e) {DebugUIPlugin.log(e);} 113 } 114 super.okPressed(); 115 } 116 117 120 protected void configureShell(Shell shell) { 121 super.configureShell(shell); 122 shell.setText(SourceLookupUIMessages.manageSourceDialog_title); 123 } 124 125 128 public boolean close() { 129 fPanel.dispose(); 130 return super.close(); 131 } 132 133 137 protected IDialogSettings getDialogBoundsSettings() { 138 IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); 139 IDialogSettings section = settings.getSection(getClass().getName()); 140 if (section == null) { 141 section = settings.addNewSection(getClass().getName()); 142 } 143 return section; 144 } 145 } 146 | Popular Tags |