private void createJREGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL); initializeJREValues(); SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2); fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2); fDefaultJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath()); } }); fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName); fNamedJREButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fNamedJREsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames()); fNamedJREsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getVMInstall(fNamedJREsCombo.getText()))); } }); fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv); fExecEnvButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateJREWidgets(); getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); fExecEnvsCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, fExecEnvChoices.toArray(new String[fExecEnvChoices.size()])); fExecEnvsCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition() .setJREContainer( JavaRuntime.newJREContainerPath( VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText()))); } }); }
/** @param composite */ private void createInstallationDirectoryGroup(Composite parent) { Group instDirGroup = NSISWizardDialogUtil.createGroup( parent, 2, "installation.directory.group.label", null, false); // $NON-NLS-1$ NSISWizardSettings settings = mWizard.getSettings(); ((GridData) NSISWizardDialogUtil.createLabel( instDirGroup, "installation.directory.label", true, null, isScriptWizard()) .getLayoutData()) .horizontalSpan = 1; //$NON-NLS-1$ final Composite instDirComposite = new Composite(instDirGroup, SWT.NONE); instDirComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final StackLayout instDirLayout = new StackLayout(); instDirComposite.setLayout(instDirLayout); final Combo instDirCombo = NSISWizardDialogUtil.createCombo( instDirComposite, 1, NSISWizardUtil.getPathConstantsAndVariables(settings.getTargetPlatform()), settings.getInstallDir(), false, true, null); final Text instDirText = NSISWizardDialogUtil.createText(instDirComposite, settings.getInstallDir(), 1, true, null); instDirLayout.topControl = instDirCombo; Runnable r = new Runnable() { private String mInstDirParent = ""; // $NON-NLS-1$ private void updateInstDir(NSISWizardSettings settings) { Control topControl; if (isMultiUser()) { if (settings.getInstallDir().startsWith(mInstDirParent)) { String instDir = settings.getInstallDir().substring(mInstDirParent.length()); settings.setInstallDir(instDir); instDirText.setText(instDir); } topControl = instDirText; } else { if (!settings.getInstallDir().startsWith(mInstDirParent)) { String instDir = mInstDirParent + settings.getInstallDir(); settings.setInstallDir(instDir); instDirCombo.setText(instDir); } topControl = instDirCombo; } if (instDirLayout.topControl != topControl) { instDirLayout.topControl = topControl; instDirComposite.layout(true); } validateField(INSTDIR_CHECK); } public void run() { final PropertyChangeListener propertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (NSISWizardSettings.INSTALLER_TYPE.equals(evt.getPropertyName()) || NSISWizardSettings.MULTIUSER_INSTALLATION.equals( evt.getPropertyName())) { updateInstDir(mWizard.getSettings()); } else if (NSISWizardSettings.INSTALL_DIR.equals(evt.getPropertyName())) { if (!isMultiUser()) { setInstDirParent(mWizard.getSettings()); } } } }; final INSISWizardSettingsListener settingsListener = new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, final NSISWizardSettings newSettings) { if (oldSettings != null) { oldSettings.removePropertyChangeListener(propertyListener); } setInstDirParent(newSettings); if (newSettings != null) { newSettings.addPropertyChangeListener(propertyListener); } updateInstDir(newSettings); } }; mWizard.addSettingsListener(settingsListener); mWizard.getSettings().addPropertyChangeListener(propertyListener); instDirCombo.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { mWizard.getSettings().removePropertyChangeListener(propertyListener); mWizard.removeSettingsListener(settingsListener); } }); setInstDirParent(mWizard.getSettings()); updateInstDir(mWizard.getSettings()); } private void setInstDirParent(NSISWizardSettings settings) { mInstDirParent = ""; // $NON-NLS-1$ if (settings != null) { String instDir = settings.getInstallDir(); if (!Common.isEmpty(instDir)) { int n = instDir.lastIndexOf('\\'); if (n > 0 && n < instDir.length() - 1) { mInstDirParent = instDir.substring(0, n + 1); } } } } }; r.run(); GridData gd = (GridData) instDirCombo.getLayoutData(); gd.horizontalAlignment = GridData.FILL; gd.grabExcessHorizontalSpace = true; instDirCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = ((Combo) e.widget).getText(); mWizard.getSettings().setInstallDir(text); validateField(INSTDIR_CHECK); } }); instDirText.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = ((Text) e.widget).getText(); mWizard.getSettings().setInstallDir(text); validateField(INSTDIR_CHECK); } }); final Button changeInstDir = NSISWizardDialogUtil.createCheckBox( instDirGroup, "change.installation.directory.label", //$NON-NLS-1$ settings.isChangeInstallDir(), (settings.getInstallerType() != INSTALLER_TYPE_SILENT), null, false); changeInstDir.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setChangeInstallDir(((Button) e.widget).getSelection()); } }); addPageChangedRunnable( new Runnable() { public void run() { if (isCurrentPage()) { NSISWizardSettings settings = mWizard.getSettings(); instDirCombo.setText(settings.getInstallDir()); changeInstDir.setEnabled(settings.getInstallerType() != INSTALLER_TYPE_SILENT); } } }); final PropertyChangeListener propertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (NSISWizardSettings.TARGET_PLATFORM.equals(evt.getPropertyName())) { NSISWizardDialogUtil.populateCombo( instDirCombo, NSISWizardUtil.getPathConstantsAndVariables( ((Integer) evt.getNewValue()).intValue()), ((NSISWizardSettings) evt.getSource()).getInstallDir()); } } }; settings.addPropertyChangeListener(propertyListener); final INSISWizardSettingsListener listener = new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { if (oldSettings != null) { oldSettings.removePropertyChangeListener(propertyListener); } instDirCombo.setText(newSettings.getInstallDir()); changeInstDir.setSelection(newSettings.isChangeInstallDir()); changeInstDir.setEnabled(newSettings.getInstallerType() != INSTALLER_TYPE_SILENT); newSettings.addPropertyChangeListener(propertyListener); } }; mWizard.addSettingsListener(listener); instDirGroup.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { mWizard.removeSettingsListener(listener); mWizard.getSettings().removePropertyChangeListener(propertyListener); } }); }
private void createTargetEnvironmentGroup(Composite container) { Group group = SWTFactory.createGroup( container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL); initializeChoices(); SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1); fOSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()])); fOSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setOS(getModelValue(fOSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1); fWSCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()])); fWSCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setWS(getModelValue(fWSCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1); fArchCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fArchChoices.toArray(new String[fArchChoices.size()])); fArchCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { getTargetDefinition().setArch(getModelValue(fArchCombo.getText())); } }); SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1); fNLCombo = SWTFactory.createCombo( group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()])); fNLCombo.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String value = fNLCombo.getText(); int index = value.indexOf("-"); // $NON-NLS-1$ if (index > 0) value = value.substring(0, index); getTargetDefinition().setNL(getModelValue(value)); } }); }