1 11 package org.eclipse.jdt.internal.debug.ui.jres; 12 13 14 import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; 15 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 16 import org.eclipse.jdt.launching.IVMInstall; 17 import org.eclipse.jdt.launching.IVMInstall2; 18 import org.eclipse.jdt.launching.JavaRuntime; 19 import org.eclipse.jface.dialogs.Dialog; 20 import org.eclipse.jface.dialogs.IDialogConstants; 21 import org.eclipse.jface.dialogs.IDialogSettings; 22 import org.eclipse.jface.viewers.TreeViewer; 23 import org.eclipse.swt.SWT; 24 import org.eclipse.swt.layout.GridData; 25 import org.eclipse.swt.layout.GridLayout; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.swt.widgets.Control; 28 import org.eclipse.swt.widgets.Label; 29 import org.eclipse.swt.widgets.Shell; 30 import org.eclipse.ui.PlatformUI; 31 32 37 public class VMDetailsDialog extends Dialog { 38 39 private IVMInstall fVM; 40 41 public VMDetailsDialog(Shell shell, IVMInstall vm) { 42 super(shell); 43 setShellStyle(getShellStyle() | SWT.RESIZE); 44 fVM= vm; 45 } 46 47 50 protected void configureShell(Shell newShell) { 51 super.configureShell(newShell); 52 newShell.setText(JREMessages.VMDetailsDialog_0); 53 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaDebugHelpContextIds.JRE_DETAILS_DIALOG); 54 } 55 56 protected Control createDialogArea(Composite ancestor) { 57 Composite parent = (Composite)super.createDialogArea(ancestor); 58 GridLayout layout = new GridLayout(2, false); 59 parent.setLayout(layout); 60 61 createLabel(parent, JREMessages.addVMDialog_jreType); 63 createLabel(parent, fVM.getVMInstallType().getName()); 64 65 createLabel(parent, JREMessages.addVMDialog_jreName); 67 createLabel(parent, fVM.getName()); 68 69 createLabel(parent, JREMessages.addVMDialog_jreHome); 71 createLabel(parent, fVM.getInstallLocation().getAbsolutePath()); 72 73 createLabel(parent, JREMessages.AddVMDialog_23); 75 String text = null; 76 if (fVM instanceof IVMInstall2) { 77 text = ((IVMInstall2)fVM).getVMArgs(); 78 } else { 79 String [] args = fVM.getVMArguments(); 80 if (args != null) { 81 StringBuffer buf = new StringBuffer (); 82 for (int i = 0; i < args.length; i++) { 83 buf.append(args[i]); 84 if (i < (args.length - 1)) { 85 buf.append(" "); } 87 } 88 text = buf.toString(); 89 } 90 } 91 if (text == null) { 92 text = ""; } 94 createLabel(parent, text); 95 96 Label label = createLabel(parent, JREMessages.AddVMDialog_JRE_system_libraries__1); 98 GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING); 99 label.setLayoutData(gd); 100 TreeViewer libraryViewer= new TreeViewer(parent); 101 gd = new GridData(GridData.FILL_BOTH); 102 gd.heightHint = 6; 103 libraryViewer.getControl().setLayoutData(gd); 104 LibraryContentProvider provider = new LibraryContentProvider(); 105 libraryViewer.setContentProvider(provider); 106 libraryViewer.setLabelProvider(new LibraryLabelProvider()); 107 libraryViewer.setInput(this); 108 provider.setLibraries(JavaRuntime.getLibraryLocations(fVM)); 109 110 applyDialogFont(parent); 111 return parent; 112 } 113 114 private Label createLabel(Composite parent, String text) { 115 Label label = new Label(parent, SWT.NONE); 116 label.setText(text); 117 return label; 118 } 119 120 125 protected String getDialogSettingsSectionName() { 126 return "VM_DETAILS_DIALOG_SECTION"; } 128 129 132 protected IDialogSettings getDialogBoundsSettings() { 133 IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings(); 134 IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); 135 if (section == null) { 136 section = settings.addNewSection(getDialogSettingsSectionName()); 137 } 138 return section; 139 } 140 141 144 protected void createButtonsForButtonBar(Composite parent) { 145 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, 147 true); 148 } 149 } 150 | Popular Tags |