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

@ -7,16 +7,17 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Javier Montalvo Orús (Symbian) - Bug 158555 - newConnectionWizardDelegates can only be used once * Javier Montalvo Orús (Symbian) - Bug 158555 - newConnectionWizardDelegates can only be used once
* Uwe Stieber (Wind River) - Reworked new connection wizard extension point. * Uwe Stieber (Wind River) - Reworked new connection wizard extension point.
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * 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 * 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; package org.eclipse.rse.ui.wizards.newconnection;
@ -49,7 +50,7 @@ import org.eclipse.ui.IWorkbench;
/** /**
* The New Connection wizard. This wizard allows users to create new RSE connections. * The New Connection wizard. This wizard allows users to create new RSE connections.
* *
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
*/ */
public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, ISelectionProvider { public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, ISelectionProvider {
@ -57,7 +58,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
* Dialog settings slot id: Last selected system type id within the wizard. * Dialog settings slot id: Last selected system type id within the wizard.
*/ */
public static final String LAST_SELECTED_SYSTEM_TYPE_ID = "lastSelectedSystemTypeId"; //$NON-NLS-1$ public static final String LAST_SELECTED_SYSTEM_TYPE_ID = "lastSelectedSystemTypeId"; //$NON-NLS-1$
// The selected context as passed in from the invoking class. // The selected context as passed in from the invoking class.
// Just pass on to the wizards. Do not interpret here! // Just pass on to the wizards. Do not interpret here!
// @see #setSelectedContext(ISelection). // @see #setSelectedContext(ISelection).
@ -65,18 +66,19 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// The connection context as determined from the invoking class // The connection context as determined from the invoking class
// @see #setConnectionContext(IHost) // @see #setConnectionContext(IHost)
private IHost connectionContext; private IHost connectionContext;
private RSENewConnectionWizardRegistry wizardRegistry;
private IWizard selectedWizard; private IWizard selectedWizard;
private IRSESystemType selectedSystemType; private IRSESystemType selectedSystemType;
private boolean selectedWizardCanFinishEarly; private boolean selectedWizardCanFinishEarly;
private RSENewConnectionWizardSelectionPage mainPage; private RSENewConnectionWizardSelectionPage mainPage;
private final List initializedWizards = new LinkedList(); private final List initializedWizards = new LinkedList();
private final List selectionChangedListener = new LinkedList(); private final List selectionChangedListener = new LinkedList();
private IRSESystemType[] restrictedSystemTypes; private IRSESystemType[] restrictedSystemTypes;
private boolean onlySystemType; private boolean onlySystemType;
/** /**
* Constructor. * Constructor.
*/ */
@ -91,10 +93,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
String sectionName = this.getClass().getName(); String sectionName = this.getClass().getName();
if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName); if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
setDialogSettings(settings.getSection(sectionName)); setDialogSettings(settings.getSection(sectionName));
wizardRegistry = new RSENewConnectionWizardRegistry();
selectedContext = null; selectedContext = null;
selectedWizard = null; selectedWizard = null;
mainPage = new RSENewConnectionWizardSelectionPage(); mainPage = new RSENewConnectionWizardSelectionPage(wizardRegistry);
initializedWizards.clear(); initializedWizards.clear();
selectionChangedListener.clear(); selectionChangedListener.clear();
} }
@ -104,7 +107,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
*/ */
public void dispose() { public void dispose() {
super.dispose(); super.dispose();
selectedContext = null; selectedContext = null;
selectedSystemType = null; selectedSystemType = null;
selectedWizardCanFinishEarly = false; selectedWizardCanFinishEarly = false;
@ -125,7 +128,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
/** /**
* Restrict to a single system type. Users will not be shown the system type selection page in * Restrict to a single system type. Users will not be shown the system type selection page in
* the wizard. * the wizard.
* *
* @param systemType the system type to restrict to. * @param systemType the system type to restrict to.
*/ */
public void restrictToSystemType(IRSESystemType systemType) { public void restrictToSystemType(IRSESystemType systemType) {
@ -134,12 +137,12 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
/** /**
* Restrict system types. Users will only be able to choose from the given system types. * Restrict system types. Users will only be able to choose from the given system types.
* *
* @param systemTypes the system types to restrict to. * @param systemTypes the system types to restrict to.
*/ */
public void restrictToSystemTypes(IRSESystemType[] systemTypes) { public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
assert systemTypes != null; assert systemTypes != null;
restrictedSystemTypes = systemTypes; restrictedSystemTypes = systemTypes;
onlySystemType = restrictedSystemTypes.length == 1; onlySystemType = restrictedSystemTypes.length == 1;
mainPage.restrictToSystemTypes(restrictedSystemTypes); mainPage.restrictToSystemTypes(restrictedSystemTypes);
@ -149,13 +152,13 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
/** /**
* Returns if or if not the main new connection wizard has been restricted to only * Returns if or if not the main new connection wizard has been restricted to only
* one system type. * one system type.
* *
* @return <code>True</code> if the wizard is restricted to only one system type, <code>false</code> otherwise. * @return <code>True</code> if the wizard is restricted to only one system type, <code>false</code> otherwise.
*/ */
public final boolean isRestrictedToSingleSystemType() { public final boolean isRestrictedToSingleSystemType() {
return onlySystemType; return onlySystemType;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/ */
@ -177,7 +180,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
*/ */
private void fireSelectionChanged() { private void fireSelectionChanged() {
if (getSelection() == null) return; if (getSelection() == null) return;
SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
Iterator iterator = selectionChangedListener.iterator(); Iterator iterator = selectionChangedListener.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -185,7 +188,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
listener.selectionChanged(event); listener.selectionChanged(event);
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/ */
@ -203,11 +206,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (selectedContext != null) { if (selectedContext != null) {
selectionElements.add(selectedContext); selectionElements.add(selectedContext);
} }
// construct the selection now // construct the selection now
selection = new StructuredSelection(selectionElements); selection = new StructuredSelection(selectionElements);
} }
return selection; return selection;
} }
@ -223,7 +226,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
} else { } else {
selectedSystemType = null; selectedSystemType = null;
} }
// signal the system type change // signal the system type change
onSelectedSystemTypeChanged(); onSelectedSystemTypeChanged();
} }
@ -233,7 +236,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
* Sets the currently selected context for the wizard as know by the caller * Sets the currently selected context for the wizard as know by the caller
* of this method. The selected context is not interpreted by the main wizard, * of this method. The selected context is not interpreted by the main wizard,
* the selection is passed on as is to the nested wizards. * the selection is passed on as is to the nested wizards.
* *
* @param selectedContext The selected context or <code>null</code>. * @param selectedContext The selected context or <code>null</code>.
*/ */
public void setSelectedContext(ISelection selectedContext) { public void setSelectedContext(ISelection selectedContext) {
@ -246,7 +249,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
* the connections context system type and invoke <code> * the connections context system type and invoke <code>
* setSelection(...)</code> to apply the system type as the selected * setSelection(...)</code> to apply the system type as the selected
* one. * one.
* *
* @param connectionContext The connection context or <code>null</code>. * @param connectionContext The connection context or <code>null</code>.
*/ */
public void setConnectionContext(IHost connectionContext) { public void setConnectionContext(IHost connectionContext) {
@ -259,7 +262,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (systemType != null) setSelection(new StructuredSelection(systemType)); if (systemType != null) setSelection(new StructuredSelection(systemType));
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
*/ */
@ -269,7 +272,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
/** /**
* Returns the wizard for the currently selected system type. * Returns the wizard for the currently selected system type.
* *
* @return The wizard for the currently selected system type. Must be never <code>null</code>. * @return The wizard for the currently selected system type. Must be never <code>null</code>.
*/ */
public IWizard getSelectedWizard() { public IWizard getSelectedWizard() {
@ -284,9 +287,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
protected void onSelectedSystemTypeChanged() { protected void onSelectedSystemTypeChanged() {
// unregister the previous selected wizard as selection changed listener // unregister the previous selected wizard as selection changed listener
if (selectedWizard instanceof ISelectionChangedListener) removeSelectionChangedListener((ISelectionChangedListener)selectedWizard); if (selectedWizard instanceof ISelectionChangedListener) removeSelectionChangedListener((ISelectionChangedListener)selectedWizard);
// Check if a wizard is registered for the selected system type // 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) { if (descriptor != null) {
selectedWizard = descriptor.getWizard(); selectedWizard = descriptor.getWizard();
selectedWizardCanFinishEarly = descriptor.canFinishEarly(); selectedWizardCanFinishEarly = descriptor.canFinishEarly();
@ -294,7 +299,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
selectedWizard = null; selectedWizard = null;
selectedWizardCanFinishEarly = false; selectedWizardCanFinishEarly = false;
} }
// Check on the container association of the selected wizard. // Check on the container association of the selected wizard.
if (getContainer() != null && selectedWizard != null && !getContainer().equals(selectedWizard.getContainer())) { if (getContainer() != null && selectedWizard != null && !getContainer().equals(selectedWizard.getContainer())) {
selectedWizard.setContainer(getContainer()); selectedWizard.setContainer(getContainer());
@ -302,23 +307,23 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// Check if the wizard defines it's own window title. If not, make sure to pass the // Check if the wizard defines it's own window title. If not, make sure to pass the
// main wizards window title. // main wizards window title.
if (selectedWizard instanceof Wizard if (selectedWizard instanceof Wizard
&& (selectedWizard.getWindowTitle() == null || "".equals(selectedWizard.getWindowTitle()))) { //$NON-NLS-1$ && (selectedWizard.getWindowTitle() == null || "".equals(selectedWizard.getWindowTitle()))) { //$NON-NLS-1$
((Wizard)selectedWizard).setWindowTitle(getWindowTitle()); ((Wizard)selectedWizard).setWindowTitle(getWindowTitle());
} }
// if the newly selected wizard is the default RSE new connection wizard // if the newly selected wizard is the default RSE new connection wizard
// and the selected context is non-null, set the selected context to the // and the selected context is non-null, set the selected context to the
// default RSE new connection wizard. // default RSE new connection wizard.
if (selectedWizard instanceof RSEDefaultNewConnectionWizard) { if (selectedWizard instanceof RSEDefaultNewConnectionWizard) {
((RSEDefaultNewConnectionWizard)selectedWizard).setSelectedContext(connectionContext); ((RSEDefaultNewConnectionWizard)selectedWizard).setSelectedContext(connectionContext);
} }
// register the newly selected wizard as selection changed listener // register the newly selected wizard as selection changed listener
if (selectedWizard instanceof ISelectionChangedListener) { if (selectedWizard instanceof ISelectionChangedListener) {
addSelectionChangedListener((ISelectionChangedListener)selectedWizard); addSelectionChangedListener((ISelectionChangedListener)selectedWizard);
} }
// Initialize the wizard pages and remember which wizard we have initialized already. // Initialize the wizard pages and remember which wizard we have initialized already.
// Note: Do not call IWizard.addPages() here in case the main wizard is restricted to // Note: Do not call IWizard.addPages() here in case the main wizard is restricted to
// a single system type. The IWizard.addPages() method will be called from the // a single system type. The IWizard.addPages() method will be called from the
@ -360,10 +365,10 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
saveWidgetValues(); saveWidgetValues();
if (getSelectedWizard() != null) nextPage = getSelectedWizard().getStartingPage(); if (getSelectedWizard() != null) nextPage = getSelectedWizard().getStartingPage();
} }
if (nextPage == null) super.getNextPage(page); if (nextPage == null) super.getNextPage(page);
if (nextPage != null) nextPage.setPreviousPage(page); if (nextPage != null) nextPage.setPreviousPage(page);
return nextPage; return nextPage;
} }
@ -375,16 +380,16 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// wizard can finish early // wizard can finish early
return selectedWizardCanFinishEarly; return selectedWizardCanFinishEarly;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#performFinish() * @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#performFinish()
*/ */
public boolean performFinish() { public boolean performFinish() {
// Save the current selection to the dialog settings // Save the current selection to the dialog settings
saveWidgetValues(); saveWidgetValues();
if (mainPage != null) mainPage.saveWidgetValues(); if (mainPage != null) mainPage.saveWidgetValues();
return true; return true;
} }
@ -402,7 +407,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
} }
} }
} }
/** /**
* Restore the persistent saved wizard state. This method * Restore the persistent saved wizard state. This method
* is called from the wizards constructor. * is called from the wizards constructor.

View file

@ -10,6 +10,7 @@
* Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones * Javier Montalvo Orus (Symbian) - [174992] default wizard hides special ones
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind * David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
* Martin Oberhuber (Wind River) - [235148] get rid of dead code for caching * 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; 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. * 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. * @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 { 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() { public static RSENewConnectionWizardRegistry getInstance() {
return LazyInstanceHolder.instance; return LazyInstanceHolder.instance;
@ -48,8 +64,10 @@ public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry {
/** /**
* Constructor. * Constructor.
*
* @since org.eclipse.rse.ui 3.0
*/ */
protected RSENewConnectionWizardRegistry() { public RSENewConnectionWizardRegistry() {
super(); super();
} }

View file

@ -1,14 +1,15 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Uwe Stieber (Wind River) - initial API and implementation. * Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [186779] Fix IRSESystemType.getAdapter() * 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 * 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; package org.eclipse.rse.ui.wizards.newconnection;
@ -67,23 +68,24 @@ import org.eclipse.ui.dialogs.PatternFilter;
*/ */
public class RSENewConnectionWizardSelectionPage extends WizardPage { public class RSENewConnectionWizardSelectionPage extends WizardPage {
private final String helpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$; private final String helpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$;
private static final String EXPANDED_CATEGORIES_SETTINGS_ID = "filteredTree.expandedCatogryIds"; //$NON-NLS-1$ private static final String EXPANDED_CATEGORIES_SETTINGS_ID = "filteredTree.expandedCatogryIds"; //$NON-NLS-1$
private static final String[] DEFAULT_EXPANDED_CATEGORY_IDS = new String[] { "org.eclipse.rse.ui.wizards.newconnection.default.category" }; //$NON-NLS-1$ private static final String[] DEFAULT_EXPANDED_CATEGORY_IDS = new String[] { "org.eclipse.rse.ui.wizards.newconnection.default.category" }; //$NON-NLS-1$
private IRSESystemType[] restrictedSystemTypes; private IRSESystemType[] restrictedSystemTypes;
private RSENewConnectionWizardRegistry wizardRegistry;
private FilteredTree filteredTree; private FilteredTree filteredTree;
private PatternFilter filteredTreeFilter; private PatternFilter filteredTreeFilter;
private ViewerFilter filteredTreeWizardStateFilter; private ViewerFilter filteredTreeWizardStateFilter;
private RSENewConnectionWizardSelectionTreeDataManager filteredTreeDataManager; private RSENewConnectionWizardSelectionTreeDataManager filteredTreeDataManager;
/** /**
* Internal class. The wizard state filter is responsible to filter * Internal class. The wizard state filter is responsible to filter
* out any not enabled or filtered wizard from the tree. * out any not enabled or filtered wizard from the tree.
*/ */
private class NewConnectionWizardStateFilter extends ViewerFilter { private class NewConnectionWizardStateFilter extends ViewerFilter {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/ */
@ -92,18 +94,18 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
if (children.length > 0) { if (children.length > 0) {
return filter(viewer, element, children).length > 0; return filter(viewer, element, children).length > 0;
} }
if (element instanceof RSENewConnectionWizardSelectionTreeElement) { if (element instanceof RSENewConnectionWizardSelectionTreeElement) {
// the system type must be enabled, otherwise it is filtered out // the system type must be enabled, otherwise it is filtered out
IRSESystemType systemType = ((RSENewConnectionWizardSelectionTreeElement)element).getSystemType(); IRSESystemType systemType = ((RSENewConnectionWizardSelectionTreeElement)element).getSystemType();
if (systemType == null) return false; if (systemType == null) return false;
// if the page is restricted to a set of system types, check on them first // if the page is restricted to a set of system types, check on them first
IRSESystemType[] restricted = getRestrictToSystemTypes(); IRSESystemType[] restricted = getRestrictToSystemTypes();
if (restricted != null && restricted.length > 0) { if (restricted != null && restricted.length > 0) {
if (!Arrays.asList(restricted).contains(systemType)) return false; if (!Arrays.asList(restricted).contains(systemType)) return false;
} }
// First, adapt the system type to a viewer filter and pass on the select request // First, adapt the system type to a viewer filter and pass on the select request
// to the viewer filter adapter if available // to the viewer filter adapter if available
ViewerFilter filter = (ViewerFilter)(systemType.getAdapter(ViewerFilter.class)); ViewerFilter filter = (ViewerFilter)(systemType.getAdapter(ViewerFilter.class));
@ -114,19 +116,19 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
// Second, double check if the system type passed the viewer filter but is disabled. // Second, double check if the system type passed the viewer filter but is disabled.
if (!systemType.isEnabled()) return false; if (!systemType.isEnabled()) return false;
} }
// In all other cases, the element passes the filter // In all other cases, the element passes the filter
return true; return true;
} }
} }
/** /**
* Internal class. The wizard viewer comparator is responsible for * Internal class. The wizard viewer comparator is responsible for
* the sorting in the tree. Current implementation is not prioritizing * the sorting in the tree. Current implementation is not prioritizing
* categories. * categories.
*/ */
private class NewConnectionWizardViewerComparator extends ViewerComparator { private class NewConnectionWizardViewerComparator extends ViewerComparator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object, java.lang.String) * @see org.eclipse.jface.viewers.ViewerComparator#isSorterProperty(java.lang.Object, java.lang.String)
*/ */
@ -135,28 +137,41 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
return property.equals(IBasicPropertyConstants.P_TEXT); return property.equals(IBasicPropertyConstants.P_TEXT);
} }
} }
/** /**
* Constructor. * Constructor.
* @since org.eclipse.rse.ui 3.0
*/ */
public RSENewConnectionWizardSelectionPage() { public RSENewConnectionWizardSelectionPage(RSENewConnectionWizardRegistry wizardRegistry) {
super("RSENewConnectionWizardSelectionPage"); //$NON-NLS-1$ super("RSENewConnectionWizardSelectionPage"); //$NON-NLS-1$
setTitle(getDefaultTitle()); setTitle(getDefaultTitle());
setDescription(getDefaultDescription()); setDescription(getDefaultDescription());
this.wizardRegistry = wizardRegistry;
}
/**
* Constructor.
*
* @deprecated Use
* {@link #RSENewConnectionWizardSelectionPage(RSENewConnectionWizardRegistry)}
* to control the lifetime of the wizard registry
*/
public RSENewConnectionWizardSelectionPage() {
this(RSENewConnectionWizardRegistry.getInstance());
} }
/** /**
* Returns the default page title. * Returns the default page title.
* *
* @return The default page title. Must be never <code>null</code>. * @return The default page title. Must be never <code>null</code>.
*/ */
protected String getDefaultTitle() { protected String getDefaultTitle() {
return SystemResources.RESID_NEWCONN_MAIN_PAGE_TITLE; return SystemResources.RESID_NEWCONN_MAIN_PAGE_TITLE;
} }
/** /**
* Returns the default page description. * Returns the default page description.
* *
* @return The default page description. Must be never <code>null</code>. * @return The default page description. Must be never <code>null</code>.
*/ */
protected String getDefaultDescription() { protected String getDefaultDescription() {
@ -165,16 +180,16 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
/** /**
* Restrict the selectable wizards to the given set of system types. * Restrict the selectable wizards to the given set of system types.
* *
* @param systemTypes The list of the system types to restrict the page to or <code>null</code>. * @param systemTypes The list of the system types to restrict the page to or <code>null</code>.
*/ */
public void restrictToSystemTypes(IRSESystemType[] systemTypes) { public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
this.restrictedSystemTypes = systemTypes; this.restrictedSystemTypes = systemTypes;
} }
/** /**
* Returns the list of system types the page is restricted to. * Returns the list of system types the page is restricted to.
* *
* @return The list of system types the page is restricted to or <code>null</code>. * @return The list of system types the page is restricted to or <code>null</code>.
*/ */
public IRSESystemType[] getRestrictToSystemTypes() { public IRSESystemType[] getRestrictToSystemTypes() {
@ -188,22 +203,22 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout()); composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 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));
filteredTreeFilter = new RSEWizardSelectionTreePatternFilter(); Label label = new Label(composite, SWT.NONE);
filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter); 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);
filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
GridData layoutData = new GridData(GridData.FILL_BOTH); GridData layoutData = new GridData(GridData.FILL_BOTH);
layoutData.heightHint = 325; layoutData.widthHint = 450; layoutData.heightHint = 325; layoutData.widthHint = 450;
filteredTree.setLayoutData(layoutData); filteredTree.setLayoutData(layoutData);
final TreeViewer treeViewer = filteredTree.getViewer(); final TreeViewer treeViewer = filteredTree.getViewer();
treeViewer.setContentProvider(new RSEWizardSelectionTreeContentProvider()); treeViewer.setContentProvider(new RSEWizardSelectionTreeContentProvider());
// Explicitly allow the tree items to get decorated!!! // Explicitly allow the tree items to get decorated!!!
treeViewer.setLabelProvider(new DecoratingLabelProvider(new RSEWizardSelectionTreeLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); treeViewer.setLabelProvider(new DecoratingLabelProvider(new RSEWizardSelectionTreeLabelProvider(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
treeViewer.setComparator(new NewConnectionWizardViewerComparator()); treeViewer.setComparator(new NewConnectionWizardViewerComparator());
@ -234,19 +249,19 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
} }
} }
}); });
filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager(); filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager(wizardRegistry);
treeViewer.setInput(filteredTreeDataManager); treeViewer.setInput(filteredTreeDataManager);
// apply the standard dialog font // apply the standard dialog font
Dialog.applyDialogFont(composite); Dialog.applyDialogFont(composite);
setControl(composite); setControl(composite);
// Restore the expanded state of the category items within the tree // Restore the expanded state of the category items within the tree
// before initializing the selection. // before initializing the selection.
restoreWidgetValues(); restoreWidgetValues();
// Initialize the selection in the tree // Initialize the selection in the tree
if (getWizard() instanceof ISelectionProvider) { if (getWizard() instanceof ISelectionProvider) {
ISelectionProvider selectionProvider = (ISelectionProvider)getWizard(); ISelectionProvider selectionProvider = (ISelectionProvider)getWizard();
@ -259,10 +274,10 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
} }
} }
} }
// we put the initial focus into the filter field // we put the initial focus into the filter field
filteredTree.getFilterControl().setFocus(); filteredTree.getFilterControl().setFocus();
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId);
} }
@ -288,7 +303,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
selectionProvider.setSelection(null); selectionProvider.setSelection(null);
} }
} }
// Update the wizard container UI elements // Update the wizard container UI elements
IWizardContainer container = getContainer(); IWizardContainer container = getContainer();
if (container != null && container.getCurrentPage() != null) { if (container != null && container.getCurrentPage() != null) {
@ -313,7 +328,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
return settings; return settings;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
*/ */
@ -338,36 +353,36 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
for (int i = 0; i < expandedCategories.length; i++) { for (int i = 0; i < expandedCategories.length; i++) {
String categoryId = expandedCategories[i]; String categoryId = expandedCategories[i];
if (categoryId != null && !"".equals(categoryId.trim())) { //$NON-NLS-1$ if (categoryId != null && !"".equals(categoryId.trim())) { //$NON-NLS-1$
IRSEWizardRegistryElement registryElement = RSENewConnectionWizardRegistry.getInstance().findElementById(categoryId); IRSEWizardRegistryElement registryElement = wizardRegistry.findElementById(categoryId);
if (registryElement instanceof IRSEWizardCategory) { if (registryElement instanceof IRSEWizardCategory) {
RSEWizardSelectionTreeElement treeElement = filteredTreeDataManager.getTreeElementForCategory((IRSEWizardCategory)registryElement); RSEWizardSelectionTreeElement treeElement = filteredTreeDataManager.getTreeElementForCategory((IRSEWizardCategory)registryElement);
if (treeElement != null) expanded.add(treeElement); if (treeElement != null) expanded.add(treeElement);
} }
} }
} }
if (expanded.size() > 0) filteredTree.getViewer().setExpandedElements(expanded.toArray()); if (expanded.size() > 0) filteredTree.getViewer().setExpandedElements(expanded.toArray());
} }
} }
} }
/** /**
* Saves the tree state to the dialog settings. * Saves the tree state to the dialog settings.
*/ */
public void saveWidgetValues() { public void saveWidgetValues() {
IDialogSettings settings = getDialogSettings(); IDialogSettings settings = getDialogSettings();
if (settings != null) { if (settings != null) {
List expandedCategories = new ArrayList(); List expandedCategories = new ArrayList();
Object[] expanded = filteredTree.getViewer().getVisibleExpandedElements(); Object[] expanded = filteredTree.getViewer().getVisibleExpandedElements();
for (int i = 0; i < expanded.length; i++) { for (int i = 0; i < expanded.length; i++) {
if (expanded[i] instanceof RSEWizardSelectionTreeElement) { if (expanded[i] instanceof RSEWizardSelectionTreeElement) {
IRSEWizardRegistryElement registryElement = ((RSEWizardSelectionTreeElement)expanded[i]).getWizardRegistryElement(); IRSEWizardRegistryElement registryElement = ((RSEWizardSelectionTreeElement)expanded[i]).getWizardRegistryElement();
if (registryElement instanceof IRSEWizardCategory) { if (registryElement instanceof IRSEWizardCategory) {
expandedCategories.add(((IRSEWizardCategory)registryElement).getId()); expandedCategories.add(((IRSEWizardCategory)registryElement).getId());
} }
} }
} }
settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, (String[])expandedCategories.toArray(new String[expandedCategories.size()])); settings.put(EXPANDED_CATEGORIES_SETTINGS_ID, (String[])expandedCategories.toArray(new String[expandedCategories.size()]));
} }
} }
} }

View file

@ -1,13 +1,14 @@
/******************************************************************************* /*******************************************************************************
* 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Uwe Stieber (Wind River) - initial API and implementation. * Uwe Stieber (Wind River) - initial API and implementation.
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * 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; package org.eclipse.rse.ui.wizards.newconnection;
@ -31,21 +32,33 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
// into RSENewConnectionWizardSelectionTreeElement object instances as the tree // into RSENewConnectionWizardSelectionTreeElement object instances as the tree
// and the wizard using these different object instances in their selections! // and the wizard using these different object instances in their selections!
private Map elementMap; private Map elementMap;
// The category map is doing the same as the element but for categories. // The category map is doing the same as the element but for categories.
private Map categoryMap; private Map categoryMap;
/** /**
* Constructor. * 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() { public RSENewConnectionWizardSelectionTreeDataManager() {
super(); this(RSENewConnectionWizardRegistry.getInstance());
} }
/** /**
* Returns the corresponding wizard selection tree element for the specified * Returns the corresponding wizard selection tree element for the specified
* system type. * system type.
* *
* @param systemType The system type. Must be not <code>null</code>. * @param systemType The system type. Must be not <code>null</code>.
* @return The wizard selection tree element or <code>null</code>. * @return The wizard selection tree element or <code>null</code>.
*/ */
@ -53,10 +66,10 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
assert systemType != null; assert systemType != null;
return (RSENewConnectionWizardSelectionTreeElement)elementMap.get(systemType); return (RSENewConnectionWizardSelectionTreeElement)elementMap.get(systemType);
} }
/** /**
* Returns the corresponding wizard selection tree element for the specified category. * Returns the corresponding wizard selection tree element for the specified category.
* *
* @param category The category. Must be not <code>null</code>. * @param category The category. Must be not <code>null</code>.
* @return The wizard selection tree element or <code>null</code>. * @return The wizard selection tree element or <code>null</code>.
*/ */
@ -64,7 +77,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
assert category != null; assert category != null;
return (RSEWizardSelectionTreeElement)categoryMap.get(category); return (RSEWizardSelectionTreeElement)categoryMap.get(category);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEAbstractWizardSelectionTreeDataManager#initialize(java.util.Set) * @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEAbstractWizardSelectionTreeDataManager#initialize(java.util.Set)
*/ */
@ -74,17 +87,17 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
// from the base classes constructor! // from the base classes constructor!
if (elementMap == null) elementMap = new HashMap(); if (elementMap == null) elementMap = new HashMap();
elementMap.clear(); elementMap.clear();
if (categoryMap == null) categoryMap = new HashMap(); if (categoryMap == null) categoryMap = new HashMap();
categoryMap.clear(); categoryMap.clear();
// The new connection wizard selection is combining system types // The new connection wizard selection is combining system types
// with registered new connection wizard. // with registered new connection wizard.
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes(); IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) { for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType systemType = systemTypes[i]; IRSESystemType systemType = systemTypes[i];
// for the system type, lookup the corresponding wizard descriptor // for the system type, lookup the corresponding wizard descriptor
IRSENewConnectionWizardDescriptor descriptor = RSENewConnectionWizardRegistry.getInstance().getWizardForSystemType(systemType); IRSENewConnectionWizardDescriptor descriptor = ((RSENewConnectionWizardRegistry)getWizardRegistry()).getWizardForSystemType(systemType);
if (descriptor == null) { if (descriptor == null) {
// a system type without even the default RSE new connection wizard associated // 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. // is bad and should never happen. Drop a warning and skip the system type.
@ -92,19 +105,19 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
RSEUIPlugin.getDefault().getLogger().logWarning(message); RSEUIPlugin.getDefault().getLogger().logWarning(message);
continue; continue;
} }
// ok, we have wizard for the current system type. Create the wizard selection tree element // ok, we have wizard for the current system type. Create the wizard selection tree element
// and categorise the wizard. // and categorise the wizard.
RSENewConnectionWizardSelectionTreeElement wizardElement = new RSENewConnectionWizardSelectionTreeElement(systemType, descriptor); RSENewConnectionWizardSelectionTreeElement wizardElement = new RSENewConnectionWizardSelectionTreeElement(systemType, descriptor);
wizardElement.setParentElement(null); wizardElement.setParentElement(null);
elementMap.put(systemType, wizardElement); elementMap.put(systemType, wizardElement);
String categoryId = descriptor.getCategoryId(); String categoryId = descriptor.getCategoryId();
// if the wizard is of type IRSEDynamicNewConnectionWizard, call validateCategoryId! // if the wizard is of type IRSEDynamicNewConnectionWizard, call validateCategoryId!
if (descriptor.getWizard() instanceof IRSEDynamicNewConnectionWizard) { if (descriptor.getWizard() instanceof IRSEDynamicNewConnectionWizard) {
categoryId = ((IRSEDynamicNewConnectionWizard)descriptor.getWizard()).validateCategoryId(systemType, categoryId); categoryId = ((IRSEDynamicNewConnectionWizard)descriptor.getWizard()).validateCategoryId(systemType, categoryId);
} }
// if the category id is null, the wizard will be sorted in as root element // if the category id is null, the wizard will be sorted in as root element
if (categoryId == null) { if (categoryId == null) {
rootElement.add(wizardElement); rootElement.add(wizardElement);
@ -112,14 +125,14 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
} }
// get the category. If failing, the wizard will end up as root element // 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)) { if (!(candidate instanceof IRSEWizardCategory)) {
rootElement.add(wizardElement); rootElement.add(wizardElement);
continue; continue;
} }
IRSEWizardCategory category = (IRSEWizardCategory)candidate; IRSEWizardCategory category = (IRSEWizardCategory)candidate;
// if the category id is not null, check if we have accessed the category // if the category id is not null, check if we have accessed the category
// already once. // already once.
RSEWizardSelectionTreeElement categoryElement = (RSEWizardSelectionTreeElement)categoryMap.get(category); RSEWizardSelectionTreeElement categoryElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
@ -130,23 +143,23 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
} }
categoryElement.add(wizardElement); categoryElement.add(wizardElement);
wizardElement.setParentElement(categoryElement); wizardElement.setParentElement(categoryElement);
// The category itself does not have a parent category, the category is a root element // The category itself does not have a parent category, the category is a root element
String parentCategoryId = category.getParentCategoryId(); String parentCategoryId = category.getParentCategoryId();
if (parentCategoryId == null) { if (parentCategoryId == null) {
rootElement.add(categoryElement); rootElement.add(categoryElement);
continue; continue;
} }
while (parentCategoryId != null) { while (parentCategoryId != null) {
candidate = RSENewConnectionWizardRegistry.getInstance().findElementById(parentCategoryId); candidate = getWizardRegistry().findElementById(parentCategoryId);
if (!(candidate instanceof IRSEWizardCategory)) { if (!(candidate instanceof IRSEWizardCategory)) {
rootElement.add(categoryElement); rootElement.add(categoryElement);
break; break;
} }
category = (IRSEWizardCategory)candidate; category = (IRSEWizardCategory)candidate;
RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryMap.get(category); RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
if (parentElement == null) { if (parentElement == null) {
parentElement = new RSEWizardSelectionTreeElement(category); parentElement = new RSEWizardSelectionTreeElement(category);
@ -155,7 +168,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
} }
parentElement.add(categoryElement); parentElement.add(categoryElement);
categoryElement.setParentElement(parentElement); categoryElement.setParentElement(parentElement);
categoryElement = parentElement; categoryElement = parentElement;
parentCategoryId = category.getParentCategoryId(); parentCategoryId = category.getParentCategoryId();
} }

View file

@ -1,12 +1,13 @@
/******************************************************************************* /*******************************************************************************
* 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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Uwe Stieber (Wind River) - initial API and implementation. * 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; package org.eclipse.rse.ui.wizards.registries;
@ -19,20 +20,46 @@ import java.util.Set;
*/ */
public abstract class RSEAbstractWizardSelectionTreeDataManager { public abstract class RSEAbstractWizardSelectionTreeDataManager {
private final Set rootElement = new HashSet(); private final Set rootElement = new HashSet();
private RSEAbstractWizardRegistry wizardRegistry;
/** /**
* Constructor. * Constructor.
* @since org.eclipse.rse.ui 3.0
*/ */
public RSEAbstractWizardSelectionTreeDataManager() { public RSEAbstractWizardSelectionTreeDataManager(RSEAbstractWizardRegistry wizardRegistry) {
this.wizardRegistry = wizardRegistry;
rootElement.clear(); rootElement.clear();
// start the initialization of the data tree. // start the initialization of the data tree.
initialize(rootElement); 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. * Returns the children of this wizard selection tree element.
* *
* @return The list of children, May be empty but never <code>null</code>. * @return The list of children, May be empty but never <code>null</code>.
*/ */
public RSEWizardSelectionTreeElement[] getChildren() { public RSEWizardSelectionTreeElement[] getChildren() {
@ -41,7 +68,7 @@ public abstract class RSEAbstractWizardSelectionTreeDataManager {
/** /**
* Initialize the data tree. * Initialize the data tree.
* *
* @param rootElement The root element which is the container for all user visible tree root elements. Must be not <code>null</code>. * @param rootElement The root element which is the container for all user visible tree root elements. Must be not <code>null</code>.
*/ */
protected abstract void initialize(Set rootElement); protected abstract void initialize(Set rootElement);