1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 20:15:22 +02:00

[235197][api] Unusable wizard after cancelling on first page

This commit is contained in:
Martin Oberhuber 2008-06-03 09:04:12 +00:00
parent 9e2fc1d12d
commit 9f90db5b93
5 changed files with 222 additions and 144 deletions

View file

@ -17,6 +17,7 @@
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Uwe Stieber (Wind River) - [189426] System File/Folder Dialogs - New Connection Not Added to Drop Down
* Martin Oberhuber (Wind River) - [235197][api] Unusable wizard after cancelling on first page
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -66,6 +67,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// @see #setConnectionContext(IHost)
private IHost connectionContext;
private RSENewConnectionWizardRegistry wizardRegistry;
private IWizard selectedWizard;
private IRSESystemType selectedSystemType;
private boolean selectedWizardCanFinishEarly;
@ -92,9 +94,10 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
setDialogSettings(settings.getSection(sectionName));
wizardRegistry = new RSENewConnectionWizardRegistry();
selectedContext = null;
selectedWizard = null;
mainPage = new RSENewConnectionWizardSelectionPage();
mainPage = new RSENewConnectionWizardSelectionPage(wizardRegistry);
initializedWizards.clear();
selectionChangedListener.clear();
}
@ -286,7 +289,9 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (selectedWizard instanceof ISelectionChangedListener) removeSelectionChangedListener((ISelectionChangedListener)selectedWizard);
// Check if a wizard is registered for the selected system type
IRSENewConnectionWizardDescriptor descriptor = getSelection() != null ? RSENewConnectionWizardRegistry.getInstance().getWizardForSelection((IStructuredSelection)getSelection()) : null;
IRSENewConnectionWizardDescriptor descriptor = getSelection() != null ?
wizardRegistry.getWizardForSelection((IStructuredSelection) getSelection())
: null;
if (descriptor != null) {
selectedWizard = descriptor.getWizard();
selectedWizardCanFinishEarly = descriptor.canFinishEarly();

View file

@ -10,6 +10,7 @@
* Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [235148] get rid of dead code for caching
* Martin Oberhuber (Wind River) - [235197][api] Unusable wizard after cancelling on first page
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -27,8 +28,14 @@ import org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardRegistry;
/**
* RSE New connection wizard registry implementation.
*
* Gives access to the new connection wizards contributed by users, by looking
* up and creating wizard instances based on search criteria like system type or
* wizard id. Clients should create a new wizard registry instance for each UI
* "session" using the registry. For instance, an invocation of the new
* connection wizard (which delegates to sub-wizards) should always create a new
* registry instance.
*
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
@ -40,7 +47,16 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
}
/**
* Return the parser instance.
* Return the global new connection wizard registry instance. Note that
* using a global registry is problematic because sub-wizard state (and thus
* wizard instances) should not be re-used between separate invocations of a
* wizard by the user.
*
* @deprecated Instantiate a wizard registry yourself using
* {@link #RSENewConnectionWizardRegistry()} in order to control
* the lifetime of your wizard registry. Lifetime should be
* limited to the time a wizard is active. Each new wizard
* invocation should create a new wizard registry.
*/
public static RSENewConnectionWizardRegistry getInstance() {
return LazyInstanceHolder.instance;
@ -48,8 +64,10 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
/**
* Constructor.
*
* @since org.eclipse.rse.ui 3.0
*/
protected RSENewConnectionWizardRegistry() {
public RSENewConnectionWizardRegistry() {
super();
}

View file

@ -9,6 +9,7 @@
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter()
* Uwe Stieber (Wind River) - [209193] RSE new connection wizard shows empty categories if typing something into the filter
* Martin Oberhuber (Wind River) - [235197][api] Unusable wizard after cancelling on first page
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -73,6 +74,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
private IRSESystemType[] restrictedSystemTypes;
private RSENewConnectionWizardRegistry wizardRegistry;
private FilteredTree filteredTree;
private PatternFilter filteredTreeFilter;
private ViewerFilter filteredTreeWizardStateFilter;
@ -138,11 +140,24 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
/**
* Constructor.
* @since org.eclipse.rse.ui 3.0
*/
public RSENewConnectionWizardSelectionPage() {
public RSENewConnectionWizardSelectionPage(RSENewConnectionWizardRegistry wizardRegistry) {
super("RSENewConnectionWizardSelectionPage"); //$NON-NLS-1$
setTitle(getDefaultTitle());
setDescription(getDefaultDescription());
this.wizardRegistry = wizardRegistry;
}
/**
* Constructor.
*
* @deprecated Use
* {@link #RSENewConnectionWizardSelectionPage(RSENewConnectionWizardRegistry)}
* to control the lifetime of the wizard registry
*/
public RSENewConnectionWizardSelectionPage() {
this(RSENewConnectionWizardRegistry.getInstance());
}
/**
@ -189,21 +204,21 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Label label = new Label(composite, SWT.NONE);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_LABEL + ":"); //$NON-NLS-1$
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(composite, SWT.NONE);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
label.setText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_LABEL + ":"); //$NON-NLS-1$
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filteredTreeFilter = new RSEWizardSelectionTreePatternFilter();
filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter);
filteredTreeFilter = new RSEWizardSelectionTreePatternFilter();
filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter);
filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.heightHint = 325; layoutData.widthHint = 450;
filteredTree.setLayoutData(layoutData);
final TreeViewer treeViewer = filteredTree.getViewer();
treeViewer.setContentProvider(new RSEWizardSelectionTreeContentProvider());
// Explicitly allow the tree items to get decorated!!!
final TreeViewer treeViewer = filteredTree.getViewer();
treeViewer.setContentProvider(new RSEWizardSelectionTreeContentProvider());
// Explicitly allow the tree items to get decorated!!!
treeViewer.setLabelProvider(new DecoratingLabelProvider(new RSEWizardSelectionTreeLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
treeViewer.setComparator(new NewConnectionWizardViewerComparator());
@ -235,7 +250,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
});
filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager();
filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager(wizardRegistry);
treeViewer.setInput(filteredTreeDataManager);
// apply the standard dialog font
@ -338,7 +353,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
for (int i = 0; i < expandedCategories.length; i++) {
String categoryId = expandedCategories[i];
if (categoryId != null && !"".equals(categoryId.trim())) { //$NON-NLS-1$
IRSEWizardRegistryElement registryElement = RSENewConnectionWizardRegistry.getInstance().findElementById(categoryId);
IRSEWizardRegistryElement registryElement = wizardRegistry.findElementById(categoryId);
if (registryElement instanceof IRSEWizardCategory) {
RSEWizardSelectionTreeElement treeElement = filteredTreeDataManager.getTreeElementForCategory((IRSEWizardCategory)registryElement);
if (treeElement != null) expanded.add(treeElement);
@ -357,17 +372,17 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
public void saveWidgetValues() {
IDialogSettings settings = getDialogSettings();
if (settings != null) {
List expandedCategories = new ArrayList();
List expandedCategories = new ArrayList();
Object[] expanded = filteredTree.getViewer().getVisibleExpandedElements();
for (int i = 0; i < expanded.length; i++) {
if (expanded[i] instanceof RSEWizardSelectionTreeElement) {
IRSEWizardRegistryElement registryElement = ((RSEWizardSelectionTreeElement)expanded[i]).getWizardRegistryElement();
if (registryElement instanceof IRSEWizardCategory) {
expandedCategories.add(((IRSEWizardCategory)registryElement).getId());
}
}
}
settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, (String[])expandedCategories.toArray(new String[expandedCategories.size()]));
for (int i = 0; i < expanded.length; i++) {
if (expanded[i] instanceof RSEWizardSelectionTreeElement) {
IRSEWizardRegistryElement registryElement = ((RSEWizardSelectionTreeElement)expanded[i]).getWizardRegistryElement();
if (registryElement instanceof IRSEWizardCategory) {
expandedCategories.add(((IRSEWizardCategory)registryElement).getId());
}
}
}
settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, (String[])expandedCategories.toArray(new String[expandedCategories.size()]));
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
* Martin Oberhuber (Wind River) - [235197][api] Unusable wizard after cancelling on first page
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
@ -37,9 +38,21 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
/**
* Constructor.
* @since org.eclipse.rse.ui 3.0
*/
public RSENewConnectionWizardSelectionTreeDataManager(RSENewConnectionWizardRegistry wizardRegistry) {
super(wizardRegistry);
}
/**
* Constructor.
*
* @deprecated Use
* {@link #RSENewConnectionWizardSelectionTreeDataManager(RSENewConnectionWizardRegistry)}
* to control the lifetime of the wizard registry
*/
public RSENewConnectionWizardSelectionTreeDataManager() {
super();
this(RSENewConnectionWizardRegistry.getInstance());
}
/**
@ -84,7 +97,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i];
// for the system type, lookup the corresponding wizard descriptor
IRSENewConnectionWizardDescriptor descriptor = RSENewConnectionWizardRegistry.getInstance().getWizardForSystemType(systemType);
IRSENewConnectionWizardDescriptor descriptor = ((RSENewConnectionWizardRegistry)getWizardRegistry()).getWizardForSystemType(systemType);
if (descriptor == null) {
// a system type without even the default RSE new connection wizard associated
// is bad and should never happen. Drop a warning and skip the system type.
@ -112,7 +125,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
}
// get the category. If failing, the wizard will end up as root element
IRSEWizardRegistryElement candidate = RSENewConnectionWizardRegistry.getInstance().findElementById(categoryId);
IRSEWizardRegistryElement candidate = getWizardRegistry().findElementById(categoryId);
if (!(candidate instanceof IRSEWizardCategory)) {
rootElement.add(wizardElement);
continue;
@ -139,7 +152,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
}
while (parentCategoryId != null) {
candidate = RSENewConnectionWizardRegistry.getInstance().findElementById(parentCategoryId);
candidate = getWizardRegistry().findElementById(parentCategoryId);
if (!(candidate instanceof IRSEWizardCategory)) {
rootElement.add(categoryElement);
break;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [235197][api] Unusable wizard after cancelling on first page
*******************************************************************************/
package org.eclipse.rse.ui.wizards.registries;
@ -19,17 +20,43 @@ import java.util.Set;
*/
public abstract class RSEAbstractWizardSelectionTreeDataManager {
private final Set rootElement = new HashSet();
private RSEAbstractWizardRegistry wizardRegistry;
/**
* Constructor.
* @since org.eclipse.rse.ui 3.0
*/
public RSEAbstractWizardSelectionTreeDataManager() {
public RSEAbstractWizardSelectionTreeDataManager(RSEAbstractWizardRegistry wizardRegistry) {
this.wizardRegistry = wizardRegistry;
rootElement.clear();
// start the initialization of the data tree.
initialize(rootElement);
}
/**
* Constructor.
*
* @deprecated Use
* {@link #RSEAbstractWizardSelectionTreeDataManager(RSEAbstractWizardRegistry)}
* to control the lifetime of the wizard registry
*/
public RSEAbstractWizardSelectionTreeDataManager() {
this(null);
}
/**
* Returns the currently active wizard registry, which allows looking up
* wizard instances by various search keys. The wizard registry is valid as
* long as a particular wizard is open.
*
* @return the current wizard registry
* @since org.eclipse.rse.ui 3.0
*/
protected RSEAbstractWizardRegistry getWizardRegistry() {
return wizardRegistry;
}
/**
* Returns the children of this wizard selection tree element.
*