1 11 package org.eclipse.jdt.internal.debug.ui.jres; 12 13 14 import org.eclipse.core.runtime.IPath; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.jdt.core.IClasspathEntry; 17 import org.eclipse.jdt.core.JavaCore; 18 import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; 19 import org.eclipse.jdt.launching.JavaRuntime; 20 import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; 21 import org.eclipse.jface.util.IPropertyChangeListener; 22 import org.eclipse.jface.util.PropertyChangeEvent; 23 import org.eclipse.jface.wizard.WizardPage; 24 import org.eclipse.swt.SWT; 25 import org.eclipse.swt.graphics.Image; 26 import org.eclipse.swt.layout.GridData; 27 import org.eclipse.swt.layout.GridLayout; 28 import org.eclipse.swt.widgets.Composite; 29 30 33 public class JREContainerWizardPage extends WizardPage implements IClasspathContainerPage { 34 35 38 private IClasspathEntry fSelection; 39 40 43 private JREsComboBlock fJREBlock; 44 45 48 public JREContainerWizardPage() { 49 super(JREMessages.JREContainerWizardPage_JRE_System_Library_1); 50 } 51 52 55 public boolean finish() { 56 IPath path = fJREBlock.getPath(); 57 fSelection = JavaCore.newContainerEntry(path); 58 return true; 59 } 60 61 64 public IClasspathEntry getSelection() { 65 return fSelection; 66 } 67 68 71 public void setSelection(IClasspathEntry containerEntry) { 72 fSelection = containerEntry; 73 initializeFromSelection(); 74 } 75 76 79 protected void initializeFromSelection() { 80 if (getControl() != null) { 81 if (fSelection == null) { 82 fJREBlock.setPath(JavaRuntime.newDefaultJREContainerPath()); 83 } else { 84 fJREBlock.setPath(fSelection.getPath()); 85 IStatus status = fJREBlock.getStatus(); 86 if (!status.isOK()) { 87 setErrorMessage(status.getMessage()); 88 } 89 } 90 } 91 } 92 93 96 public void createControl(Composite parent) { 97 Composite composite = new Composite(parent, SWT.NONE); 98 GridLayout layout = new GridLayout(); 99 composite.setLayout(layout); 100 GridData gd = new GridData(GridData.FILL_BOTH); 101 composite.setLayoutData(gd); 102 composite.setFont(parent.getFont()); 103 fJREBlock = new JREsComboBlock(); 104 fJREBlock.setDefaultJREDescriptor(new BuildJREDescriptor()); 105 fJREBlock.setTitle(JREMessages.JREContainerWizardPage_3); 106 fJREBlock.createControl(composite); 107 gd = new GridData(GridData.FILL_HORIZONTAL); 108 fJREBlock.getControl().setLayoutData(gd); 109 setControl(composite); 110 fJREBlock.addPropertyChangeListener(new IPropertyChangeListener() { 111 public void propertyChange(PropertyChangeEvent event) { 112 IStatus status = fJREBlock.getStatus(); 113 if (status.isOK()) { 114 setErrorMessage(null); 115 } else { 116 setErrorMessage(status.getMessage()); 117 } 118 } 119 }); 120 121 setTitle(JREMessages.JREContainerWizardPage_JRE_System_Library_1); 122 setMessage(JREMessages.JREContainerWizardPage_Select_the_JRE_used_to_build_this_project__4); 123 124 initializeFromSelection(); 125 } 126 127 130 public Image getImage() { 131 return JavaDebugImages.get(JavaDebugImages.IMG_WIZBAN_LIBRARY); 132 } 133 134 } 135 | Popular Tags |