mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 07:35:24 +02:00
[235197][api] Unusable wizard after cancelling on first page
This commit is contained in:
parent
9e2fc1d12d
commit
9f90db5b93
5 changed files with 222 additions and 144 deletions
|
@ -7,16 +7,17 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Javier Montalvo Orús (Symbian) - Bug 158555 - newConnectionWizardDelegates can only be used once
|
||||
* 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
|
||||
* 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;
|
||||
|
@ -49,7 +50,7 @@ import org.eclipse.ui.IWorkbench;
|
|||
|
||||
/**
|
||||
* The New Connection wizard. This wizard allows users to create new RSE connections.
|
||||
*
|
||||
*
|
||||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public static final String LAST_SELECTED_SYSTEM_TYPE_ID = "lastSelectedSystemTypeId"; //$NON-NLS-1$
|
||||
|
||||
|
||||
// The selected context as passed in from the invoking class.
|
||||
// Just pass on to the wizards. Do not interpret here!
|
||||
// @see #setSelectedContext(ISelection).
|
||||
|
@ -65,18 +66,19 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
// The connection context as determined from the invoking class
|
||||
// @see #setConnectionContext(IHost)
|
||||
private IHost connectionContext;
|
||||
|
||||
|
||||
private RSENewConnectionWizardRegistry wizardRegistry;
|
||||
private IWizard selectedWizard;
|
||||
private IRSESystemType selectedSystemType;
|
||||
private boolean selectedWizardCanFinishEarly;
|
||||
|
||||
|
||||
private RSENewConnectionWizardSelectionPage mainPage;
|
||||
private final List initializedWizards = new LinkedList();
|
||||
private final List selectionChangedListener = new LinkedList();
|
||||
|
||||
|
||||
private IRSESystemType[] restrictedSystemTypes;
|
||||
private boolean onlySystemType;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
@ -91,10 +93,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
String sectionName = this.getClass().getName();
|
||||
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();
|
||||
}
|
||||
|
@ -104,7 +107,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
*/
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
|
||||
selectedContext = null;
|
||||
selectedSystemType = null;
|
||||
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
|
||||
* the wizard.
|
||||
*
|
||||
*
|
||||
* @param systemType the system type to restrict to.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @param systemTypes the system types to restrict to.
|
||||
*/
|
||||
public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
|
||||
assert systemTypes != null;
|
||||
|
||||
|
||||
restrictedSystemTypes = systemTypes;
|
||||
onlySystemType = restrictedSystemTypes.length == 1;
|
||||
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
|
||||
* one system type.
|
||||
*
|
||||
*
|
||||
* @return <code>True</code> if the wizard is restricted to only one system type, <code>false</code> otherwise.
|
||||
*/
|
||||
public final boolean isRestrictedToSingleSystemType() {
|
||||
return onlySystemType;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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() {
|
||||
if (getSelection() == null) return;
|
||||
|
||||
|
||||
SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
|
||||
Iterator iterator = selectionChangedListener.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -185,7 +188,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
listener.selectionChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
|
||||
*/
|
||||
|
@ -203,11 +206,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
if (selectedContext != null) {
|
||||
selectionElements.add(selectedContext);
|
||||
}
|
||||
|
||||
|
||||
// construct the selection now
|
||||
selection = new StructuredSelection(selectionElements);
|
||||
}
|
||||
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
|
@ -223,7 +226,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
} else {
|
||||
selectedSystemType = null;
|
||||
}
|
||||
|
||||
|
||||
// signal the system type change
|
||||
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
|
||||
* of this method. The selected context is not interpreted by the main wizard,
|
||||
* the selection is passed on as is to the nested wizards.
|
||||
*
|
||||
*
|
||||
* @param selectedContext The selected context or <code>null</code>.
|
||||
*/
|
||||
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>
|
||||
* setSelection(...)</code> to apply the system type as the selected
|
||||
* one.
|
||||
*
|
||||
*
|
||||
* @param connectionContext The connection context or <code>null</code>.
|
||||
*/
|
||||
public void setConnectionContext(IHost connectionContext) {
|
||||
|
@ -259,7 +262,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
if (systemType != null) setSelection(new StructuredSelection(systemType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* @return The wizard for the currently selected system type. Must be never <code>null</code>.
|
||||
*/
|
||||
public IWizard getSelectedWizard() {
|
||||
|
@ -284,9 +287,11 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
protected void onSelectedSystemTypeChanged() {
|
||||
// unregister the previous selected wizard as selection changed listener
|
||||
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();
|
||||
|
@ -294,7 +299,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
selectedWizard = null;
|
||||
selectedWizardCanFinishEarly = false;
|
||||
}
|
||||
|
||||
|
||||
// Check on the container association of the selected wizard.
|
||||
if (getContainer() != null && selectedWizard != null && !getContainer().equals(selectedWizard.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
|
||||
// main wizards window title.
|
||||
if (selectedWizard instanceof Wizard
|
||||
if (selectedWizard instanceof Wizard
|
||||
&& (selectedWizard.getWindowTitle() == null || "".equals(selectedWizard.getWindowTitle()))) { //$NON-NLS-1$
|
||||
((Wizard)selectedWizard).setWindowTitle(getWindowTitle());
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
// default RSE new connection wizard.
|
||||
if (selectedWizard instanceof RSEDefaultNewConnectionWizard) {
|
||||
((RSEDefaultNewConnectionWizard)selectedWizard).setSelectedContext(connectionContext);
|
||||
}
|
||||
|
||||
|
||||
// register the newly selected wizard as selection changed listener
|
||||
if (selectedWizard instanceof ISelectionChangedListener) {
|
||||
addSelectionChangedListener((ISelectionChangedListener)selectedWizard);
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
// 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();
|
||||
if (getSelectedWizard() != null) nextPage = getSelectedWizard().getStartingPage();
|
||||
}
|
||||
|
||||
|
||||
if (nextPage == null) super.getNextPage(page);
|
||||
if (nextPage != null) nextPage.setPreviousPage(page);
|
||||
|
||||
|
||||
return nextPage;
|
||||
}
|
||||
|
||||
|
@ -375,16 +380,16 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
// wizard can finish early
|
||||
return selectedWizardCanFinishEarly;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#performFinish()
|
||||
*/
|
||||
public boolean performFinish() {
|
||||
// Save the current selection to the dialog settings
|
||||
saveWidgetValues();
|
||||
|
||||
|
||||
if (mainPage != null) mainPage.saveWidgetValues();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -402,7 +407,7 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore the persistent saved wizard state. This method
|
||||
* is called from the wizards constructor.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* 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;
|
||||
|
@ -67,23 +68,24 @@ import org.eclipse.ui.dialogs.PatternFilter;
|
|||
*/
|
||||
public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
||||
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[] DEFAULT_EXPANDED_CATEGORY_IDS = new String[] { "org.eclipse.rse.ui.wizards.newconnection.default.category" }; //$NON-NLS-1$
|
||||
|
||||
|
||||
private IRSESystemType[] restrictedSystemTypes;
|
||||
|
||||
private RSENewConnectionWizardRegistry wizardRegistry;
|
||||
private FilteredTree filteredTree;
|
||||
private PatternFilter filteredTreeFilter;
|
||||
private ViewerFilter filteredTreeWizardStateFilter;
|
||||
private RSENewConnectionWizardSelectionTreeDataManager filteredTreeDataManager;
|
||||
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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) {
|
||||
return filter(viewer, element, children).length > 0;
|
||||
}
|
||||
|
||||
|
||||
if (element instanceof RSENewConnectionWizardSelectionTreeElement) {
|
||||
// the system type must be enabled, otherwise it is filtered out
|
||||
IRSESystemType systemType = ((RSENewConnectionWizardSelectionTreeElement)element).getSystemType();
|
||||
if (systemType == null) return false;
|
||||
|
||||
|
||||
// if the page is restricted to a set of system types, check on them first
|
||||
IRSESystemType[] restricted = getRestrictToSystemTypes();
|
||||
if (restricted != null && restricted.length > 0) {
|
||||
if (!Arrays.asList(restricted).contains(systemType)) return false;
|
||||
}
|
||||
|
||||
|
||||
// First, adapt the system type to a viewer filter and pass on the select request
|
||||
// to the viewer filter adapter if available
|
||||
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.
|
||||
if (!systemType.isEnabled()) return false;
|
||||
}
|
||||
|
||||
|
||||
// In all other cases, the element passes the filter
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internal class. The wizard viewer comparator is responsible for
|
||||
* the sorting in the tree. Current implementation is not prioritizing
|
||||
* categories.
|
||||
*/
|
||||
private class NewConnectionWizardViewerComparator extends ViewerComparator {
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default page title.
|
||||
*
|
||||
*
|
||||
* @return The default page title. Must be never <code>null</code>.
|
||||
*/
|
||||
protected String getDefaultTitle() {
|
||||
return SystemResources.RESID_NEWCONN_MAIN_PAGE_TITLE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the default page description.
|
||||
*
|
||||
*
|
||||
* @return The default page description. Must be never <code>null</code>.
|
||||
*/
|
||||
protected String getDefaultDescription() {
|
||||
|
@ -165,16 +180,16 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
|
||||
/**
|
||||
* 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>.
|
||||
*/
|
||||
public void restrictToSystemTypes(IRSESystemType[] systemTypes) {
|
||||
this.restrictedSystemTypes = systemTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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>.
|
||||
*/
|
||||
public IRSESystemType[] getRestrictToSystemTypes() {
|
||||
|
@ -188,22 +203,22 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
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));
|
||||
|
||||
filteredTreeFilter = new RSEWizardSelectionTreePatternFilter();
|
||||
filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter);
|
||||
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);
|
||||
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());
|
||||
|
||||
|
@ -234,19 +249,19 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager();
|
||||
|
||||
filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager(wizardRegistry);
|
||||
treeViewer.setInput(filteredTreeDataManager);
|
||||
|
||||
|
||||
// apply the standard dialog font
|
||||
Dialog.applyDialogFont(composite);
|
||||
|
||||
|
||||
setControl(composite);
|
||||
|
||||
|
||||
// Restore the expanded state of the category items within the tree
|
||||
// before initializing the selection.
|
||||
restoreWidgetValues();
|
||||
|
||||
|
||||
// Initialize the selection in the tree
|
||||
if (getWizard() instanceof ISelectionProvider) {
|
||||
ISelectionProvider selectionProvider = (ISelectionProvider)getWizard();
|
||||
|
@ -259,10 +274,10 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// we put the initial focus into the filter field
|
||||
filteredTree.getFilterControl().setFocus();
|
||||
|
||||
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpId);
|
||||
|
||||
}
|
||||
|
@ -288,7 +303,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
selectionProvider.setSelection(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the wizard container UI elements
|
||||
IWizardContainer container = getContainer();
|
||||
if (container != null && container.getCurrentPage() != null) {
|
||||
|
@ -313,7 +328,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
|
|||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (expanded.size() > 0) filteredTree.getViewer().setExpandedElements(expanded.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the tree state to the dialog settings.
|
||||
*/
|
||||
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()]));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
@ -31,21 +32,33 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
|
|||
// into RSENewConnectionWizardSelectionTreeElement object instances as the tree
|
||||
// and the wizard using these different object instances in their selections!
|
||||
private Map elementMap;
|
||||
|
||||
|
||||
// The category map is doing the same as the element but for categories.
|
||||
private Map categoryMap;
|
||||
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding wizard selection tree element for the specified
|
||||
* system type.
|
||||
*
|
||||
*
|
||||
* @param systemType The system type. Must be not <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;
|
||||
return (RSENewConnectionWizardSelectionTreeElement)elementMap.get(systemType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the corresponding wizard selection tree element for the specified category.
|
||||
*
|
||||
*
|
||||
* @param category The category. Must be not <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;
|
||||
return (RSEWizardSelectionTreeElement)categoryMap.get(category);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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!
|
||||
if (elementMap == null) elementMap = new HashMap();
|
||||
elementMap.clear();
|
||||
|
||||
|
||||
if (categoryMap == null) categoryMap = new HashMap();
|
||||
categoryMap.clear();
|
||||
|
||||
|
||||
// The new connection wizard selection is combining system types
|
||||
// with registered new connection wizard.
|
||||
IRSESystemType[] systemTypes = RSECorePlugin.getTheCoreRegistry().getSystemTypes();
|
||||
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.
|
||||
|
@ -92,19 +105,19 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
|
|||
RSEUIPlugin.getDefault().getLogger().logWarning(message);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// ok, we have wizard for the current system type. Create the wizard selection tree element
|
||||
// and categorise the wizard.
|
||||
RSENewConnectionWizardSelectionTreeElement wizardElement = new RSENewConnectionWizardSelectionTreeElement(systemType, descriptor);
|
||||
wizardElement.setParentElement(null);
|
||||
elementMap.put(systemType, wizardElement);
|
||||
|
||||
|
||||
String categoryId = descriptor.getCategoryId();
|
||||
// if the wizard is of type IRSEDynamicNewConnectionWizard, call validateCategoryId!
|
||||
if (descriptor.getWizard() instanceof IRSEDynamicNewConnectionWizard) {
|
||||
categoryId = ((IRSEDynamicNewConnectionWizard)descriptor.getWizard()).validateCategoryId(systemType, categoryId);
|
||||
}
|
||||
|
||||
|
||||
// if the category id is null, the wizard will be sorted in as root element
|
||||
if (categoryId == null) {
|
||||
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
|
||||
IRSEWizardRegistryElement candidate = RSENewConnectionWizardRegistry.getInstance().findElementById(categoryId);
|
||||
IRSEWizardRegistryElement candidate = getWizardRegistry().findElementById(categoryId);
|
||||
if (!(candidate instanceof IRSEWizardCategory)) {
|
||||
rootElement.add(wizardElement);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
IRSEWizardCategory category = (IRSEWizardCategory)candidate;
|
||||
|
||||
|
||||
// if the category id is not null, check if we have accessed the category
|
||||
// already once.
|
||||
RSEWizardSelectionTreeElement categoryElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
|
||||
|
@ -130,23 +143,23 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
|
|||
}
|
||||
categoryElement.add(wizardElement);
|
||||
wizardElement.setParentElement(categoryElement);
|
||||
|
||||
|
||||
// The category itself does not have a parent category, the category is a root element
|
||||
String parentCategoryId = category.getParentCategoryId();
|
||||
if (parentCategoryId == null) {
|
||||
rootElement.add(categoryElement);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
while (parentCategoryId != null) {
|
||||
candidate = RSENewConnectionWizardRegistry.getInstance().findElementById(parentCategoryId);
|
||||
candidate = getWizardRegistry().findElementById(parentCategoryId);
|
||||
if (!(candidate instanceof IRSEWizardCategory)) {
|
||||
rootElement.add(categoryElement);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
category = (IRSEWizardCategory)candidate;
|
||||
|
||||
|
||||
RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryMap.get(category);
|
||||
if (parentElement == null) {
|
||||
parentElement = new RSEWizardSelectionTreeElement(category);
|
||||
|
@ -155,7 +168,7 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
|
|||
}
|
||||
parentElement.add(categoryElement);
|
||||
categoryElement.setParentElement(parentElement);
|
||||
|
||||
|
||||
categoryElement = parentElement;
|
||||
parentCategoryId = category.getParentCategoryId();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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,20 +20,46 @@ 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.
|
||||
*
|
||||
*
|
||||
* @return The list of children, May be empty but never <code>null</code>.
|
||||
*/
|
||||
public RSEWizardSelectionTreeElement[] getChildren() {
|
||||
|
@ -41,7 +68,7 @@ public abstract class RSEAbstractWizardSelectionTreeDataManager {
|
|||
|
||||
/**
|
||||
* 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>.
|
||||
*/
|
||||
protected abstract void initialize(Set rootElement);
|
||||
|
|
Loading…
Add table
Reference in a new issue