private boolean validateStartMenuGroup() { NSISWizardSettings settings = mWizard.getSettings(); if (settings.isCreateStartMenuGroup()) { String startMenuGroup = settings.getStartMenuGroup(); String[] parts = Common.tokenize(startMenuGroup, File.separatorChar); if (Common.isEmptyArray(parts)) { setErrorMessage( EclipseNSISPlugin.getFormattedString( "invalid.start.menu.group.error", new String[] {startMenuGroup})); // $NON-NLS-1$ return false; } for (int i = 0; i < parts.length; i++) { if (!IOUtility.isValidFileName(parts[i])) { setErrorMessage( EclipseNSISPlugin.getFormattedString( "invalid.start.menu.group.error", new String[] {startMenuGroup})); // $NON-NLS-1$ return false; } } } return true; }
/** @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(); } }); }