1 11 package org.eclipse.jdt.debug.ui; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 17 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 18 import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages; 19 import org.eclipse.jdt.internal.debug.ui.launcher.SourceLookupBlock; 20 import org.eclipse.jface.dialogs.Dialog; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.graphics.Font; 23 import org.eclipse.swt.layout.GridData; 24 import org.eclipse.swt.layout.GridLayout; 25 import org.eclipse.swt.widgets.Button; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.swt.widgets.Control; 28 import org.eclipse.swt.widgets.Display; 29 import org.eclipse.swt.widgets.Label; 30 import org.eclipse.swt.widgets.Shell; 31 32 49 public class JavaSourceLookupDialog extends Dialog { 50 51 private SourceLookupBlock fSourceLookupBlock; 52 private ILaunchConfiguration fConfiguration; 53 private String fMessage; 54 private boolean fNotAskAgain; 55 private Button fAskAgainCheckBox; 56 57 71 public JavaSourceLookupDialog(Shell shell, String message, ILaunchConfiguration configuration) { 72 super(shell); 73 fSourceLookupBlock= new SourceLookupBlock(); 74 fMessage = message; 75 fNotAskAgain= false; 76 fAskAgainCheckBox= null; 77 fConfiguration = configuration; 78 } 79 80 85 public boolean isNotAskAgain() { 86 return fNotAskAgain; 87 } 88 89 92 protected Control createDialogArea(Composite parent) { 93 Font font = parent.getFont(); 94 initializeDialogUnits(parent); 95 getShell().setText(LauncherMessages.JavaUISourceLocator_selectprojects_title); 96 97 Composite composite= (Composite) super.createDialogArea(parent); 98 composite.setLayout(new GridLayout()); 99 composite.setFont(font); 100 101 int pixelWidth= convertWidthInCharsToPixels(70); 102 Label message= new Label(composite, SWT.LEFT + SWT.WRAP); 103 message.setText(fMessage); 104 GridData data= new GridData(); 105 data.widthHint= pixelWidth; 106 message.setLayoutData(data); 107 message.setFont(font); 108 109 fSourceLookupBlock.createControl(composite); 110 Control inner = fSourceLookupBlock.getControl(); 111 fSourceLookupBlock.initializeFrom(fConfiguration); 112 GridData gd = new GridData(GridData.FILL_BOTH); 113 int height = Display.getCurrent().getBounds().height; 114 gd.heightHint = (int)(0.4f * height); 115 inner.setLayoutData(gd); 116 fAskAgainCheckBox= new Button(composite, SWT.CHECK + SWT.WRAP); 117 data= new GridData(); 118 data.widthHint= pixelWidth; 119 fAskAgainCheckBox.setLayoutData(data); 120 fAskAgainCheckBox.setFont(font); 121 fAskAgainCheckBox.setText(LauncherMessages.JavaUISourceLocator_askagain_message); 122 123 return composite; 124 } 125 126 129 protected void okPressed() { 130 try { 131 if (fAskAgainCheckBox != null) { 132 fNotAskAgain= fAskAgainCheckBox.getSelection(); 133 } 134 ILaunchConfigurationWorkingCopy wc = fConfiguration.getWorkingCopy(); 135 fSourceLookupBlock.performApply(wc); 136 if (!fConfiguration.contentsEqual(wc)) { 137 fConfiguration = wc.doSave(); 138 } 139 } catch (CoreException e) { 140 JDIDebugUIPlugin.log(e); 141 } 142 super.okPressed(); 143 } 144 } 145 | Popular Tags |