Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 114740
Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.java (-37 / +58 lines)
Lines 331-342 Link Here
331
		private final SelectionButtonDialogField fUseDefaultJRE, fUseProjectJRE;
331
		private final SelectionButtonDialogField fUseDefaultJRE, fUseProjectJRE;
332
		private final ComboDialogField fJRECombo;
332
		private final ComboDialogField fJRECombo;
333
		private final Group fGroup;
333
		private final Group fGroup;
334
		private final String[] fComplianceLabels;
334
		private String[] fComplianceLabels;
335
		private final String[] fComplianceData;
335
		private String[] fComplianceData;
336
		private final Link fPreferenceLink;
336
		private final Link fPreferenceLink;
337
		private final IVMInstall[] fInstalledJVMs;
337
		private IVMInstall[] fInstalledJVMs;
338
		
338
		
339
		public JREGroup(Composite composite) {
339
		public JREGroup(Composite composite) {
340
			fGroup= new Group(composite, SWT.NONE);
341
			fGroup.setFont(composite.getFont());
342
			fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
343
			fGroup.setLayout(initGridLayout(new GridLayout(3, false), true));
344
			fGroup.setText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_title); 
345
						
346
			fUseDefaultJRE= new SelectionButtonDialogField(SWT.RADIO);
347
			fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
348
			fUseDefaultJRE.doFillIntoGrid(fGroup, 2);
349
			
350
			fPreferenceLink= new Link(fGroup, SWT.NONE);
351
			fPreferenceLink.setFont(fGroup.getFont());
352
			fPreferenceLink.setText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_link_description);
353
			fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
354
			fPreferenceLink.addSelectionListener(this);
355
		
356
			fUseProjectJRE= new SelectionButtonDialogField(SWT.RADIO);
357
			fUseProjectJRE.setLabelText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_specific_compliance);
358
			fUseProjectJRE.doFillIntoGrid(fGroup, 1);
359
			fUseProjectJRE.setDialogFieldListener(this);
360
						
361
			fJRECombo= new ComboDialogField(SWT.READ_ONLY);
362
			fillInstalledJREs(fJRECombo);
363
			fJRECombo.setDialogFieldListener(this);
364
365
			Combo comboControl= fJRECombo.getComboControl(fGroup);
366
			comboControl.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); // make sure column 2 is grabing (but no fill)
367
			
368
			DialogField.createEmptySpace(fGroup);
369
			
370
			fUseDefaultJRE.setSelection(true);
371
			fJRECombo.setEnabled(fUseProjectJRE.isSelected());
372
		}
373
374
		private void fillInstalledJREs(ComboDialogField comboField) {
375
			String selectedItem= null;
376
			int selectionIndex= -1;
377
			if (fUseProjectJRE.isSelected()) {
378
				selectionIndex= comboField.getSelectionIndex();
379
				if (selectionIndex != -1) {//paranoia
380
					selectedItem= comboField.getItems()[selectionIndex];
381
				}
382
			}
383
			
340
			fInstalledJVMs= getWorkspaceJREs();
384
			fInstalledJVMs= getWorkspaceJREs();
341
			Arrays.sort(fInstalledJVMs, new Comparator() {
385
			Arrays.sort(fInstalledJVMs, new Comparator() {
342
386
Lines 360-369 Link Here
360
				}
404
				}
361
				
405
				
362
			});
406
			});
407
			selectionIndex= -1;//find new index
363
			fComplianceLabels= new String[fInstalledJVMs.length];
408
			fComplianceLabels= new String[fInstalledJVMs.length];
364
			fComplianceData= new String[fInstalledJVMs.length];
409
			fComplianceData= new String[fInstalledJVMs.length];
365
			for (int i= 0; i < fInstalledJVMs.length; i++) {
410
			for (int i= 0; i < fInstalledJVMs.length; i++) {
366
				fComplianceLabels[i]= fInstalledJVMs[i].getName();
411
				fComplianceLabels[i]= fInstalledJVMs[i].getName();
412
				if (selectedItem != null && fComplianceLabels[i].equals(selectedItem)) {
413
					selectionIndex= i;
414
				}
367
				if (fInstalledJVMs[i] instanceof IVMInstall2) {
415
				if (fInstalledJVMs[i] instanceof IVMInstall2) {
368
					String compliance= JavaModelUtil.getCompilerCompliance((IVMInstall2)fInstalledJVMs[i]);
416
					String compliance= JavaModelUtil.getCompilerCompliance((IVMInstall2)fInstalledJVMs[i]);
369
					if (compliance != null) {
417
					if (compliance != null) {
Lines 375-414 Link Here
375
					fComplianceData[i]= JavaCore.VERSION_1_4;
423
					fComplianceData[i]= JavaCore.VERSION_1_4;
376
				}
424
				}
377
			}
425
			}
378
			
426
			comboField.setItems(fComplianceLabels);
379
			fGroup= new Group(composite, SWT.NONE);
427
			if (selectionIndex == -1) {
380
			fGroup.setFont(composite.getFont());
428
				fJRECombo.selectItem(getDefaultJVMName());
381
			fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
429
			} else {
382
			fGroup.setLayout(initGridLayout(new GridLayout(3, false), true));
430
				fJRECombo.selectItem(selectedItem);
383
			fGroup.setText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_title); 
431
			}
384
						
385
			fUseDefaultJRE= new SelectionButtonDialogField(SWT.RADIO);
386
			fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
387
			fUseDefaultJRE.doFillIntoGrid(fGroup, 2);
388
			
389
			fPreferenceLink= new Link(fGroup, SWT.NONE);
390
			fPreferenceLink.setFont(fGroup.getFont());
391
			fPreferenceLink.setText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_link_description);
392
			fPreferenceLink.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
393
			fPreferenceLink.addSelectionListener(this);
394
		
395
			fUseProjectJRE= new SelectionButtonDialogField(SWT.RADIO);
396
			fUseProjectJRE.setLabelText(NewWizardMessages.JavaProjectWizardFirstPage_JREGroup_specific_compliance);
397
			fUseProjectJRE.doFillIntoGrid(fGroup, 1);
398
			fUseProjectJRE.setDialogFieldListener(this);
399
						
400
			fJRECombo= new ComboDialogField(SWT.READ_ONLY);
401
			fJRECombo.setItems(fComplianceLabels);
402
			fJRECombo.selectItem(getDefaultJVMName());
403
			fJRECombo.setDialogFieldListener(this);
404
405
			Combo comboControl= fJRECombo.getComboControl(fGroup);
406
			comboControl.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); // make sure column 2 is grabing (but no fill)
407
			
408
			DialogField.createEmptySpace(fGroup);
409
			
410
			fUseDefaultJRE.setSelection(true);
411
			fJRECombo.setEnabled(fUseProjectJRE.isSelected());
412
		}
432
		}
413
		
433
		
414
		private IVMInstall[] getWorkspaceJREs() {
434
		private IVMInstall[] getWorkspaceJREs() {
Lines 469-474 Link Here
469
		
489
		
470
		public void handlePossibleJVMChange() {
490
		public void handlePossibleJVMChange() {
471
			fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
491
			fUseDefaultJRE.setLabelText(getDefaultJVMLabel());
492
			fillInstalledJREs(fJRECombo);
472
		}
493
		}
473
		
494
		
474
495

Return to bug 114740