/** @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); } }); }
/** @param composite */ private void createStartMenuGroupGroup(Composite parent) { Group startMenuGroup = NSISWizardDialogUtil.createGroup( parent, 1, "startmenu.group.group.label", null, false); // $NON-NLS-1$ NSISWizardSettings settings = mWizard.getSettings(); final Button createStartMenu = NSISWizardDialogUtil.createCheckBox( startMenuGroup, "create.startmenu.group.label", settings.isCreateStartMenuGroup(), // $NON-NLS-1$ true, null, false); createStartMenu.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean selection = createStartMenu.getSelection(); mWizard.getSettings().setCreateStartMenuGroup(selection); validateField(SMGRP_CHECK); NSISWizardContentsPage page = (NSISWizardContentsPage) mWizard.getPage(NSISWizardContentsPage.NAME); if (page != null) { page.setPageComplete(page.validatePage(VALIDATE_ALL)); page.refresh(); mWizard.getContainer().updateButtons(); } } }); final MasterSlaveController m = new MasterSlaveController(createStartMenu); final Text startMenu = NSISWizardDialogUtil.createText( startMenuGroup, settings.getStartMenuGroup(), "startmenu.group.label", //$NON-NLS-1$ true, m, isScriptWizard()); startMenu.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = ((Text) e.widget).getText(); mWizard.getSettings().setStartMenuGroup(text); validateField(SMGRP_CHECK); } }); Composite composite = new Composite(startMenuGroup, SWT.NONE); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(data); GridLayout layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; composite.setLayout(layout); final Button changeStartMenu = NSISWizardDialogUtil.createCheckBox( composite, "change.startmenu.group.label", //$NON-NLS-1$ settings.isChangeStartMenuGroup(), (settings.getInstallerType() != INSTALLER_TYPE_SILENT), m, false); ((GridData) changeStartMenu.getLayoutData()).horizontalSpan = 1; changeStartMenu.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setChangeStartMenuGroup(((Button) e.widget).getSelection()); } }); final MasterSlaveController m2 = new MasterSlaveController(changeStartMenu); final MasterSlaveEnabler mse = new MasterSlaveEnabler() { public void enabled(Control control, boolean flag) { m2.updateSlaves(flag); } public boolean canEnable(Control control) { NSISWizardSettings settings = mWizard.getSettings(); if (changeStartMenu == control) { return settings.getInstallerType() != INSTALLER_TYPE_SILENT && settings.isCreateStartMenuGroup(); } else { return true; } } }; final Button disableShortcuts = NSISWizardDialogUtil.createCheckBox( composite, "disable.startmenu.shortcuts.label", //$NON-NLS-1$ settings.isDisableStartMenuShortcuts(), changeStartMenu.isEnabled(), m2, false); ((GridData) disableShortcuts.getLayoutData()).horizontalSpan = 1; disableShortcuts.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { mWizard.getSettings().setDisableStartMenuShortcuts(((Button) e.widget).getSelection()); } }); m.setEnabler(changeStartMenu, mse); m.updateSlaves(); addPageChangedRunnable( new Runnable() { public void run() { startMenu.setText(mWizard.getSettings().getStartMenuGroup()); changeStartMenu.setEnabled(mse.canEnable(changeStartMenu)); disableShortcuts.setEnabled(changeStartMenu.isEnabled()); } }); mWizard.addSettingsListener( new INSISWizardSettingsListener() { public void settingsChanged( NSISWizardSettings oldSettings, NSISWizardSettings newSettings) { createStartMenu.setSelection(newSettings.isCreateStartMenuGroup()); startMenu.setText(newSettings.getStartMenuGroup()); changeStartMenu.setSelection(newSettings.isChangeStartMenuGroup()); changeStartMenu.setEnabled(newSettings.getInstallerType() != INSTALLER_TYPE_SILENT); disableShortcuts.setSelection(newSettings.isDisableStartMenuShortcuts()); disableShortcuts.setEnabled(changeStartMenu.isEnabled()); m.updateSlaves(); } }); }