/** @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); } }); }
/* * (non-Javadoc) * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { display = parent.getDisplay(); sashForm = new SashForm(parent, SWT.VERTICAL); FillLayout layout = new FillLayout(); sashForm.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); sashForm.setLayoutData(data); initializeDialogUnits(sashForm); Composite composite = new Composite(sashForm, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; composite.setLayout(gridLayout); treeViewer = createTreeViewer(composite); data = new GridData(GridData.FILL_BOTH); data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT); data.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH); Tree tree = treeViewer.getTree(); tree.setLayoutData(data); tree.setHeaderVisible(true); activateCopy(tree); TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); nameColumn.getColumn().setText(ProvUIMessages.ProvUI_NameColumnTitle); nameColumn.getColumn().setWidth(400); nameColumn.getColumn().setMoveable(true); nameColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); String label = iu.getProperty(IInstallableUnit.PROP_NAME, null); if (label == null) label = iu.getId(); return label; } public Image getImage(Object element) { if (element instanceof ProvElement) return ((ProvElement) element).getImage(element); if (ProvUI.getAdapter(element, IInstallableUnit.class) != null) return ProvUIImages.getImage(ProvUIImages.IMG_IU); return null; } public String getToolTipText(Object element) { if (element instanceof AvailableIUElement && ((AvailableIUElement) element).getImageOverlayId(null) == ProvUIImages.IMG_INFO) return ProvUIMessages.RemedyElementNotHighestVersion; return super.getToolTipText(element); } }); TreeViewerColumn versionColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); versionColumn.getColumn().setText(ProvUIMessages.ProvUI_VersionColumnTitle); versionColumn.getColumn().setWidth(200); versionColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); if (element instanceof IIUElement) { if (((IIUElement) element).shouldShowVersion()) return iu.getVersion().toString(); return ""; //$NON-NLS-1$ } return iu.getVersion().toString(); } }); TreeViewerColumn idColumn = new TreeViewerColumn(treeViewer, SWT.LEFT); idColumn.getColumn().setText(ProvUIMessages.ProvUI_IdColumnTitle); idColumn.getColumn().setWidth(200); idColumn.setLabelProvider( new ColumnLabelProvider() { public String getText(Object element) { IInstallableUnit iu = ProvUI.getAdapter(element, IInstallableUnit.class); return iu.getId(); } }); // Filters and sorters before establishing content, so we don't refresh unnecessarily. IUComparator comparator = new IUComparator(IUComparator.IU_NAME); comparator.useColumnConfig(getColumnConfig()); treeViewer.setComparator(comparator); treeViewer.setComparer(new ProvElementComparer()); ColumnViewerToolTipSupport.enableFor(treeViewer); contentProvider = new ProvElementContentProvider(); treeViewer.setContentProvider(contentProvider); // labelProvider = new IUDetailsLabelProvider(null, getColumnConfig(), getShell()); // treeViewer.setLabelProvider(labelProvider); // Optional area to show the size createSizingInfo(composite); // The text area shows a description of the selected IU, or error detail if applicable. iuDetailsGroup = new IUDetailsGroup( sashForm, treeViewer, convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH), true); setControl(sashForm); sashForm.setWeights(getSashWeights()); Dialog.applyDialogFont(sashForm); // Controls for filtering/presentation/site selection Composite controlsComposite = new Composite(composite, SWT.NONE); gridLayout = new GridLayout(); gridLayout.marginWidth = 0; gridLayout.marginHeight = 0; gridLayout.numColumns = 2; gridLayout.makeColumnsEqualWidth = true; gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); controlsComposite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); controlsComposite.setLayoutData(gd); final Runnable runnable = new Runnable() { public void run() { treeViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { setDetailText(resolvedOperation); } }); setDrilldownElements(input, resolvedOperation); treeViewer.setInput(input); } }; if (resolvedOperation != null && !resolvedOperation.hasResolved()) { try { getContainer() .run( true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) { resolvedOperation.resolveModal(monitor); display.asyncExec(runnable); } }); } catch (Exception e) { StatusManager.getManager() .handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e)); } } else { runnable.run(); } }