1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[173772] bug fixings and related cleanups

This commit is contained in:
Uwe Stieber 2007-02-20 09:04:47 +00:00
parent ae03da8d1c
commit e6c3895d55
15 changed files with 410 additions and 261 deletions

View file

@ -29,20 +29,26 @@ public interface IRSECoreRegistry {
/**
* Returns all defined system types.
*
* @return an array of all defined system types.
*/
public IRSESystemType[] getSystemTypes();
/**
* Returns the names of all defined system types.
* @return all defined system type names
*/
public String[] getSystemTypeNames();
/**
* Returns a system type object given the name.
*
* @param name the name of the system type
* @return the system type object with the given name, or <code>null</code> if none is found
*
* @deprecated Use {@link #getSystemTypeById(String)}.
*/
public IRSESystemType getSystemType(String name);
/**
* Returns a system type object given by the id.
*
* @param systemTypeId The system type id.
* @return The system type object with the given id, or <code>null</code> if none is found
*/
public IRSESystemType getSystemTypeById(String systemTypeId);
}

View file

@ -77,8 +77,7 @@ public class RSECoreRegistry implements IRSECoreRegistry {
return instance;
}
/**
* Returns all system types that have been defined.
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSECoreRegistry#getSystemTypes()
*/
public IRSESystemType[] getSystemTypes() {
@ -91,12 +90,25 @@ public class RSECoreRegistry implements IRSECoreRegistry {
return systemTypes;
}
/**
* Returns the system type with the given name.
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSECoreRegistry#getSystemTypeById(java.lang.String)
*/
public IRSESystemType getSystemTypeById(String systemTypeId) {
if (systemTypeId != null) {
IRSESystemType[] types = getSystemTypes();
for (int i = 0; i < types.length; i++) {
if (types[i].getId().equals(systemTypeId)) {
return types[i];
}
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.rse.core.IRSECoreRegistry#getSystemType(java.lang.String)
*/
public IRSESystemType getSystemType(String name) {
IRSESystemType[] types = getSystemTypes();
for (int i = 0; i < types.length; i++) {
@ -110,21 +122,6 @@ public class RSECoreRegistry implements IRSECoreRegistry {
return null;
}
/**
* @see org.eclipse.rse.core.IRSECoreRegistry#getSystemTypeNames()
*/
public String[] getSystemTypeNames() {
IRSESystemType[] types = getSystemTypes();
String[] names = new String[types.length];
for (int i = 0; i < types.length; i++) {
IRSESystemType type = types[i];
names[i] = type.getName();
}
return names;
}
/**
* Reads system types from the extension point registry and returns the defined system types.
* @return an array of system types that have been defined

View file

@ -20,6 +20,7 @@ import java.util.Arrays;
import java.util.Locale;
import org.eclipse.jface.action.IAction;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemBasePlugin;
import org.eclipse.rse.core.model.IHost;
@ -772,7 +773,7 @@ public class SystemWidgetHelpers {
List list = createListBox(group, listener, false, null, SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
String[] typeItems = ((systemTypes == null) ? RSECorePlugin.getDefault().getRegistry().getSystemTypeNames() : systemTypes);
String[] typeItems = ((systemTypes == null) ? getSystemTypeNames() : systemTypes);
if (systemTypes == null) {
for (int i = 0; i < typeItems.length; i++) {
@ -1126,13 +1127,28 @@ public class SystemWidgetHelpers {
return createSystemTypeCombo(parent, listener, null);
}
private static String[] systemTypeNames = null;
/**
* Internal method. Helper to get the list of registered system type names.
*/
private static String[] getSystemTypeNames() {
if (systemTypeNames == null) {
java.util.List names = new ArrayList();
IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) names.add(systemTypes[i].getName());
systemTypeNames = (String[])names.toArray(new String[names.size()]);
}
return systemTypeNames;
}
/**
* Creates a readonly system type combination box with the given system types.
* Does NOT create the leading prompt or anything except the combo.
*/
public static Combo createSystemTypeCombo(Composite parent, Listener listener, String[] systemTypes) {
Combo combo = createReadonlyCombo(parent, listener, SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
String[] typeItems = ((systemTypes == null) ? RSECorePlugin.getDefault().getRegistry().getSystemTypeNames() : systemTypes);
String[] typeItems = ((systemTypes == null) ? getSystemTypeNames() : systemTypes);
ArrayList list = new ArrayList();

View file

@ -35,6 +35,8 @@ import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;
@ -132,18 +134,34 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction {
protected WizardDialog doCreateWizardDialog(Shell shell, IWizard wizard) {
// The new connection action is always using the standard Eclipse WizardDialog!!!
WizardDialog dialog = new WizardDialog(getShell(), wizard) {
// protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
// Rectangle bounds = super.getConstrainedShellBounds(preferredSize);
// // We allow to resize the dialog in height, but not in width
// // to more to 500 pixel.
// bounds.width = Math.min(bounds.width, 500);
// return bounds;
// }
// protected Point getInitialSize() {
// Point size = super.getInitialSize();
// size.x = 500;
// return size;
// }
private boolean computeShellSizeFromScratch = true;
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getConstrainedShellBounds(org.eclipse.swt.graphics.Rectangle)
*/
protected Rectangle getConstrainedShellBounds(Rectangle preferredSize) {
// The parent shell might have very large bounds if badly selected. We
// will recalculate the wizard dialogs shell size the first time we end
// up here. That asures that the dialog does not inherit shell bounds
// from a much larger window.
if (computeShellSizeFromScratch) {
Point newSize = getInitialSize();
Point newLoaction = getInitialLocation(newSize);
preferredSize.height = newSize.y;
preferredSize.width = newSize.x;
preferredSize.y = newLoaction.y;
preferredSize.x = newLoaction.x;
computeShellSizeFromScratch = false;
}
Rectangle bounds = super.getConstrainedShellBounds(preferredSize);
// We allow to resize the dialog in height, but not in width
// to more to 500 pixel.
bounds.width = Math.min(bounds.width, 500);
return bounds;
}
};
return dialog;

View file

@ -18,10 +18,14 @@
package org.eclipse.rse.ui.propertypages;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.rse.core.IRSEPreferenceNames;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemPreferenceChangeEvents;
import org.eclipse.rse.internal.model.SystemPreferenceChangeEvent;
@ -91,11 +95,15 @@ public class RemoteSystemsPreferencePage
{
IPreferenceStore coreStore = new PreferencesMapper(RSECorePlugin.getDefault().getPluginPreferences());
List systemTypeNames = new ArrayList();
IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) systemTypeNames.add(systemTypes[i].getName());
// DEFAULT SYSTEM TYPE
SystemComboBoxFieldEditor systemTypeEditor = new SystemComboBoxFieldEditor(
IRSEPreferenceNames.SYSTEMTYPE,
SystemResources.RESID_PREF_SYSTEMTYPE_PREFIX_LABEL,
RSECorePlugin.getDefault().getRegistry().getSystemTypeNames(),
(String[])systemTypeNames.toArray(new String[systemTypeNames.size()]),
true, // readonly
getFieldEditorParent()
);

View file

@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@ -32,6 +33,7 @@ import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources;
@ -43,8 +45,11 @@ import org.eclipse.ui.IWorkbench;
* The New Connection wizard. This wizard allows users to create new RSE connections.
*/
public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, ISelectionProvider {
protected static final String LAST_SELECTED_SYSTEM_TYPE_ID = "lastSelectedSystemTypeId"; //$NON-NLS-1$
private IWizard selectedWizard;
private IRSESystemType selectedSystemType;
private boolean selectedWizardCanFinishEarly;
private final RSENewConnectionWizardSelectionPage mainPage;
private final List initializedWizards = new LinkedList();
@ -61,12 +66,21 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
setWindowTitle(SystemResources.RESID_NEWCONN_TITLE);
setForcePreviousAndNextButtons(true);
setNeedsProgressMonitor(true);
// Initialize the dialog settings for this wizard
IDialogSettings settings = RSEUIPlugin.getDefault().getDialogSettings();
String sectionName = this.getClass().getName();
if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
setDialogSettings(settings.getSection(sectionName));
mainPage = new RSENewConnectionWizardSelectionPage();
initializedWizards.clear();
selectionChangedListener.clear();
// and finally restore the wizard state
restoreFromDialogSettings();
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#getDefaultPageImage()
*/
@ -141,8 +155,10 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
if (selection instanceof IStructuredSelection
&& ((IStructuredSelection)selection).getFirstElement() instanceof IRSESystemType) {
selectedSystemType = (IRSESystemType)((IStructuredSelection)selection).getFirstElement();
onSelectedSystemTypeChanged();
} else {
selectedSystemType = null;
}
onSelectedSystemTypeChanged();
}
/* (non-Javadoc)
@ -172,7 +188,13 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
// Check if a wizard is registered for the selected system type
IRSENewConnectionWizardDescriptor descriptor = getSelection() != null ? RSENewConnectionWizardRegistry.getInstance().getWizardForSelection((IStructuredSelection)getSelection()) : null;
selectedWizard = descriptor != null ? descriptor.getWizard() : null;
if (descriptor != null) {
selectedWizard = descriptor.getWizard();
selectedWizardCanFinishEarly = descriptor.canFinishEarly();
} else {
selectedWizard = null;
selectedWizardCanFinishEarly = false;
}
// register the newly selected wizard as selection changed listener
if (selectedWizard instanceof ISelectionChangedListener) {
@ -229,18 +251,49 @@ public class RSEMainNewConnectionWizard extends Wizard implements INewWizard, IS
return nextPage;
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
public boolean canFinish() {
// We can finish from the main new connection wizard only if the selected
// wizard can finish early
return selectedWizardCanFinishEarly;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#performFinish()
*/
public boolean performFinish() {
boolean result = true;
if (mainPage != null) result = mainPage.performFinish();
// Note: Do _NOT_ delegate the performFinish from here to the selected
// wizard!! The outer wizard dialog is handling the nested wizards by
// default already itself!!
return result;
// Save the current selection to the dialog settings
IDialogSettings dialogSettings = getDialogSettings();
if (dialogSettings != null && getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection)getSelection();
if (selection.getFirstElement() instanceof IRSESystemType) {
dialogSettings.put(LAST_SELECTED_SYSTEM_TYPE_ID, ((IRSESystemType)selection.getFirstElement()).getId());
}
}
return true;
}
}
/**
* Restore the persistent saved wizard state. This method
* is called from the wizards constructor.
*/
protected void restoreFromDialogSettings() {
IDialogSettings dialogSettings = getDialogSettings();
if (dialogSettings != null) {
String systemTypeId = dialogSettings.get(LAST_SELECTED_SYSTEM_TYPE_ID);
if (systemTypeId != null) {
IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemTypeById(systemTypeId);
if (systemType != null) {
setSelection(new StructuredSelection(systemType));
}
}
}
}
}

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.rse.ui.wizards.newconnection;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -29,8 +28,8 @@ import org.eclipse.rse.ui.wizards.registries.RSEWizardDescriptor;
public class RSENewConnectionWizardDescriptor extends RSEWizardDescriptor implements IRSENewConnectionWizardDescriptor {
private final SystemTypeMatcher systemTypeMatcher;
// The list of resolved system types supported by this wizard.
private List resolvedSystemTypes;
// The list of resolved system type ids supported by this wizard.
private List resolvedSystemTypeIds;
/**
* Constructor
@ -54,14 +53,14 @@ public class RSENewConnectionWizardDescriptor extends RSEWizardDescriptor implem
* @see org.eclipse.rse.ui.wizards.newconnection.INewConnectionWizardDescriptor#getSystemTypeIds()
*/
public String[] getSystemTypeIds() {
if (resolvedSystemTypes == null) {
resolvedSystemTypes = new LinkedList();
if (resolvedSystemTypeIds == null) {
resolvedSystemTypeIds = new LinkedList();
// If the subsystem configuration supports all system types, just add all
// currently registered system types to th resolved list
if (systemTypeMatcher.supportsAllSystemTypes()) {
String[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
if (systemTypes != null) resolvedSystemTypes.addAll(Arrays.asList(systemTypes));
IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) resolvedSystemTypeIds.add(systemTypes[i].getId());
} else {
// We have to match the given lists of system type ids against
// the list of available system types. As the list of system types cannot
@ -74,15 +73,15 @@ public class RSENewConnectionWizardDescriptor extends RSEWizardDescriptor implem
if (systemTypeMatcher.matches(systemType)
|| (adapter != null
&& adapter.acceptWizardDescriptor(getConfigurationElement().getName(), this))) {
if (!resolvedSystemTypes.contains(systemType.getId())) {
resolvedSystemTypes.add(systemType.getId());
if (!resolvedSystemTypeIds.contains(systemType.getId())) {
resolvedSystemTypeIds.add(systemType.getId());
}
}
}
}
}
return (String[])resolvedSystemTypes.toArray(new String[resolvedSystemTypes.size()]);
return (String[])resolvedSystemTypeIds.toArray(new String[resolvedSystemTypeIds.size()]);
}
}

View file

@ -14,9 +14,11 @@ package org.eclipse.rse.ui.wizards.newconnection;
import java.util.Arrays;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@ -26,8 +28,10 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.ui.RSESystemTypeAdapter;
@ -58,6 +62,10 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
private ViewerFilter filteredTreeWizardStateFilter;
private RSENewConnectionWizardSelectionTreeDataManager filteredTreeDataManager;
/**
* Internal class. The wizard state filter is responsible to filter
* out any not enabled wizard from the tree.
*/
private class NewConnectionWizardStateFilter extends ViewerFilter {
/* (non-Javadoc)
@ -91,6 +99,22 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
/**
* 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)
*/
public boolean isSorterProperty(Object element, String property) {
// The comparator is affected if the label of the elements should change.
return property.equals(IBasicPropertyConstants.P_TEXT);
}
}
/**
* Constructor.
*/
public RSENewConnectionWizardSelectionPage() {
@ -151,13 +175,15 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
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 = 275; layoutData.widthHint = 450;
filteredTree.setLayoutData(layoutData);
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(NewWizardCollectionComparator.INSTANCE);
// treeViewer.addSelectionChangedListener(this);
treeViewer.setComparator(new NewConnectionWizardViewerComparator());
treeViewer.setAutoExpandLevel(2);
filteredTreeWizardStateFilter = new NewConnectionWizardStateFilter();
@ -170,7 +196,6 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
});
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
// onSelectionChanged();
if (canFlipToNextPage()) getWizard().getContainer().showPage(getNextPage());
}
});
@ -182,6 +207,19 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
Dialog.applyDialogFont(composite);
setControl(composite);
// Initialize the selection in the tree
if (getWizard() instanceof ISelectionProvider) {
ISelectionProvider selectionProvider = (ISelectionProvider)getWizard();
if (selectionProvider.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection)selectionProvider.getSelection();
if (selection.getFirstElement() instanceof IRSESystemType) {
IRSESystemType systemType = (IRSESystemType)selection.getFirstElement();
RSENewConnectionWizardSelectionTreeElement treeElement = filteredTreeDataManager.getTreeElementForSystemType(systemType);
if (treeElement != null) treeViewer.setSelection(new StructuredSelection(treeElement), true);
}
}
}
}
/* (non-Javadoc)
@ -192,7 +230,7 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
}
/**
* Called from the selection and double-click listener to propage the current
* Called from the selection listener to propage the current
* system type selection to the underlaying wizard.
*/
protected void onSelectionChanged() {
@ -208,56 +246,33 @@ public class RSENewConnectionWizardSelectionPage extends WizardPage {
} else {
if (!getDefaultDescription().equals(getDescription())) setDescription(getDefaultDescription());
}
} else {
selectionProvider.setSelection(null);
}
}
// Update the wizard container UI elements
IWizardContainer container = getContainer();
if (container != null && container.getCurrentPage() != null) {
container.updateWindowTitle();
container.updateTitleBar();
container.updateButtons();
}
}
/**
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#createContents(org.eclipse.swt.widgets.Composite)
*/
// public Control createContents(Composite parent) {
//
// int nbrColumns = 2;
// Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns);
// SystemWidgetHelpers.setCompositeHelp(composite_prompts, parentHelpId);
//
// String temp = SystemWidgetHelpers.appendColon(SystemResources.RESID_CONNECTION_SYSTEMTYPE_LABEL);
//
// Label labelSystemType = SystemWidgetHelpers.createLabel(composite_prompts, temp);
// labelSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
//
// if (restrictedSystemTypes == null) {
// textSystemType = SystemWidgetHelpers.createSystemTypeListBox(parent, null);
// }
// else {
// String[] systemTypeNames = new String[restrictedSystemTypes.length];
//
// for (int i = 0; i < restrictedSystemTypes.length; i++) {
// systemTypeNames[i] = restrictedSystemTypes[i].getName();
// }
//
// textSystemType = SystemWidgetHelpers.createSystemTypeListBox(parent, null, systemTypeNames);
// }
//
// textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
// SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003"); //$NON-NLS-1$
//
// textSystemType.addSelectionListener(this);
//
// descriptionSystemType = SystemWidgetHelpers.createMultiLineTextField(parent,null,30);
// descriptionSystemType.setEditable(false);
//
// widgetSelected(null);
//
// return composite_prompts;
// }
/* (non-Javadoc)
* @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#performFinish()
* @see org.eclipse.jface.wizard.WizardPage#getDialogSettings()
*/
public boolean performFinish() {
return true;
protected IDialogSettings getDialogSettings() {
// If the wizard is set and returns dialog settings, we re-use them here
IDialogSettings settings = super.getDialogSettings();
// If the dialog settings could not set from the wizard, fallback to the plugins
// dialog settings store.
if (settings == null) settings = RSEUIPlugin.getDefault().getDialogSettings();
String sectionName = this.getClass().getName();
if (settings.getSection(sectionName) == null) settings.addNewSection(sectionName);
settings = settings.getSection(sectionName);
return settings;
}
}

View file

@ -26,6 +26,10 @@ import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeElement;
* New connection wizard selection tree data manager.
*/
public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractWizardSelectionTreeDataManager {
// The element map is required to translate from IRSESystemType object instance
// into RSENewConnectionWizardSelectionTreeElement object instances as the tree
// and the wizard using these different object instances in their selections!
private Map elementMap;
/**
* Constructor.
@ -34,10 +38,28 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
super();
}
/**
* 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>.
*/
public RSENewConnectionWizardSelectionTreeElement getTreeElementForSystemType(IRSESystemType systemType) {
assert systemType != null;
return (RSENewConnectionWizardSelectionTreeElement)elementMap.get(systemType);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEAbstractWizardSelectionTreeDataManager#initialize(java.util.Set)
*/
protected void initialize(Set rootElement) {
// we must check the elementMap here for null as the static
// constructors may not have called yet as this method is called
// from the base classes constructor!
if (elementMap == null) elementMap = new HashMap();
elementMap.clear();
Map categoryCache = new HashMap();
// The new connection wizard selection is combining system types
@ -59,6 +81,8 @@ public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractW
// 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) {

View file

@ -72,7 +72,22 @@ public class RSENewConnectionWizardSelectionTreeElement extends RSEWizardSelecti
return image;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeElement#getDescription()
*/
public String getDescription() {
// Check the system type adapter for the description in case the wizard descriptor does
// not come up with a description itself.
String description = super.getDescription();
if (description == null) {
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(IRSESystemType.class));
if (adapter != null) {
description = adapter.getDescription(getSystemType());
}
}
return description;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)

View file

@ -34,10 +34,8 @@ public class RSEWizardSelectionTreePatternFilter extends PatternFilter {
protected boolean isLeafMatch(Viewer viewer, Object element) {
if (element instanceof RSEWizardSelectionTreeElement) {
RSEWizardSelectionTreeElement treeElement = (RSEWizardSelectionTreeElement)element;
// we filter only the wizard nodes, not the category nodes (yet).
if (treeElement.getWizardRegistryElement() instanceof IRSEWizardCategory) {
return true;
} else {
// we filter only the wizard nodes
if (treeElement.getWizardRegistryElement() instanceof IRSEWizardDescriptor) {
return wordMatches(treeElement.getLabel());
}

View file

@ -15,6 +15,9 @@
********************************************************************************/
package org.eclipse.rse.internal.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
@ -40,75 +43,86 @@ import org.eclipse.swt.widgets.Shell;
* It shows as "New Connection..." in the tree. When expanded, they get the new connection
* wizard.
*/
public class SystemNewConnectionPromptObject
implements ISystemPromptableObject, ISystemViewRunnableObject, IAdaptable
{
private Object parent;
private String[] systemTypes;
private ISystemPromptableObject[] children;
private SystemNewConnectionAction action = null;
private boolean systemTypesSet = false;
private String newConnText;
private boolean isRootPrompt = false;
/**
* Constructor
*/
public SystemNewConnectionPromptObject()
{
setSystemTypes(RSECorePlugin.getDefault().getRegistry().getSystemTypeNames());
isRootPrompt = true;
}
/**
* Constructor for child instances
*/
public SystemNewConnectionPromptObject(SystemNewConnectionPromptObject parent, String systemType)
{
this.parent = parent;
setSystemTypes(new String[] {systemType});
}
// ----------------------------------------------------
// METHODS FOR CONFIGURING THIS OBJECT
// ----------------------------------------------------
/**
* Set the system types to restrict the New Connection wizard to
*/
public void setSystemTypes(String[] systemTypes)
{
this.systemTypes = systemTypes;
this.systemTypesSet = true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.model.ISystemPromptableObject#getSystemTypes()
*/
public String[] getSystemTypes() {
String[] types = systemTypes;
if (types == null || !systemTypesSet) types = new String[0];
return types;
public class SystemNewConnectionPromptObject implements ISystemPromptableObject, ISystemViewRunnableObject, IAdaptable {
private Object parent;
private IRSESystemType[] systemTypes;
private ISystemPromptableObject[] children;
private SystemNewConnectionAction action = null;
private boolean systemTypesSet = false;
private String newConnText;
private boolean isRootPrompt = false;
/**
* Constructor
*/
public SystemNewConnectionPromptObject() {
setSystemTypes(RSECorePlugin.getDefault().getRegistry().getSystemTypes());
isRootPrompt = true;
}
/**
* Constructor for child instances
*/
public SystemNewConnectionPromptObject(SystemNewConnectionPromptObject parent, IRSESystemType systemType) {
this.parent = parent;
setSystemTypes(new IRSESystemType[] { systemType });
}
// ----------------------------------------------------
// METHODS FOR CONFIGURING THIS OBJECT
// ----------------------------------------------------
/**
* Set the system types to restrict the New Connection wizard to
*/
public void setSystemTypes(IRSESystemType[] systemTypes) {
this.systemTypes = systemTypes;
this.systemTypesSet = true;
}
/**
* @deprecated Use {@link #setSystemTypes(IRSESystemType[])}.
*/
public void setSystemTypes(String[] systemTypes) {
if (systemTypes != null) {
List types = new ArrayList();
for (int i = 0; i < systemTypes.length; i++) {
IRSESystemType type = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[i]);
if (type != null) types.add(type);
}
setSystemTypes((IRSESystemType[])types.toArray(new IRSESystemType[types.size()]));
} else {
setSystemTypes((IRSESystemType[])null);
}
/**
* Set the parent object so that we can respond to getParent requests
*/
public void setParent(Object parent)
{
this.parent = parent;
}
// ----------------------------------------------------
// METHODS CALLED BY THE SYSTEMVIEWPROMPTABLEADAPTER...
// ----------------------------------------------------
/**
* Get the parent object (within tree view)
*/
public Object getParent()
{
return parent;
}
}
/* (non-Javadoc)
* @see org.eclipse.rse.model.ISystemPromptableObject#getSystemTypes()
*/
public IRSESystemType[] getSystemTypes() {
IRSESystemType[] types = systemTypes;
if (types == null || !systemTypesSet)
types = new IRSESystemType[0];
return types;
}
/**
* Set the parent object so that we can respond to getParent requests
*/
public void setParent(Object parent) {
this.parent = parent;
}
// ----------------------------------------------------
// METHODS CALLED BY THE SYSTEMVIEWPROMPTABLEADAPTER...
// ----------------------------------------------------
/**
* Get the parent object (within tree view)
*/
public Object getParent() {
return parent;
}
/**
* Return the child promptable objects.
@ -123,9 +137,7 @@ public class SystemNewConnectionPromptObject
// Basically, once initialized, the list of system types cannot change, but
// it doesn't hurt to check this in case it changes because of future extensions.
if (isRootPrompt) {
String[] typeNames = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
if (systemTypes == null || typeNames.length != systemTypes.length)
systemTypes = typeNames;
systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
}
if (systemTypes != null) {
@ -138,21 +150,20 @@ public class SystemNewConnectionPromptObject
return children;
}
/**
* Return true if we have children, false if run when expanded
*/
public boolean hasChildren()
{
public boolean hasChildren() {
// DKM - I think we shouuld indicate children even if there's only one connection type
//if (systemTypes.length == 1)
if (systemTypes == null || (systemTypes.length == 1 && !isRootPrompt))
return false;
else
return true;
return true;
}
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* Calls getImage on the subsystem's owning factory.
@ -161,12 +172,11 @@ public class SystemNewConnectionPromptObject
if (hasChildren())
return RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID);
else {
IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]);
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class));
return adapter.getImageDescriptor(sysType);
RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemTypes[0].getAdapter(IRSESystemType.class));
return adapter.getImageDescriptor(systemTypes[0]);
}
}
/**
* Return the label for this object
*/
@ -184,68 +194,59 @@ public class SystemNewConnectionPromptObject
return newConnText;
}
/**
* Return the type label for this object
*/
public String getType()
{
public String getType() {
if (hasChildren())
return SystemResources.RESID_NEWCONN_EXPANDABLEPROMPT_VALUE;
return SystemResources.RESID_NEWCONN_EXPANDABLEPROMPT_VALUE;
else
return SystemResources.RESID_NEWCONN_PROMPT_VALUE;
}
return SystemResources.RESID_NEWCONN_PROMPT_VALUE;
}
/**
* Run this prompt. This should return an appropriate ISystemMessageObject to show
* as the child, reflecting if it ran successfully, was cancelled or failed.
*/
public Object[] run(Shell shell)
{
if (action == null)
{
action = new SystemNewConnectionAction(shell, false, false, null);
public Object[] run(Shell shell) {
if (action == null) {
action = new SystemNewConnectionAction(shell, false, false, null);
}
if (systemTypes!=null)
action.restrictSystemTypes(systemTypes);
try
{
action.run();
} catch (Exception exc)
{
return new Object[] {
new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED),
ISystemMessageObject.MSGTYPE_ERROR,null)};
if (systemTypes != null) {
List systemTypeNames = new ArrayList();
for (int i = 0; i < systemTypes.length; i++) systemTypeNames.add(systemTypes[i].getName());
action.restrictSystemTypes((String[])systemTypeNames.toArray(new String[systemTypeNames.size()]));
}
try {
action.run();
} catch (Exception exc) {
return new Object[] { new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_FAILED), ISystemMessageObject.MSGTYPE_ERROR, null) };
}
IHost newConnection = (IHost)action.getValue();
// create appropriate object to return...
ISystemMessageObject result = null;
if (newConnection != null)
{
result = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CONNECTIONCREATED),
ISystemMessageObject.MSGTYPE_OBJECTCREATED,null);
}
else
result = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED),
ISystemMessageObject.MSGTYPE_CANCEL,null);
return new Object[] {result};
if (newConnection != null) {
result = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CONNECTIONCREATED), ISystemMessageObject.MSGTYPE_OBJECTCREATED,
null);
} else
result = new SystemMessageObject(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXPAND_CANCELLED), ISystemMessageObject.MSGTYPE_CANCEL, null);
return new Object[] { result };
}
// ----------------------------------------------------
// METHODS REQUIRED BY THE IADAPTABLE INTERFACE...
// ----------------------------------------------------
/**
// ----------------------------------------------------
// METHODS REQUIRED BY THE IADAPTABLE INTERFACE...
// ----------------------------------------------------
/**
* This is the method required by the IAdaptable interface.
* Given an adapter class type, return an object castable to the type, or
* null if this is not possible.
*/
public Object getAdapter(Class adapterType)
{
return Platform.getAdapterManager().getAdapter(this, adapterType);
}
}
public Object getAdapter(Class adapterType) {
return Platform.getAdapterManager().getAdapter(this, adapterType);
}
}

View file

@ -17,6 +17,7 @@
package org.eclipse.rse.model;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.swt.widgets.Shell;
/**
@ -29,9 +30,7 @@ import org.eclipse.swt.widgets.Shell;
* <p>
* Related adapter is org.eclipse.rse.ui.view.SystemViewPromptableAdapter
*/
public interface ISystemPromptableObject extends IAdaptable
{
public interface ISystemPromptableObject extends IAdaptable {
/**
* Returns the list of system types this promptable object
* is associated with. This is important to implement label
@ -39,9 +38,9 @@ public interface ISystemPromptableObject extends IAdaptable
*
* @return The list of associated system types or an empty list.
*/
public String[] getSystemTypes();
/**
public IRSESystemType[] getSystemTypes();
/**
* Get the parent object (within tree view)
*/
public Object getParent();

View file

@ -103,8 +103,9 @@ New connection wizard may have the need of contributing different attribute valu
<attribute name="categoryId" type="string">
<annotation>
<documentation>
A fully qualified valid category id previously defined by this or some other plug-in. If omitted or if the specified category id is invalid, the wizard will be added as non-categorized root element.
A fully qualified valid category id previously defined by this or some other plug-in. If omitted or if the specified category id is invalid, the wizard will be added as non-categorized root element.
&lt;p&gt;
The default RSE wizard category id is &quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;.
</documentation>
</annotation>
</attribute>
@ -148,7 +149,6 @@ New connection wizard may have the need of contributing different attribute valu
<annotation>
<documentation>
The fully qualified id of the parent category or empty if it is a root category.
</documentation>
</annotation>
</attribute>
@ -166,16 +166,16 @@ New connection wizard may have the need of contributing different attribute valu
&lt;pre&gt;
&lt;extension
point=&quot;org.eclipse.rse.ui.newConnectionWizard&quot;&gt;
&lt;category id=&quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;
name=&quot;%Creation.category.name&quot;/&gt;
&lt;newConnectionWizard
id=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultnNewConnectionWizard&quot;
class=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard&quot;
name=&quot;%DefaultRSENewConnectionWizard.name&quot;
canFinishEarly=&quot;false&quot;
categoryId=&quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;
hasPages=&quot;true&quot;&gt;
&lt;/newConnectionWizard&gt;
&lt;category id=&quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;
name=&quot;%Creation.category.name&quot;/&gt;
&lt;newConnectionWizard
id=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultnNewConnectionWizard&quot;
class=&quot;org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard&quot;
name=&quot;%DefaultRSENewConnectionWizard.name&quot;
canFinishEarly=&quot;false&quot;
categoryId=&quot;org.eclipse.rse.ui.wizards.newconnection.default.category&quot;
hasPages=&quot;true&quot;&gt;
&lt;/newConnectionWizard&gt;
&lt;/extension&gt;
&lt;/pre&gt;
&lt;/p&gt;

View file

@ -164,8 +164,8 @@ public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy
// If the subsystem configuration supports all system types, just add all
// currently registered system types to th resolved list
if (supportsAllSystemTypes()) {
String[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames();
if (systemTypes != null) resolvedSystemTypes.addAll(Arrays.asList(systemTypes));
IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes();
for (int i = 0; i < systemTypes.length; i++) resolvedSystemTypes.add(systemTypes[i].getName());
} else {
// We have to match the given lists of system type ids against
// the list of available system types. As the list of system types cannot