diff --git a/discovery/org.eclipse.rse.discovery/plugin.properties b/discovery/org.eclipse.rse.discovery/plugin.properties index 1c1e0d6528f..56fcf0790e9 100644 --- a/discovery/org.eclipse.rse.discovery/plugin.properties +++ b/discovery/org.eclipse.rse.discovery/plugin.properties @@ -11,3 +11,5 @@ pluginName = TM Service Discovery RSE Plug-in providerName = Eclipse.org + +NewConnectionWizard.discovery.name=Service Discovery Wizard diff --git a/discovery/org.eclipse.rse.discovery/plugin.xml b/discovery/org.eclipse.rse.discovery/plugin.xml index 09a31684b08..9556c9487a1 100644 --- a/discovery/org.eclipse.rse.discovery/plugin.xml +++ b/discovery/org.eclipse.rse.discovery/plugin.xml @@ -13,13 +13,18 @@ Contributors: - - - + + + + diff --git a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java b/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java deleted file mode 100644 index f017f51bc11..00000000000 --- a/discovery/org.eclipse.rse.discovery/src/org/eclipse/rse/discovery/ServiceDiscoveryWizardDelegate.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 Symbian Software Ltd. 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: - * Javier Montalvo OrĂºs (Symbian) - initial API and implementation - ********************************************************************************/ - -package org.eclipse.rse.discovery; - -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; -import org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate; - -/** - * RSE Wizard extension for Service Discovery - */ - -public class ServiceDiscoveryWizardDelegate extends RSENewConnectionWizardDelegate { - - private ServiceDiscoveryWizard subWizard; - - private boolean isSubWizardCreated; - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType) - */ - public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { - super.init(wizard, systemType); - subWizard = new ServiceDiscoveryWizard(); - isSubWizardCreated = false; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getDummyHost() - */ - public IHost getDummyHost() { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getMainPage() - */ - public IWizardPage getMainPage() { - if (!isSubWizardCreated) { - subWizard.addPages(); - isSubWizardCreated = true; - } - IWizardPage firstSubPage = subWizard.getStartingPage(); - return firstSubPage; - - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#performFinish() - */ - public boolean performFinish() { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#canFinish() - */ - public boolean canFinish() { - return subWizard.canFinish(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#getNextPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getNextPage(IWizardPage page) { - return subWizard.getNextPage(page); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getPreviousPage(IWizardPage page) { - if (page == getMainPage()) { - return getWizard().getPreviousPage(page); - } else { - return subWizard.getPreviousPage(page); - } - } - -} diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemTypeMatcher.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemTypeMatcher.java new file mode 100644 index 00000000000..1d02c57557c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemTypeMatcher.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2006 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. + *******************************************************************************/ +package org.eclipse.rse.core; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + +/** + * Shared system type id list parser and matcher. Parses a given + * list of system type id's, separated by semicolon and possibly + * containing the wildcards '*' and '?. + */ +public final class SystemTypeMatcher { + private final class SystemTypeIdPattern { + private final Pattern pattern; + + /** + * Constructor. + */ + public SystemTypeIdPattern(Pattern pattern) { + assert pattern != null; + this.pattern = pattern; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.internal.subsystems.SubSystemConfigurationProxy.ISystemTypePattern#matches(org.eclipse.rse.core.IRSESystemType) + */ + public boolean matches(IRSESystemType systemType) { + assert systemType != null; + return pattern.matcher(systemType.getId()).matches(); + } + } + + // List of patterns to match. The order is preserved. + private final List patterns = new LinkedList(); + private boolean matchAllTypes = false; + + /** + * Constructor. + * + * @param declaredSystemTypeIds The list of declared system type ids. Might be null. + */ + public SystemTypeMatcher(String declaredSystemTypeIds) { + // Compile the list of patterns out of given lists of declared system types + if (declaredSystemTypeIds != null) { + String[] ids = declaredSystemTypeIds.split(";"); //$NON-NLS-1$ + if (ids != null && ids.length > 0) { + for (int i = 0; i < ids.length; i++) { + String id = ids[i].trim(); + if (id.equals("*")) { //$NON-NLS-1$ + matchAllTypes = true; + patterns.clear(); + return; + } else if(id.length()>0) { + SystemTypeIdPattern pattern = new SystemTypeIdPattern(Pattern.compile(makeRegex(id))); + patterns.add(pattern); + } + } + } + } + } + + private String makeRegex(String pattern) { + assert pattern != null; + String translated = pattern; + if (translated.indexOf('.') != -1) translated = translated.replaceAll("\\.", "\\."); //$NON-NLS-1$ //$NON-NLS-2$ + if (translated.indexOf('*') != -1) translated = translated.replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$ + if (translated.indexOf('?') != -1) translated = translated.replaceAll("\\?", "."); //$NON-NLS-1$ //$NON-NLS-2$ + return translated; + } + + /** + * @return true if this matcher supports all system types. + */ + public boolean supportsAllSystemTypes() { + return matchAllTypes; + } + + /** + * Checks if the specified system type is matched by this pattern. + */ + public boolean matches(IRSESystemType systemType) { + assert systemType != null; + if (matchAllTypes) return true; + Iterator iterator = patterns.iterator(); + while (iterator.hasNext()) { + SystemTypeIdPattern matcher = (SystemTypeIdPattern)iterator.next(); + if (matcher.matches(systemType)) return true; + } + return false; + } +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystemConfigurationProxy.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystemConfigurationProxy.java index 8d370683d94..b613af8727d 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystemConfigurationProxy.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystemConfigurationProxy.java @@ -59,7 +59,7 @@ public interface ISubSystemConfigurationProxy { /** * Returns the list of system types the subsystem configuration is supporting. * The list is combined from the list of currently registered system types cleaned - * up by the ones not matching the declared system type names and ids. + * up by the ones not matching the declared system type ids. * * @return The list of supported system types or an empty list. */ diff --git a/rse/plugins/org.eclipse.rse.ui/.settings/org.eclipse.core.resources.prefs b/rse/plugins/org.eclipse.rse.ui/.settings/org.eclipse.core.resources.prefs index d97f5cff540..217bc8e347f 100644 --- a/rse/plugins/org.eclipse.rse.ui/.settings/org.eclipse.core.resources.prefs +++ b/rse/plugins/org.eclipse.rse.ui/.settings/org.eclipse.core.resources.prefs @@ -1,5 +1,5 @@ -#Fri Oct 27 10:57:59 EDT 2006 +#Mon Feb 19 12:59:50 GMT+01:00 2007 eclipse.preferences.version=1 encoding//UI/org/eclipse/rse/ui/SystemWidgetHelpers.java=UTF-8 -encoding//UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizard.java=UTF-8 -encoding//UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java=UTF-8 +encoding//UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java=UTF-8 +encoding//UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java=UTF-8 diff --git a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF index 22815e75b61..c93ddd43282 100644 --- a/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.ui/META-INF/MANIFEST.MF @@ -47,6 +47,8 @@ Export-Package: org.eclipse.rse.core, org.eclipse.rse.ui.view, org.eclipse.rse.ui.widgets, org.eclipse.rse.ui.widgets.services, - org.eclipse.rse.ui.wizards + org.eclipse.rse.ui.wizards, + org.eclipse.rse.ui.wizards.newconnection, + org.eclipse.rse.ui.wizards.registries Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemConnectionFormCaller.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemConnectionFormCaller.java index a35ea42cf57..c04a609004d 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemConnectionFormCaller.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemConnectionFormCaller.java @@ -20,19 +20,19 @@ import org.eclipse.swt.widgets.Shell; /** * Interface that any UI that uses the SystemConnectionForm must implement */ -public interface ISystemConnectionFormCaller -{ +public interface ISystemConnectionFormCaller { + /** + * Event: the user has selected a system type. + * + * @param systemType the type of system selected + * @param duringInitialization true if this is being set at page initialization time versus selected by the user + */ + public void systemTypeSelected(String systemType, boolean duringInitialization); + + /** + * Return the shell hosting this form + */ + public Shell getShell(); - /** - * Event: the user has selected a system type. - * @param systemType the type of system selected - * @param duringInitialization true if this is being set at page initialization time versus selected by the user - */ - public void systemTypeSelected(String systemType, boolean duringInitialization); - /** - * Return the shell hosting this form - */ - public Shell getShell(); - } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java index 72bbbe72fd5..c2b77515aba 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2006, 2007 IBM Corporation 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 @@ -13,6 +13,7 @@ * Contributors: * David Dykstal (IBM) - moved SystemPreferencesManager to a new package * - created and used RSEPreferencesManager + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. ********************************************************************************/ package org.eclipse.rse.ui; @@ -26,6 +27,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemTypeConstants; import org.eclipse.rse.core.RSEPreferencesManager; +import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor; import org.osgi.framework.Bundle; /** @@ -233,4 +235,23 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo return result; } + /** + * Checks if the given wizard descriptor is accepted for the system types the + * adapter is covering. + * + * @param wizardConfigurationElementName The wizard configuration element name. Must be not null. + * @param descriptor The wizard descriptor. Must be not null. + * + * @return True is accepted, false otherwise. + */ + public boolean acceptWizardDescriptor(String wizardConfigurationElementName, IRSEWizardDescriptor descriptor) { + assert wizardConfigurationElementName != null && descriptor != null; + + // We always accept the default RSE new connection wizard + if ("org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard".equals(descriptor.getId())) { //$NON-NLS-1$ + return true; + } + + return false; + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java index b5990653244..a7112be36ad 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java @@ -43,7 +43,7 @@ import org.eclipse.rse.ui.validators.ValidatorConnectionName; import org.eclipse.rse.ui.validators.ValidatorUserId; import org.eclipse.rse.ui.widgets.InheritableEntryField; import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage; -import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; +import org.eclipse.rse.ui.wizards.newconnection.RSEAbstractNewConnectionWizard; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; @@ -893,8 +893,8 @@ public class SystemConnectionForm IWizardPage[] pages = null; - if (wizard instanceof RSENewConnectionWizard) { - RSENewConnectionWizard connWizard = (RSENewConnectionWizard)wizard; + if (wizard instanceof RSEAbstractNewConnectionWizard) { + RSEAbstractNewConnectionWizard connWizard = (RSEAbstractNewConnectionWizard)wizard; AbstractSystemWizardPage mainPage = (AbstractSystemWizardPage)(connWizard.getStartingPage()); Vector pageList = new Vector(); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java index 1d8ac35a174..55a225d3868 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.java @@ -192,12 +192,15 @@ public class SystemResources extends NLS public static String RESID_NEWCONN_PAGE1_REMOTE_TITLE; public static String RESID_NEWCONN_PAGE1_LOCAL_TITLE; public static String RESID_NEWCONN_PAGE1_DESCRIPTION; + public static String RESID_NEWCONN_MAIN_PAGE_TITLE; + public static String RESID_NEWCONN_MAIN_PAGE_DESCRIPTION; public static String RESID_NEWCONN_SUBSYSTEMPAGE_FILES_DESCRIPTION; public static String RESID_NEWCONN_SUBSYSTEMPAGE_FILES_TITLE; public static String RESID_NEWCONN_SUBSYSTEMPAGE_FILES_VERBIAGE1; public static String RESID_NEWCONN_SUBSYSTEMPAGE_FILES_VERBIAGE2; public static String RESID_NEWCONN_SUBSYSTEMPAGE_DESCRIPTION; + public static String RESID_CONNECTION_TYPE_LABEL; public static String RESID_CONNECTION_TYPE_VALUE; public static String RESID_CONNECTION_SYSTEMTYPE_LABEL; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties index 16c6f6802f0..c78a71575d6 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemResources.properties @@ -261,6 +261,8 @@ RESID_NEWCONN_PAGE1_TITLE=Remote System Connection RESID_NEWCONN_PAGE1_LOCAL_TITLE=Local System Connection RESID_NEWCONN_PAGE1_REMOTE_TITLE=Remote &1 System Connection RESID_NEWCONN_PAGE1_DESCRIPTION=Define connection information +RESID_NEWCONN_MAIN_PAGE_TITLE=Select Remote System Type +RESID_NEWCONN_MAIN_PAGE_DESCRIPTION=Please select the system type of the remote system to connect. #============================================================= # NEW CONNECTION WIZARD INFORMATION PAGE FOR UNIX/LINUX/WINDOWS diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/DisplayDialogAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/DisplayDialogAction.java deleted file mode 100644 index 6aecd17dd74..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/DisplayDialogAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.actions; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * DisplayDialogAction can be used to display a JFace Dialog when - * not running on the UI thread and no shell is availble. For example: - * - * Display.getDefault().syncExec(new DisplayDialogAction(myDialog)); - * - */ -public class DisplayDialogAction implements Runnable { - - - private Dialog _dialog; - - /** - * Constructor for DisplayDialogAction. - * - * @param dialog The dialog to be displayed. - */ - public DisplayDialogAction(Dialog dialog) { - _dialog = dialog; - } - - /** - * @see java.lang.Runnable#run() - */ - public void run() { - boolean finished = false; - - Shell[] shells = Display.getCurrent().getShells(); - for (int loop = 0; loop < shells.length && !finished; loop++) { - if (shells[loop].isEnabled()) - { - _dialog.open(); - finished = true; - } - } - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemBaseWizardAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemBaseWizardAction.java index 0b4fcede9fd..8e78e912779 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemBaseWizardAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemBaseWizardAction.java @@ -43,9 +43,6 @@ import org.eclipse.swt.widgets.Shell; *
  • Supports setting the default wizard {@link #setWizardPageTitle(String) page-title}, which is propogated to the wizard and the wizard pages. *
  • Supports setting the wizard;s default {@link #setHelp(String) contextual-help}, which is propogated to the wizard and the wizard pages. *
  • Supports setting the wizard's {@link #setMinimumPageSize(int,int) minimum-size}, which is propogated and applied to the wizard. - *
  • Supports setting an {@link org.eclipse.rse.ui.actions.SystemBaseAction#setInputObject(Object) input-object}, which is propogated to the wizard and wizard pages. By default, this - * is set the current StructuredSelection. - *
  • Supports querying a {@link org.eclipse.rse.ui.actions.SystemBaseAction#getOutputObject() output-object} which is set by the wizard class. *
  • Supports a {@link #wasCancelled()} method so the caller can easily determine if the wizard was dismissed or cancelled by the user. *
  • Supports propogation of the {@link org.eclipse.rse.ui.actions.SystemBaseAction#getViewer() current-viewer}. * @@ -64,15 +61,13 @@ import org.eclipse.swt.widgets.Shell; * after the sucessful completion of the wizard. * */ -public abstract class SystemBaseWizardAction extends SystemBaseDialogAction - implements ISystemWizardAction -{ - - private IWizard newWizard; - private String wizardTitle, pageTitle; - private ImageDescriptor wizardImage; - private int minPageWidth=-1, minPageHeight=-1; - +public abstract class SystemBaseWizardAction extends SystemBaseDialogAction implements ISystemWizardAction { + + private IWizard newWizard; + private String wizardTitle, pageTitle; + private ImageDescriptor wizardImage; + private int minPageWidth = -1, minPageHeight = -1; + /** * Constructor for SystemBaseWizardAction when translated label is known. You must separately * call setToolTipText and setDescription to enable these if desired. @@ -80,55 +75,52 @@ public abstract class SystemBaseWizardAction extends SystemBaseDialogAction * @param image icon to display in menu or toolbar. Can be null. * @param parent Shell of parent window. Can be null if you don't know it, but call setShell when you do. */ - protected SystemBaseWizardAction(String text, ImageDescriptor image, Shell parent) - { + protected SystemBaseWizardAction(String text, ImageDescriptor image, Shell parent) { super(text, image, parent); allowOnMultipleSelection(false); } + /** * Constructor for SystemBaseWizardAction when translated label and tooltip are known. You must * separately call setDescription to enable this if desired. * @param text string to display in menu or toolbar * @param tooltip string to display when user hovers mouse over action. - * @param image icon to display in menu or toolbar. Can be null. + * @param image icon to display in menu or toolbar. Can be null. * @param parent Shell of parent window. Can be null if you don't know it, but call setShell when you do. */ - protected SystemBaseWizardAction(String text, String tooltip, ImageDescriptor image, Shell parent) - { + protected SystemBaseWizardAction(String text, String tooltip, ImageDescriptor image, Shell parent) { super(text, tooltip, image, parent); - allowOnMultipleSelection(false); + allowOnMultipleSelection(false); } + /** * Constructor for SystemBaseWizardAction when translated label and tooltip and description are * all known. * @param text string to display in menu or toolbar * @param tooltip string to display when user hovers mouse over action. * @param description string displayed in status bar of some displays. Longer than tooltip. - * @param image icon to display in menu or toolbar. Can be null. + * @param image icon to display in menu or toolbar. Can be null. * @param parent Shell of parent window. Can be null if you don't know it, but call setShell when you do. */ - protected SystemBaseWizardAction(String text, String tooltip, String description, ImageDescriptor image, Shell parent) - { + protected SystemBaseWizardAction(String text, String tooltip, String description, ImageDescriptor image, Shell parent) { super(text, tooltip, description, image, parent); - allowOnMultipleSelection(false); - } + allowOnMultipleSelection(false); + } - - /** * Set the wizard title. Using this makes it possible to avoid subclassing a wizard */ - public void setWizardTitle(String title) - { + public void setWizardTitle(String title) { this.wizardTitle = title; } + /** * Set the wizard image. Using this makes it possible to avoid subclassing a wizard */ - public void setWizardImage(ImageDescriptor wizardImage) - { + public void setWizardImage(ImageDescriptor wizardImage) { this.wizardImage = wizardImage; } + /** * Set the wizard page title. Using this makes it possible to avoid subclassing. * The page title goes below the wizard title, and can be unique per page. However, @@ -137,30 +129,30 @@ public abstract class SystemBaseWizardAction extends SystemBaseDialogAction * This is not used by default, but can be queried via getPageTitle() when constructing * pages. */ - public void setWizardPageTitle(String pageTitle) - { + public void setWizardPageTitle(String pageTitle) { this.pageTitle = pageTitle; } + /** * Return the page title as set via setWizardPageTitle */ - public String getWizardPageTitle() - { + public String getWizardPageTitle() { return pageTitle; - } + } + /** * Call this method to set the wizard's dimensions without having to subclass the wizard. * If you pass zero for either value, then the default will be used for that. */ - public void setMinimumPageSize(int width, int height) - { - //if (width <= 0) - // width = 300; // found this number in WizardDialog code - //if (height<= 0) - // height = 225; // found this number in WizardDialog code + public void setMinimumPageSize(int width, int height) { + //if (width <= 0) + // width = 300; // found this number in WizardDialog code + //if (height<= 0) + // height = 225; // found this number in WizardDialog code this.minPageWidth = width; this.minPageHeight = height; } + /** * Override of parent's method. Does the following: *
      @@ -172,59 +164,59 @@ public abstract class SystemBaseWizardAction extends SystemBaseDialogAction *
    * */ - protected Dialog createDialog(Shell shell) - { + protected final Dialog createDialog(Shell shell) { newWizard = createWizard(); - + if ((newWizard instanceof Wizard) && wasNeedsProgressMonitorSet()) - ((Wizard)newWizard).setNeedsProgressMonitor(getNeedsProgressMonitor()); - - if (newWizard instanceof Wizard) - { - if (wizardTitle != null) - ((Wizard)newWizard).setWindowTitle(wizardTitle); - if (wizardImage != null) - ((Wizard)newWizard).setDefaultPageImageDescriptor(wizardImage); + ((Wizard)newWizard).setNeedsProgressMonitor(getNeedsProgressMonitor()); + + if (newWizard instanceof Wizard) { + if (wizardTitle != null) + ((Wizard)newWizard).setWindowTitle(wizardTitle); + if (wizardImage != null) + ((Wizard)newWizard).setDefaultPageImageDescriptor(wizardImage); } - - WizardDialog dialog = null; - - if (newWizard instanceof ISystemWizard) - { - ISystemWizard swizard = (ISystemWizard)newWizard; - if (pageTitle != null) - swizard.setWizardPageTitle(pageTitle); - swizard.setViewer(getViewer()); - dialog = new SystemWizardDialog(shell,swizard); - int w = swizard.getMinimumPageWidth(); - int h = swizard.getMinimumPageHeight(); - if (minPageWidth > 0) - w = minPageWidth; - if (minPageHeight > 0) - h = minPageHeight; - //System.out.println("In SystemBaseWizardAction. minPageWidth = " + w + ", minPageHeight = " + h); - if ((w>0) && (h>0)) - dialog.setMinimumPageSize(w,h); - - /* - * Don't do the following here as it is redundant! The run method in the parent SystemBaseDialogAction - * does this already - Object wizardInputValue = null; - if (getValue() != null) - wizardInputValue = getValue(); - else - wizardInputValue = getFirstSelection(); - if (wizardInputValue != null) - ((SystemWizardDialog)dialog).setInputObject(wizardInputValue); - */ - } - else - dialog = new WizardDialog(shell,newWizard); - - return dialog; + return doCreateWizardDialog(shell, newWizard); } - + + /** + * Creates the dialog instance. Called from createDialog(...). + * Gives overrides the chance to plug-in their own specialized wizard dialog + * implementations. + * + * @param shell The shell to create the dialog in. Must be not null. + * @param wizard The wizard to create the wizard dialog for. Must be not null. + * + * @return The wizard dialog instance. Must be never null. + */ + protected WizardDialog doCreateWizardDialog(Shell shell, IWizard wizard) { + assert shell != null && wizard != null; + + WizardDialog dialog = null; + + if (newWizard instanceof ISystemWizard) { + ISystemWizard swizard = (ISystemWizard)newWizard; + if (pageTitle != null) + swizard.setWizardPageTitle(pageTitle); + swizard.setViewer(getViewer()); + dialog = new SystemWizardDialog(shell, swizard); + int w = swizard.getMinimumPageWidth(); + int h = swizard.getMinimumPageHeight(); + if (minPageWidth > 0) + w = minPageWidth; + if (minPageHeight > 0) + h = minPageHeight; + //System.out.println("In SystemBaseWizardAction. minPageWidth = " + w + ", minPageHeight = " + h); + if ((w > 0) && (h > 0)) + dialog.setMinimumPageSize(w, h); + + } else + dialog = new WizardDialog(shell, newWizard); + + return dialog; + } + /** * The default processing for the run method calls createDialog, which * we override in this class. The implementation of createDialog calls @@ -232,49 +224,42 @@ public abstract class SystemBaseWizardAction extends SystemBaseDialogAction * goes into a WizardDialog which is opened and hence displayed to the * user. */ - protected abstract IWizard createWizard(); - + protected abstract IWizard createWizard(); + /** * By default, we try to get the wizard's value by calling getOutputObject() */ - protected Object getDialogValue(Dialog dlg) - { - postProcessWizard(newWizard); - if (newWizard instanceof ISystemWizard) - { + protected Object getDialogValue(Dialog dlg) { + postProcessWizard(newWizard); + if (newWizard instanceof ISystemWizard) { ISystemWizard ourWizard = (ISystemWizard)newWizard; - return ourWizard.getOutputObject(); - } - else - return null; + return ourWizard.getOutputObject(); + } else + return null; + } + + /** + * Typically, the wizard's performFinish method does the work required by + * a successful finish of the wizard. However, often we also want to be + * able to extract user-entered data from the wizard, by calling getters + * in this action. To enable this, override this method to populate your + * output instance variables from the completed wizard, which is passed + * as a parameter. This is only called after successful completion of the + * wizard. + */ + protected void postProcessWizard(IWizard wizard) { } - /** - * Typically, the wizard's performFinish method does the work required by - * a successful finish of the wizard. However, often we also want to be - * able to extract user-entered data from the wizard, by calling getters - * in this action. To enable this, override this method to populate your - * output instance variables from the completed wizard, which is passed - * as a parameter. This is only called after successful completion of the - * wizard. - */ - protected void postProcessWizard(IWizard wizard) - { - } - /** * Returns true if the user cancelled the wizard. * This is an override of the parent method, since we can be more * accurate with wizards than we can with dialogs. */ - public boolean wasCancelled() - { - if (newWizard instanceof ISystemWizard) - { + public boolean wasCancelled() { + if (newWizard instanceof ISystemWizard) { ISystemWizard ourWizard = (ISystemWizard)newWizard; - return ourWizard.wasCancelled(); - } - else - return super.wasCancelled(); - } + return ourWizard.wasCancelled(); + } else + return super.wasCancelled(); + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java index d93b6beeecb..23b447395e0 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemNewConnectionAction.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation 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 @@ -15,9 +15,14 @@ ********************************************************************************/ package org.eclipse.rse.ui.actions; +import java.util.LinkedList; +import java.util.List; + import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.filters.ISystemFilterPoolReference; @@ -29,35 +34,33 @@ import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.wizards.RSENewConnectionWizard; +import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard; import org.eclipse.swt.widgets.Shell; /** * The action that displays the New Connection wizard */ -public class SystemNewConnectionAction extends SystemBaseWizardAction - -{ - - private IHost currConn; +public class SystemNewConnectionAction extends SystemBaseWizardAction { + private boolean fromPopupMenu = true; - private ISelectionProvider sp = null; - private String[] restrictSystemTypesTo; - private String defaultConnectionName, defaultHostName; - + private ISelectionProvider sp; + private String[] restrictSystemTypesTo; + private String systemTypeFromSelectedContext; + /** - * Constructor for SystemNewConnectionAction + * Constructor. + * * @param shell The parent shell to host the new wizard * @param fromPopupMenu true if being launched from the Remote System Explorer view directly, * false if being launched from a dialog * @param sp The selection provider that will supply the selection via getSelection, if * fromPopupMenu is false */ - public SystemNewConnectionAction(Shell shell, boolean fromPopupMenu, ISelectionProvider sp) - { + public SystemNewConnectionAction(Shell shell, boolean fromPopupMenu, ISelectionProvider sp) { this(shell, fromPopupMenu, true, sp); } + /** * Constructor for SystemNewConnectionAction when you don't want the icon. * @param shell The parent shell to host the new wizard @@ -67,141 +70,121 @@ public class SystemNewConnectionAction extends SystemBaseWizardAction * @param sp The selection provider that will supply the selection via getSelection, if * fromPopupMenu is false */ - public SystemNewConnectionAction(Shell shell, boolean fromPopupMenu, boolean wantIcon, ISelectionProvider sp) - { + public SystemNewConnectionAction(Shell shell, boolean fromPopupMenu, boolean wantIcon, ISelectionProvider sp) { this(shell, SystemResources.ACTION_NEWCONN_LABEL, SystemResources.ACTION_NEWCONN_TOOLTIP, fromPopupMenu, wantIcon, sp); } + /** * Constructor for SystemNewConnectionAction when you possibly don't want the icon, and want to * supply your own label. This is the "full" flavoured constructor! * * @param shell The parent shell to host the new wizard - * @param label The label for the action - * @param tooltip the tooltip for the action + * @param label The label for the action + * @param tooltip the tooltip for the action * @param fromPopupMenu true if being launched from the Remote System Explorer view directly, * false if being launched from a dialog * @param wantIcon true if you want the icon to show beside the action, false if not * @param sp The selection provider that will supply the selection via getSelection, if * fromPopupMenu is false */ - public SystemNewConnectionAction(Shell shell, String label, String tooltip, - boolean fromPopupMenu, boolean wantIcon, ISelectionProvider sp) - { - super(label, tooltip, - wantIcon ? RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID) : null , - shell); + public SystemNewConnectionAction(Shell shell, String label, String tooltip, boolean fromPopupMenu, boolean wantIcon, ISelectionProvider sp) { + super(label, tooltip, wantIcon ? RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTION_ID) : null, shell); setContextMenuGroup(ISystemContextMenuConstants.GROUP_NEW); this.fromPopupMenu = fromPopupMenu; this.sp = sp; - setHelp(RSEUIPlugin.HELPPREFIX+"actn0000"); //$NON-NLS-1$ + setHelp(RSEUIPlugin.HELPPREFIX + "actn0000"); //$NON-NLS-1$ } /** * The default processing for the run method calls createDialog, which * in turn calls this method to return an instance of our wizard. *

    - * Our default implementation is to return SystemNewConnectionWizard. + * Our default implementation is to return RSEMainNewConnectionWizard. */ - protected IWizard createWizard() - { - RSENewConnectionWizard newConnWizard = new RSENewConnectionWizard(); - if (!fromPopupMenu && (sp!=null)) - { - setSelection(sp.getSelection()); - } + protected IWizard createWizard() { + RSEMainNewConnectionWizard newConnWizard = new RSEMainNewConnectionWizard(); + if (!fromPopupMenu && (sp != null)) { + setSelection(sp.getSelection()); + } - // newConnWizard.setCurrentlySelectedConnection(currConn); if (restrictSystemTypesTo != null) { - - IRSESystemType[] systemTypes = new IRSESystemType[restrictSystemTypesTo.length]; + List systemTypes = new LinkedList(); for (int i = 0; i < restrictSystemTypesTo.length; i++) { - systemTypes[i] = RSECorePlugin.getDefault().getRegistry().getSystemType(restrictSystemTypesTo[i]); + IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(restrictSystemTypesTo[i]); + if (systemType != null) systemTypes.add(systemType); } - - newConnWizard.restrictToSystemTypes(systemTypes); + + newConnWizard.restrictToSystemTypes((IRSESystemType[])systemTypes.toArray(new IRSESystemType[systemTypes.size()])); + } + + // if there is a system type available from the current context, this system type + // is selected by default + if (systemTypeFromSelectedContext != null && RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeFromSelectedContext) != null) { + newConnWizard.setSelection(new StructuredSelection(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeFromSelectedContext))); } - // if (defaultHostName != null) - // newConnWizard.setHostName(defaultHostName); - // if (defaultConnectionName != null) - // newConnWizard.setConnectionName(defaultConnectionName); - return newConnWizard; + return newConnWizard; } - /** - * Set the current selected connection so we can better intelligently set - * the defaults. - */ - public void setCurrentConnection(IHost conn) - { - this.currConn = conn; - } - /** - * Call this to restrict the system type that the user is allowed to choose - */ - public void restrictSystemType(String systemType) - { - restrictSystemTypesTo = new String[1]; - restrictSystemTypesTo[0] = systemType; - } - /** - * Call this to restrict the system types that the user is allowed to choose - */ - public void restrictSystemTypes(String[] systemTypes) - { - this.restrictSystemTypesTo = systemTypes; - } - /** - * Preset the connection name + /* (non-Javadoc) + * @see org.eclipse.rse.ui.actions.SystemBaseWizardAction#doCreateWizardDialog(org.eclipse.swt.widgets.Shell, org.eclipse.jface.wizard.IWizard) */ - public void setConnectionName(String name) - { - defaultConnectionName = name; + 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; +// } + }; + + return dialog; } + /** - * Preset the host name + * Call this to restrict the system types that the user is allowed to choose */ - public void setHostName(String name) - { - defaultHostName = name; + public void restrictSystemTypes(String[] systemTypes) { + this.restrictSystemTypesTo = systemTypes; } - + /** * Override of parent method so we can deduce currently selected connection (direct or indirect if child object selected). */ - public boolean updateSelection(IStructuredSelection selection) - { + public boolean updateSelection(IStructuredSelection selection) { boolean enable = super.updateSelection(selection); - if (enable) - { + if (enable) { Object firstSelection = getFirstSelection(); IHost conn = null; - if (firstSelection != null) - { - if (firstSelection instanceof IHost) - conn = (IHost)firstSelection; - else if (firstSelection instanceof ISubSystem) - conn = ((ISubSystem)firstSelection).getHost(); - else if (firstSelection instanceof ISystemFilterPoolReference) - { - ISystemFilterPoolReference sfpr = (ISystemFilterPoolReference)firstSelection; - ISubSystem ss = (ISubSystem)sfpr.getProvider(); - conn = ss.getHost(); - } - else if (firstSelection instanceof ISystemFilterReference) - { - ISystemFilterReference sfr = (ISystemFilterReference)firstSelection; - ISubSystem ss = (ISubSystem)sfr.getProvider(); - conn = ss.getHost(); - } - else if (firstSelection instanceof ISystemFilterStringReference) - { - ISystemFilterStringReference sfsr = (ISystemFilterStringReference)firstSelection; - ISubSystem ss = (ISubSystem)sfsr.getProvider(); - conn = ss.getHost(); - } + if (firstSelection != null) { + if (firstSelection instanceof IHost) + conn = (IHost)firstSelection; + else if (firstSelection instanceof ISubSystem) + conn = ((ISubSystem)firstSelection).getHost(); + else if (firstSelection instanceof ISystemFilterPoolReference) { + ISystemFilterPoolReference sfpr = (ISystemFilterPoolReference)firstSelection; + ISubSystem ss = (ISubSystem)sfpr.getProvider(); + conn = ss.getHost(); + } else if (firstSelection instanceof ISystemFilterReference) { + ISystemFilterReference sfr = (ISystemFilterReference)firstSelection; + ISubSystem ss = (ISubSystem)sfr.getProvider(); + conn = ss.getHost(); + } else if (firstSelection instanceof ISystemFilterStringReference) { + ISystemFilterStringReference sfsr = (ISystemFilterStringReference)firstSelection; + ISubSystem ss = (ISubSystem)sfsr.getProvider(); + conn = ss.getHost(); + } } - setCurrentConnection(conn); + + systemTypeFromSelectedContext = conn != null ? conn.getSystemType() : null; } return enable; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java index 85a04960fef..024974346e5 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemNewConnectionWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. ********************************************************************************/ package org.eclipse.rse.ui.wizards; @@ -21,6 +21,8 @@ import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.ui.SystemConnectionForm; import org.eclipse.rse.ui.SystemResources; +import org.eclipse.rse.ui.wizards.newconnection.RSEAbstractNewConnectionWizard; +import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizardMainPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -98,50 +100,44 @@ public abstract class AbstractSystemNewConnectionWizardPage extends AbstractSyst } /** - * Get the parent wizard typed as the SystemNewConnectionWizard + * Get the parent wizard typed as the RSEAbstractNewConnectionWizard */ - public RSENewConnectionWizard getNewConnectionWizard() + public RSEAbstractNewConnectionWizard getNewConnectionWizard() { - return (RSENewConnectionWizard)getWizard(); + if (getWizard() instanceof RSEAbstractNewConnectionWizard) + return (RSEAbstractNewConnectionWizard)getWizard(); + + return null; } /** - * Get the main page of SystemNewConnectionWizard, which contains all user enter connection attributes + * Get the main page of RSEDefaultNewConnectionWizard, which contains all user enter connection attributes */ - public ISystemNewConnectionWizardMainPage getMainPage() - { - RSENewConnectionWizard ourWizard = getNewConnectionWizard(); + public RSEDefaultNewConnectionWizardMainPage getMainPage() { + RSEAbstractNewConnectionWizard ourWizard = getNewConnectionWizard(); if (ourWizard != null) { - //String[] systemTypes = parentFactory.getSystemTypes(); - //IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); - IWizardPage wizardPage = ourWizard.getDelegate().getMainPage(); - - if (wizardPage instanceof ISystemNewConnectionWizardMainPage) { - return (ISystemNewConnectionWizardMainPage)wizardPage; - } - else { - return null; - } + IWizardPage wizardPage = ourWizard.getStartingPage(); + if (wizardPage instanceof RSEDefaultNewConnectionWizardMainPage) { + return (RSEDefaultNewConnectionWizardMainPage)wizardPage; + } } - else { - return null; - } + return null; } /** - * Get the SystemConnectionForm of the main page of SystemNewConnectionWizard, which - * contains all user enter connection attributes - */ + * Get the SystemConnectionForm of the main page of SystemNewConnectionWizard, which contains all user enter + * connection attributes + */ public SystemConnectionForm getMainPageForm() { - RSENewConnectionWizard ourWizard = getNewConnectionWizard(); + RSEAbstractNewConnectionWizard ourWizard = getNewConnectionWizard(); if (ourWizard != null) { //String[] systemTypes = parentFactory.getSystemTypes(); //IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypes[0]); - IWizardPage wizardPage = ourWizard.getDelegate().getMainPage(); + IWizardPage wizardPage = ourWizard.getStartingPage(); - if (wizardPage instanceof RSENewConnectionWizardDefaultDelegateMainPage) { - return ((RSENewConnectionWizardDefaultDelegateMainPage)wizardPage).getForm(); + if (wizardPage instanceof RSEDefaultNewConnectionWizardMainPage) { + return ((RSEDefaultNewConnectionWizardMainPage)wizardPage).getForm(); } else { return null; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java index 7fdfbeebf81..5c036b70db0 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizard.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. ********************************************************************************/ package org.eclipse.rse.ui.wizards; @@ -26,9 +26,6 @@ import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.dialogs.SystemWizardDialog; import org.eclipse.rse.ui.view.ISystemTree; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; @@ -66,7 +63,6 @@ import org.eclipse.ui.IWorkbench; *

  • Supports a {@link #setMinimumPageSize(int, int)} method to set the minimum width and height of the wizard. *
  • Supports a {@link #setPageError(IWizardPage)} method that can be called in performFinish when an error is detected on a * non-current page. This issues a message telling the user there is an error on another page. - *
  • Supports a simple {@link #setBusyCursor(boolean)} method to toggle the cursor between busy and normal * *

    To use this class, :

    *
      @@ -96,7 +92,6 @@ public abstract class AbstractSystemWizard protected Viewer viewer = null; protected String pageTitle; protected SystemWizardDialog owningDialog; - private Cursor waitCursor; /** * Default constructor. @@ -409,26 +404,6 @@ public abstract class AbstractSystemWizard else return -1; } - /** - * Set the cursor to the wait cursor (true) or restores it to the normal cursor (false). - */ - public void setBusyCursor(boolean setBusy) - { - if (setBusy) - { - // Set the busy cursor to all shells. - Display d = getShell().getDisplay(); - waitCursor = new Cursor(d, SWT.CURSOR_WAIT); - org.eclipse.rse.ui.dialogs.SystemPromptDialog.setDisplayCursor(getShell(), waitCursor); - } - else - { - org.eclipse.rse.ui.dialogs.SystemPromptDialog.setDisplayCursor(getShell(), null); - if (waitCursor != null) - waitCursor.dispose(); - waitCursor = null; - } - } // ---------------------------- // METHODS YOU MUST OVERRIDE... diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java index 7eab2c83e4b..fcf7386acf3 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/AbstractSystemWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. ********************************************************************************/ package org.eclipse.rse.ui.wizards; @@ -25,13 +25,11 @@ import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.messages.ISystemMessageLine; import org.eclipse.rse.ui.messages.SystemMessageLine; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; @@ -54,7 +52,6 @@ import org.eclipse.swt.widgets.Label; *
    1. Supports setting a default-focus control, which gets initial focus when the page is shown. *
    2. Supports helper methods to aid in population of the client area: {@link #addSeparatorLine(Composite, int)}, * {@link #addFillerLine(Composite,int)} and {@link #addGrowableFillerLine(Composite,int)}. - *
    3. Supports a simple {@link #setBusyCursor(boolean)} method to toggle the cursor between busy and normal * * *

      To use this class, :

      @@ -102,8 +99,6 @@ public abstract class AbstractSystemWizardPage private String helpId; private Composite parentComposite; private SystemMessage pendingMessage, pendingErrorMessage; - //private Hashtable helpIdPerControl; - private Cursor waitCursor; /** * Constructor when a unique page title is desired. @@ -112,29 +107,30 @@ public abstract class AbstractSystemWizardPage * @param pageTitle - the translated title of this page. Appears below the overall wizard title. * @param pageDescription - the translated description of this page. Appears to the right of the page title. */ - public AbstractSystemWizardPage(IWizard wizard, - String pageName, String pageTitle, String pageDescription) - { + public AbstractSystemWizardPage(IWizard wizard, String pageName, String pageTitle, String pageDescription) { super(pageName); setWizard(wizard); + if (pageTitle != null) - setTitle(pageTitle); + setTitle(pageTitle); else if (wizard instanceof AbstractSystemWizard) - setTitle(((AbstractSystemWizard)wizard).getWizardPageTitle()); - setDescription(pageDescription); + setTitle(((AbstractSystemWizard)wizard).getWizardPageTitle()); + + setDescription(pageDescription); } /** - * Constructor when the overall wizard page title is desired, as specified in - * {@link org.eclipse.rse.ui.wizards.AbstractSystemWizard#setWizardPageTitle(String)}. - *

      It is a somewhat common design pattern to use the same title for all pages in a wizard, and - * this makes it easy to do that. + * Constructor when the overall wizard page title is desired, as specified in + * {@link org.eclipse.rse.ui.wizards.AbstractSystemWizard#setWizardPageTitle(String)}. + *

      + * It is a somewhat common design pattern to use the same title for all pages in a wizard, and this makes it easy to + * do that. *

      * Your wizard must extend AbstractSystemWizard, and you must have called setWizardPageTitle. * @param wizard - the page's wizard. * @param pageName - the untranslated ID of this page. Not really used. * @param pageDescription - the translated description of this page. Appears to the right of the page title. */ - public AbstractSystemWizardPage(ISystemWizard wizard, + public AbstractSystemWizardPage(IWizard wizard, String pageName, String pageDescription) { this(wizard, pageName, null, pageDescription); @@ -150,9 +146,6 @@ public abstract class AbstractSystemWizardPage *

      * This id is stored, and then applied to each of the input-capable * controls in the main composite returned from createContents. - *

      - * Call this first to set the default help, then call {@link #setHelp(Control, String)} per individual - * control if control-unique help is desired. */ public void setHelp(String helpId) { @@ -162,19 +155,6 @@ public abstract class AbstractSystemWizardPage //System.out.println("Setting help to " + helpId); this.helpId = helpId; } - /** - * Configuration method.
      - * For setting control-specific help for a control on the wizard page. - *

      - * This overrides the default set in the call to {@link #setHelp(String)}. - */ - public void setHelp(Control c, String helpId) - { - SystemWidgetHelpers.setHelp(c, helpId); - //if (helpIdPerControl == null) - // helpIdPerControl = new Hashtable(); - //helpIdPerControl.put(c, helpId); - } /** * Configuration method.
      @@ -423,26 +403,6 @@ public abstract class AbstractSystemWizardPage // --------------- // HELPER METHODS // --------------- - /** - * Set the cursor to the wait cursor (true) or restores it to the normal cursor (false). - */ - public void setBusyCursor(boolean setBusy) - { - if (setBusy) - { - // Set the busy cursor to all shells. - Display d = getShell().getDisplay(); - waitCursor = new Cursor(d, SWT.CURSOR_WAIT); - org.eclipse.rse.ui.dialogs.SystemPromptDialog.setDisplayCursor(getShell(), waitCursor); - } - else - { - org.eclipse.rse.ui.dialogs.SystemPromptDialog.setDisplayCursor(getShell(), null); - if (waitCursor != null) - waitCursor.dispose(); - waitCursor = null; - } - } /** * Helper method
      diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java deleted file mode 100644 index 16d3e3ef65f..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizard.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; - -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.ui.INewWizard; - -public interface IRSENewConnectionWizard extends INewWizard { - - public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_POINT_ID = "org.eclipse.rse.ui.newConnectionWizardDelegates"; //$NON-NLS-1$ - public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_NAME = "newConnectionWizardDelegate"; //$NON-NLS-1$ - public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_ID = "id"; //$NON-NLS-1$ - public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_SYSTEMTYPE = "systemType"; //$NON-NLS-1$ - public static final String NEW_CONNECTION_WIZARD_DELEGATE_EXTENSION_CONFIG_ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ - - public IRSENewConnectionWizardDelegate getDelegate(); - - /** - * 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); - - /** - * 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); - - /** - * Sets the system type that was selected in the wizard. This will only be called if the wizard - * shows the system type selection page, i.e. if the wizard is not restricted to a single system type. - * @param systemType the system type. - */ - public void setSelectedSystemType(IRSESystemType systemType); -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java deleted file mode 100644 index bfa1ac97bef..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/IRSENewConnectionWizardDelegate.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; - -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.model.IHost; - -/** - * Interface for RSE new connection wizard delegate. - */ -public interface IRSENewConnectionWizardDelegate { - - public void init(RSENewConnectionWizard wizard, IRSESystemType systemType); - - public boolean isInitialized(); - - public void systemTypeChanged(IRSESystemType systemType); - - public RSENewConnectionWizard getWizard(); - - public IRSESystemType getSystemType(); - - public void addPages(); - - public boolean performFinish(); - - public boolean canFinish(); - - public IWizardPage getMainPage(); - - public IWizardPage getNextPage(IWizardPage page); - - public IWizardPage getPreviousPage(IWizardPage page); - - public IHost getDummyHost(); -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/ISystemNewConnectionWizardMainPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/ISystemNewConnectionWizardMainPage.java deleted file mode 100644 index 7ef2c1e7e18..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/ISystemNewConnectionWizardMainPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.ui.validators.ISystemValidator; - - - - -/** - * Interface for new Connection (ie Definition) wizard main page classes - */ -public interface ISystemNewConnectionWizardMainPage extends ISystemWizardPage -{ - - public String getSystemType(); - public String getConnectionName(); - public String getHostName(); - public String getConnectionDescription(); - public String getDefaultUserId(); - public int getDefaultUserIdLocation(); - public String getProfileName(); - /** - * Call this to restrict the system type that the user is allowed to choose - */ - public void restrictSystemType(String systemType); - /** - * Call this to restrict the system types that the user is allowed to choose - */ - public void restrictSystemTypes(String[] systemTypes); - - /** - * Call this to specify a validator for the connection name. It will be called per keystroke. - */ - public void setConnectionNameValidators(ISystemValidator[] v); - /** - * Call this to specify a validator for the hostname. It will be called per keystroke. - */ - public void setHostNameValidator(ISystemValidator v); - /** - * Call this to specify a validator for the userId. It will be called per keystroke. - */ - public void setUserIdValidator(ISystemValidator v); - /** - * This method allows setting of the initial user Id. Sometimes subsystems - * like to have their own default userId preference page option. If so, query - * it and set it here by calling this. - */ - public void setUserId(String userId); - /** - * Preset the connection name - */ - public void setConnectionName(String name); - /** - * Preset the host name - */ - public void setHostName(String name); - /** - * Set the profile names to show in the combo - */ - public void setProfileNames(String[] names); - /** - * Set the profile name to preselect - */ - public void setProfileNamePreSelection(String name); - /** - * Set the currently selected connection so as to better initialize input fields - */ - public void setCurrentlySelectedConnection(IHost connection); -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java deleted file mode 100644 index d6f9ea02b9b..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java +++ /dev/null @@ -1,556 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2007 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - moved SystemPreferencesManager to a new package - * - created and used RSEPreferencesManager - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; - -import java.util.Hashtable; -import java.util.Vector; - -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.RSEPreferencesManager; -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage; -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; -import org.eclipse.rse.internal.ui.view.SystemPerspectiveHelpers; -import org.eclipse.rse.model.DummyHost; -import org.eclipse.rse.model.SystemStartHere; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemConnectionForm; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.messages.SystemMessageDialog; - - -/** - * - */ -public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizardDelegate { - - private RSENewConnectionWizardDefaultDelegateMainPage mainPage; - private ISystemNewConnectionWizardPage[] subsystemFactorySuppliedWizardPages; - private Hashtable ssfWizardPagesPerSystemType = new Hashtable(); - private String defaultUserId; - private String defaultConnectionName; - private String defaultHostName; - private String[] activeProfileNames = null; - private int privateProfileIndex = -1; - private ISystemProfile privateProfile = null; - private IHost currentlySelectedConnection = null; - private String[] restrictSystemTypesTo; - private static String lastProfile = null; - private IHost _dummyHost; - - /** - * Constructor. - */ - public RSEDefaultNewConnectionWizardDelegate() { - } - - /** - * @see org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType) - */ - public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { - super.init(wizard, systemType); - restrictSystemType(systemType.getName()); - activeProfileNames = SystemStartHere.getSystemProfileManager().getActiveSystemProfileNames(); - systemTypeSelected(systemType.getName(), true); - } - - /** - * Call this to restrict the system type that the user is allowed to choose - */ - public void restrictSystemType(String systemType) - { - restrictSystemTypesTo = new String[1]; - restrictSystemTypesTo[0] = systemType; - if (mainPage != null) - mainPage.restrictSystemTypes(restrictSystemTypesTo); - } - /** - * Call this to restrict the system types that the user is allowed to choose - */ - public void restrictSystemTypes(String[] systemTypes) - { - this.restrictSystemTypesTo = systemTypes; - if (mainPage != null) - mainPage.restrictSystemTypes(systemTypes); - } - - public IHost getDummyHost() - { - if (_dummyHost == null) - { - _dummyHost = new DummyHost(mainPage.getHostName(), mainPage.getSystemType()); - } - return _dummyHost; - } - - - - /** - * Creates the wizard pages. - * This method is an override from the parent Wizard class. - */ - public void addPages() - { - try { - mainPage = createMainPage(restrictSystemTypesTo); - mainPage.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators()); - mainPage.setCurrentlySelectedConnection(currentlySelectedConnection); - if (defaultUserId != null) - mainPage.setUserId(defaultUserId); - if (defaultConnectionName != null) - mainPage.setConnectionName(defaultConnectionName); - if (defaultHostName != null) - mainPage.setHostName(defaultHostName); - - if (restrictSystemTypesTo != null) - mainPage.restrictSystemTypes(restrictSystemTypesTo); - - SystemStartHere.getSystemProfileManager().getDefaultPrivateSystemProfile(); - - // RSEUIPlugin.getShowProfilePage(); - /* DKM - I don't think we should force profiles into the faces of users - * we no longer default to "private" so hopefully this would never be - * desirable - * - // if there is a default private profile, we might want to show the rename profile page - if (defaultProfile != null) - { - // make private profile equal to default profile - privateProfile = defaultProfile; - - // get the private profile index in the list of active profiles - for (int idx=0; (privateProfileIndex<0) && (idx0)) - lastProfile = activeProfileNames[0]; - } - if (lastProfile != null) - mainPage.setProfileNamePreSelection(lastProfile); - } - } - - // getWizard().addPage((WizardPage)mainPage); - - } catch (Exception exc) - { - SystemBasePlugin.logError("New connection: Error in createPages: ",exc); //$NON-NLS-1$ - } - } - - /** - * Creates the wizard's main page. - * This method is an override from the parent class. - */ - protected RSENewConnectionWizardDefaultDelegateMainPage createMainPage(String[] restrictSystemTypesTo) - { - String pageTitle = getPageTitle(); - mainPage = new RSENewConnectionWizardDefaultDelegateMainPage(getWizard(), - pageTitle, - SystemResources.RESID_NEWCONN_PAGE1_DESCRIPTION); - getWizard().setOutputObject(null); - return mainPage; - } - - public String getPageTitle() { - - String pageTitle = null; - - if ((restrictSystemTypesTo == null) || (restrictSystemTypesTo.length != 1)) { - pageTitle = SystemResources.RESID_NEWCONN_PAGE1_TITLE; - } - else { - String onlySystemType = restrictSystemTypesTo[0]; - - if (onlySystemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL)) { - pageTitle = SystemResources.RESID_NEWCONN_PAGE1_LOCAL_TITLE; - } - else { - pageTitle = SystemResources.RESID_NEWCONN_PAGE1_REMOTE_TITLE; - pageTitle = SystemMessage.sub(pageTitle, "&1", onlySystemType); //$NON-NLS-1$ - } - } - - return pageTitle; - } - - /** - * Set the currently selected connection. Used to better default entry fields. - */ - public void setCurrentlySelectedConnection(IHost conn) - { - this.currentlySelectedConnection = conn; - } - - /** - * For "new" mode, allows setting of the initial user Id. Sometimes subsystems - * like to have their own default userId preference page option. If so, query - * it and set it here by calling this. - */ - public void setUserId(String userId) - { - defaultUserId = userId; - if (mainPage != null) - mainPage.setUserId(userId); - } - - /** - * Preset the connection name - */ - public void setConnectionName(String name) - { - defaultConnectionName = name; - if (mainPage != null) - mainPage.setConnectionName(name); - } - /** - * Preset the host name - */ - public void setHostName(String name) - { - defaultHostName = name; - if (mainPage != null) - mainPage.setHostName(name); - } - - /** - * Completes processing of the wizard. If this - * method returns true, the wizard will close; - * otherwise, it will stay active. - * This method is an override from the parent Wizard class. - * - * @return whether the wizard finished successfully - */ - public boolean performFinish() - { - boolean ok = mainPage.performFinish(); - if (!ok) - getWizard().setPageError(mainPage); - else if (ok && hasAdditionalPages()) - { - for (int idx=0; ok && (idx0))// might be in product that doesn't have iSeries plugins - sr.expandSubSystem(objSubSystems[0]); - else - sr.expandHost(conn); - } - else - sr.expandHost(conn); - } - - lastProfile = mainPage.getProfileName(); - getWizard().setOutputObject(conn); - } catch (Exception exc) - { - if (cursorSet) - getWizard().setBusyCursor(false); - cursorSet = false; - String msg = "Exception creating connection "; //$NON-NLS-1$ - SystemBasePlugin.logError(msg, exc); - SystemMessageDialog.displayExceptionMessage(getWizard().getShell(),exc); - ok = false; - } - } - //getShell().setCursor(null); - //busyCursor.dispose(); - if (cursorSet) - getWizard().setBusyCursor(false); - return ok; - } - return ok; - } - - // callbacks from rename page - - /** - * Set the new profile name specified on the rename profile page... - */ - protected void setNewPrivateProfileName(String newName) - { - activeProfileNames[privateProfileIndex] = newName; - if (mainPage != null) - { - mainPage.setProfileNames(activeProfileNames); - mainPage.setProfileNamePreSelection(newName); - } - } - - /** - * Return the main page of this wizard - */ - public IWizardPage getMainPage() - { - if (mainPage == null) { - addPages(); - } - - return mainPage; - } - - /** - * Return the form of the main page of this wizard - */ - public SystemConnectionForm getMainPageForm() - { - return (mainPage).getForm(); - } - - // ---------------------------------------- - // CALLBACKS FROM SYSTEM CONNECTION PAGE... - // ---------------------------------------- - /** - * Event: the user has selected a system type. - */ - public void systemTypeSelected(String systemType, boolean duringInitialization) - { - subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType); - if (!duringInitialization) - getWizard().getContainer().updateButtons(); - } - - /* - * Private method to get all the wizard pages from all the subsystem factories, given a - * system type. - */ - protected ISystemNewConnectionWizardPage[] getAdditionalWizardPages(String systemType) - { - // this query is expensive, so only do it once... - subsystemFactorySuppliedWizardPages = (ISystemNewConnectionWizardPage[])ssfWizardPagesPerSystemType.get(systemType); - if (subsystemFactorySuppliedWizardPages == null) - { - // query all affected subsystems for their list of additional wizard pages... - Vector additionalPages = new Vector(); - ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); - ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType, true); - for (int idx=0; idx0); - } - - /** - * Return the first additional page to show when user presses Next on the main page - */ - protected ISystemNewConnectionWizardPage getFirstAdditionalPage() - { - if ((subsystemFactorySuppliedWizardPages != null) && (subsystemFactorySuppliedWizardPages.length>0)) - { - IWizardPage previousPage = mainPage; - for (int idx=0; idx - *

    4. Connection Name - *
    5. Hostname/IP-address - *
    6. UserId - *
    7. Description - * - */ - -public class RSENewConnectionWizardDefaultDelegateMainPage - //extends WizardPage - extends AbstractSystemWizardPage - implements ISystemNewConnectionWizardMainPage, - ISystemMessageLine, ISystemConnectionFormCaller -{ - protected String[] restrictSystemTypesTo; - protected SystemConnectionForm form; - protected String parentHelpId; - protected RSEDefaultNewConnectionWizardDelegate delegate; - - /** - * Constructor. Use this when you want to supply your own title and - * description strings. - */ - public RSENewConnectionWizardDefaultDelegateMainPage(Wizard wizard, - String title, - String description) - { - super(wizard, "NewConnection", title, description); //$NON-NLS-1$ - parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$ - setHelp(parentHelpId); - form = getForm(); - } - - /** - * Call this to restrict the system type that the user is allowed to choose - */ - public void restrictSystemType(String systemType) - { - restrictSystemTypesTo = new String[1]; - restrictSystemTypesTo[0] = systemType; - form.restrictSystemTypes(restrictSystemTypesTo); - } - /** - * Call this to restrict the system types that the user is allowed to choose - */ - public void restrictSystemTypes(String[] systemTypes) - { - restrictSystemTypesTo = systemTypes; - form.restrictSystemTypes(restrictSystemTypesTo); - } - - /** - * Return the main wizard typed - */ - private RSEDefaultNewConnectionWizardDelegate getOurWizardDelegate() { - IWizard wizard = getWizard(); - - if (wizard instanceof RSENewConnectionWizard) { - IRSENewConnectionWizardDelegate delegate = ((RSENewConnectionWizard)wizard).getDelegate(); - - if (delegate instanceof RSEDefaultNewConnectionWizardDelegate) { - return (RSEDefaultNewConnectionWizardDelegate)delegate; - } - else { - return null; - } - } - else { - return null; - } - } - - - /** - * Overrride this if you want to supply your own form. This may be called - * multiple times so please only instantatiate if the form instance variable - * is null, and then return the form instance variable. - * @see org.eclipse.rse.ui.SystemConnectionForm - */ - protected SystemConnectionForm getForm() - { - if (form == null) - form = new SystemConnectionForm(this,this); - return form; - } - /** - * Call this to specify a validator for the connection name. It will be called per keystroke. - */ - public void setConnectionNameValidators(ISystemValidator[] v) - { - form.setConnectionNameValidators(v); - } - /** - * Call this to specify a validator for the hostname. It will be called per keystroke. - */ - public void setHostNameValidator(ISystemValidator v) - { - form.setHostNameValidator(v); - } - /** - * Call this to specify a validator for the userId. It will be called per keystroke. - */ - public void setUserIdValidator(ISystemValidator v) - { - form.setUserIdValidator(v); - } - - /** - * This method allows setting of the initial user Id. Sometimes subsystems - * like to have their own default userId preference page option. If so, query - * it and set it here by calling this. - */ - public void setUserId(String userId) - { - form.setUserId(userId); - } - - /** - * Set the profile names to show in the combo - */ - public void setProfileNames(String[] names) - { - form.setProfileNames(names); - } - /** - * Set the profile name to preselect - */ - public void setProfileNamePreSelection(String name) - { - form.setProfileNamePreSelection(name); - } - - /** - * Set the currently selected connection so as to better initialize input fields - */ - public void setCurrentlySelectedConnection(IHost connection) - { - form.setCurrentlySelectedConnection(connection); - } - - /** - * Preset the connection name - */ - public void setConnectionName(String name) - { - form.setConnectionName(name); - } - /** - * Preset the host name - */ - public void setHostName(String name) - { - form.setHostName(name); - } - - - /** - * CreateContents is the one method that must be overridden from the parent class. - * In this method, we populate an SWT container with widgets and return the container - * to the caller (JFace). This is used as the contents of this page. - */ - public Control createContents(Composite parent) - { - return form.createContents(parent, SystemConnectionForm.CREATE_MODE, parentHelpId); - } - /** - * Return the Control to be given initial focus. - * Override from parent. Return control to be given initial focus. - */ - protected Control getInitialFocusControl() - { - return form.getInitialFocusControl(); - } - - /** - * Completes processing of the wizard. If this - * method returns true, the wizard will close; - * otherwise, it will stay active. - * This method is an override from the parent Wizard class. - * - * @return whether the wizard finished successfully - */ - public boolean performFinish() - { - return form.verify(true); - } - - // --------------------------------- // - // METHODS FOR EXTRACTING USER DATA ... - // --------------------------------- // - /** - * Return user-entered System Type. - * Call this after finish ends successfully. - */ -/* public String getSystemType() - { - return form.getSystemType(); - } */ - /** - * Return user-entered Connection Name. - * Call this after finish ends successfully. - */ - public String getConnectionName() - { - return form.getConnectionName(); - } - /** - * Return user-entered Host Name. - * Call this after finish ends successfully. - */ - public String getHostName() - { - return form.getHostName(); - } - /** - * Return user-entered Default User Id. - * Call this after finish ends successfully. - */ - public String getDefaultUserId() - { - return form.getDefaultUserId(); - } - /** - * Return location where default user id is to be set. - * @see org.eclipse.rse.core.IRSEUserIdConstants - */ - public int getDefaultUserIdLocation() - { - return form.getUserIdLocation(); - } - /** - * Return user-entered Description. - * Call this after finish ends successfully. - */ - public String getConnectionDescription() - { - return form.getConnectionDescription(); - } - /** - * Return name of profile to contain new connection. - * Call this after finish ends successfully. - */ - public String getProfileName() - { - return form.getProfileName(); - } - - // ISystemMessageLine methods -// public void clearMessage() -// { -// setMessage(null); -// } - //public void clearErrorMessage() - //{ - //setErrorMessage(null); - //} - - public Object getLayoutData() - { - return null; - } - - public void setLayoutData(Object gridData) - { - } - - - - /** - * Return true if the page is complete, so to enable Finish. - * Called by wizard framework. - */ - public boolean isPageComplete() - { - //System.out.println("Inside isPageComplete. " + form.isPageComplete()); - if (form!=null) - return form.isPageComplete() && form.isConnectionUnique(); - else - return false; - } - - /** - * Intercept of WizardPage so we know when Next is pressed - */ - public IWizardPage getNextPage() - { - //if (wizard == null) - //return null; - //return wizard.getNextPage(this); - - // verify contents of page before going to main page - // this is done because the main page may have input that is not valid, but can - // only be verified when next is pressed since it requires a long running operation - boolean verify = form.verify(true); - - if (!verify) { - return null; - } - - RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); - if (newConnWizardDelegate != null) - { - return (IWizardPage)newConnWizardDelegate.getFirstAdditionalPage(); - } - else - return super.getNextPage(); - } - /** - * Intercept of WizardPge so we know when the wizard framework is deciding whether - * to enable next or not. - */ - public boolean canFlipToNextPage() - { - //return isPageComplete() && getNextPage() != null; - - RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); - if (newConnWizardDelegate != null) - { - return (isPageComplete() && newConnWizardDelegate.hasAdditionalPages() && form.isConnectionUnique()); - } - else - return super.canFlipToNextPage(); - } - - // ---------------------------------------- - // CALLBACKS FROM SYSTEM CONNECTION FORM... - // ---------------------------------------- - /** - * Event: the user has selected a system type. - */ - public void systemTypeSelected(String systemType, boolean duringInitialization) - { - RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); - if (newConnWizardDelegate != null) - { - newConnWizardDelegate.systemTypeSelected(systemType, duringInitialization); - } - } - - /** - * @see org.eclipse.rse.ui.wizards.ISystemNewConnectionWizardMainPage#getSystemType() - */ - public String getSystemType() { - RSEDefaultNewConnectionWizardDelegate newConnWizardDelegate = getOurWizardDelegate(); - return newConnWizardDelegate.getSystemType().getName(); - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java deleted file mode 100644 index dcd3b4e3c50..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardDelegate.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation. 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; - -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.rse.core.IRSESystemType; - -/** - * - */ -public abstract class RSENewConnectionWizardDelegate implements IRSENewConnectionWizardDelegate { - - private RSENewConnectionWizard wizard; - private IRSESystemType systemType; - private boolean isInitialized; - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#init(org.eclipse.rse.ui.wizards.RSENewConnectionWizard, org.eclipse.rse.core.IRSESystemType) - */ - public void init(RSENewConnectionWizard wizard, IRSESystemType systemType) { - setWizard(wizard); - setSystemType(systemType); - setInitialized(true); - } - - protected void setWizard(RSENewConnectionWizard wizard) { - this.wizard = wizard; - } - - protected void setSystemType(IRSESystemType systemType) { - this.systemType = systemType; - } - - protected void setInitialized(boolean isInitialized) { - this.isInitialized = true; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getWizard() - */ - public RSENewConnectionWizard getWizard() { - return wizard; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getSystemType() - */ - public IRSESystemType getSystemType() { - return systemType; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#isInitialized() - */ - public boolean isInitialized() { - return isInitialized; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#addPages() - */ - public void addPages() { - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#canFinish() - */ - public boolean canFinish() { - return false; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getNextPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getNextPage(IWizardPage page) { - return null; - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public IWizardPage getPreviousPage(IWizardPage page) { - return wizard.getStartingPage(); - } - - /** - * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#systemTypeChanged(org.eclipse.rse.core.IRSESystemType) - */ - public void systemTypeChanged(IRSESystemType systemType) { - - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java deleted file mode 100644 index cdbf27467db..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSENewConnectionWizardMainPage.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation 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 - * - * 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, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Javier Montalvo OrĂºs (Symbian) - Bug 149151: Use a Listbox for systemtype - * Martin Oberhuber (Wind River) - Use SelectionListener instead of SWT Listener - ********************************************************************************/ - -package org.eclipse.rse.ui.wizards; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.rse.core.IRSESystemType; -import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.List; -import org.eclipse.swt.widgets.Text; - -/** - * The New Connection Wizard main page that allows selection of system type. - */ -public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements SelectionListener { - - protected String parentHelpId; - protected List textSystemType; - protected Text descriptionSystemType; - protected IWizardPage nextPage; - protected IRSESystemType[] restrictedSystemTypes; - - /** - * Constructor. - * @param wizard the wizard. - * @param title the title of the wizard page. - * @param description the description of the wizard page. - */ - public RSENewConnectionWizardMainPage(IRSENewConnectionWizard wizard, String title, String description) { - super(wizard, "NewConnectionSystemType", title, description); //$NON-NLS-1$ - parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$ - setHelp(parentHelpId); - } - - /** - * @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); - - IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(textSystemType.getSelection()[0]); - - if(systemType!=null) { - descriptionSystemType.setText(systemType.getDescription()); - } - - return composite_prompts; - } - - public void restrictToSystemTypes(IRSESystemType[] systemTypes) { - this.restrictedSystemTypes = systemTypes; - } - - /** - * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#getInitialFocusControl() - */ - protected Control getInitialFocusControl() { - - if (textSystemType != null) { - return textSystemType; - } - else { - return null; - } - } - - /** - * @see org.eclipse.rse.ui.wizards.AbstractSystemWizardPage#performFinish() - */ - public boolean performFinish() { - return true; - } - - /** - * @see org.eclipse.jface.wizard.WizardPage#getNextPage() - */ - public IWizardPage getNextPage() { - - IWizard wizard = getWizard(); - - // if the wizard is a new connection wizard, which should always be the case, - // get the new connection wizard delegate for the selected system type and - // ask for the main page - if (wizard instanceof IRSENewConnectionWizard) { - String systemTypeStr = textSystemType.getSelection()[0]; - IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard; - newConnWizard.setSelectedSystemType(RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr)); - return newConnWizard.getDelegate().getMainPage(); - } - else { - return super.getNextPage(); - } - } - - /** - * Handle single-click on list - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - IWizard wizard = getWizard(); - if (wizard instanceof IRSENewConnectionWizard) { - String systemTypeStr = textSystemType.getSelection()[0]; - IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard; - - IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr); - newConnWizard.setSelectedSystemType(systemType); - descriptionSystemType.setText(systemType.getDescription()); - } - } - - /** - * Handle dbl-click on list: select, then go to next page - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) { - widgetSelected(e); - if (canFlipToNextPage()) { - getWizard().getContainer().showPage(getNextPage()); - } - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java index 49834143d45..3fd7c783330 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SubSystemServiceWizardPage.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2007 IBM Corporation 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. ********************************************************************************/ package org.eclipse.rse.ui.wizards; @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.jface.wizard.IWizard; +import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.IConnectorService; @@ -28,6 +29,7 @@ import org.eclipse.rse.core.subsystems.IServiceSubSystem; import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.model.DummyHost; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.widgets.services.ConnectorServiceElement; import org.eclipse.rse.ui.widgets.services.FactoryServiceElement; @@ -35,6 +37,8 @@ import org.eclipse.rse.ui.widgets.services.RootServiceElement; import org.eclipse.rse.ui.widgets.services.ServerLauncherPropertiesServiceElement; import org.eclipse.rse.ui.widgets.services.ServiceElement; import org.eclipse.rse.ui.widgets.services.ServicesForm; +import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard; +import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizardMainPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -81,15 +85,19 @@ public class SubSystemServiceWizardPage extends AbstractSystemNewConnectionWizar IServiceSubSystemConfiguration currentFactory = (IServiceSubSystemConfiguration)getSubSystemConfiguration(); - String systemTypeStr = getMainPage().getSystemType(); - //IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr); + IRSESystemType systemType = getMainPage() != null ? getMainPage().getSystemType() : null; + String systemTypeName = systemType != null ? systemType.getName() : null; - IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeStr, currentFactory.getServiceType()); + IServiceSubSystemConfiguration[] factories = getServiceSubSystemFactories(systemTypeName, currentFactory.getServiceType()); IHost dummyHost = null; - if (getWizard() instanceof RSENewConnectionWizard) + if (getWizard() instanceof RSEDefaultNewConnectionWizard) { - dummyHost = ((RSENewConnectionWizard)getWizard()).getDelegate().getDummyHost(); + RSEDefaultNewConnectionWizard wizard = (RSEDefaultNewConnectionWizard)getWizard(); + if (wizard.getMainPage() instanceof RSEDefaultNewConnectionWizardMainPage) { + dummyHost = new DummyHost(((RSEDefaultNewConnectionWizardMainPage)wizard.getMainPage()).getHostName(), + wizard.getSystemType() != null ? wizard.getSystemType().getName() : null); + } } // create elements for each diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java index bbb3c8932f4..56abbfafa8b 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/SystemSubSystemsPropertiesWizardPage.java @@ -115,7 +115,7 @@ public class SystemSubSystemsPropertiesWizardPage _thePage = cpage; //set the hostname for the page in case it's required - cpage.setHostname(getMainPage().getHostName()); + if (getMainPage() != null) cpage.setHostname(getMainPage().getHostName()); numAdded++; } @@ -151,7 +151,7 @@ public class SystemSubSystemsPropertiesWizardPage } //set the hostname for the page in case it's required - cpage.setHostname(getMainPage().getHostName()); + if (getMainPage() != null) cpage.setHostname(getMainPage().getHostName()); numAdded++; } @@ -199,8 +199,8 @@ public class SystemSubSystemsPropertiesWizardPage */ public boolean isPageComplete() { - String hostName = getMainPage().getHostName(); - if (!hostName.equals(_lastHostName)) + String hostName = getMainPage() != null ? getMainPage().getHostName() : null; + if (hostName != null && !hostName.equals(_lastHostName)) { hostNameUpdated(hostName); _lastHostName = hostName; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSEDynamicNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSEDynamicNewConnectionWizard.java new file mode 100644 index 00000000000..cf2eb98f9ca --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSEDynamicNewConnectionWizard.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import org.eclipse.rse.core.IRSESystemType; + +/** + * Interface to be implemented from dynamic RSE new connection + * wizards in order to influence attributes and behaviour of the + * wizard based on the current system state. + */ +public interface IRSEDynamicNewConnectionWizard { + + /** + * Validate the catgory id the wizard is proposed to be associated with. + * Dependent on the specified system type, the wizard may change the category + * id or just return the proposed category id. + * + * @param systemType The system type. Must be not null. + * @param proposedCategoryId The proposed category id. Might be null. + * @return The category id or null. + */ + public String validateCategoryId(IRSESystemType systemType, String proposedCategoryId); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSENewConnectionWizardDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSENewConnectionWizardDescriptor.java new file mode 100644 index 00000000000..79c6285bbac --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/IRSENewConnectionWizardDescriptor.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor; + +/** + * RSE new connection wizard descriptor. + */ +public interface IRSENewConnectionWizardDescriptor extends IRSEWizardDescriptor { + + /** + * Returns a semicolon separated list of system type id's this + * wizard is used for. The system type id's might contain wildcards + * ('*' or '?'). The method will return null if the + * attribute is not set. + * + * @return The list of system type id's or null. + */ + public String getDeclaredSystemTypeIds(); + + /** + * Returns the list of system type ids the wizard is supporting. + * The list is combined from the list of currently registered + * system types cleaned up by the ones not matching the declared + * system type ids. + * + * @return The list of supported system type ids. May be empty, + * but never null. + */ + public String[] getSystemTypeIds(); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEAbstractNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEAbstractNewConnectionWizard.java new file mode 100644 index 00000000000..2ec19f6683d --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEAbstractNewConnectionWizard.java @@ -0,0 +1,78 @@ +/******************************************************************************** + * Copyright (c) 2000, 2007 IBM Corporation 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 + * + * 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, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards.newconnection; + +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +/** + * Abstract base implementation of the RSE new connection wizard. + */ +public abstract class RSEAbstractNewConnectionWizard extends Wizard implements ISelectionChangedListener { + private IRSESystemType systemType; + private boolean isBusy; + + /** + * Constructor. + */ + public RSEAbstractNewConnectionWizard() { + systemType = null; + isBusy = false; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate#getSystemType() + */ + public IRSESystemType getSystemType() { + return systemType; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + public void selectionChanged(SelectionChangedEvent event) { + if (event != null && event.getSelection() instanceof IStructuredSelection) { + IStructuredSelection selection = (IStructuredSelection)event.getSelection(); + Object candidate = selection.getFirstElement(); + if (candidate instanceof IRSESystemType) systemType = (IRSESystemType)candidate; + } + } + + /** + * Sets the system cursor to a wait cursor. This method can be called in + * a display thread only! + * + * @param busy True if to show the wait cursor, false otherwise. + */ + protected void setBusyCursor(boolean busy) { + assert Display.findDisplay(Thread.currentThread()) != null; + + Shell shell = getShell(); + if (isBusy != busy) { + if (shell != null) { + shell.setCursor(busy ? shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT) : null); + } + isBusy = busy; + } + } +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java new file mode 100644 index 00000000000..212abda4270 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizard.java @@ -0,0 +1,440 @@ +/******************************************************************************** + * Copyright (c) 2000, 2007 IBM Corporation 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 + * + * 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, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards.newconnection; + +import java.util.Arrays; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemNewConnectionWizardPage; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; +import org.eclipse.rse.internal.ui.view.SystemPerspectiveHelpers; +import org.eclipse.rse.model.SystemStartHere; +import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; +import org.eclipse.rse.ui.ISystemMessages; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemConnectionForm; +import org.eclipse.rse.ui.SystemResources; +import org.eclipse.rse.ui.messages.SystemMessageDialog; + + +/** + * + */ +public class RSEDefaultNewConnectionWizard extends RSEAbstractNewConnectionWizard { + + private RSEDefaultNewConnectionWizardMainPage mainPage; + private ISystemNewConnectionWizardPage[] subsystemFactorySuppliedWizardPages; + private Map ssfWizardPagesPerSystemType = new Hashtable(); + private String defaultUserId; + private String defaultConnectionName; + private String defaultHostName; + private String[] activeProfileNames = null; + private int privateProfileIndex = -1; + private ISystemProfile privateProfile = null; + private IHost currentlySelectedConnection = null; + private static String lastProfile = null; + + /** + * Constructor. + */ + public RSEDefaultNewConnectionWizard() { + activeProfileNames = SystemStartHere.getSystemProfileManager().getActiveSystemProfileNames(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.AbstractNewConnectionWizard#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + public void selectionChanged(SelectionChangedEvent event) { + super.selectionChanged(event); + if (mainPage != null && getSystemType() != null) { + mainPage.restrictSystemType(getSystemType().getName()); + mainPage.setTitle(getPageTitle()); + } + } + + /** + * Creates the wizard pages. This method is an override from the parent Wizard class. + */ + public void addPages() { + try { + mainPage = createMainPage(getSystemType()); + mainPage.setConnectionNameValidators(SystemConnectionForm.getConnectionNameValidators()); + mainPage.setCurrentlySelectedConnection(currentlySelectedConnection); + + if (defaultUserId != null) + mainPage.setUserId(defaultUserId); + if (defaultConnectionName != null) + mainPage.setConnectionName(defaultConnectionName); + if (defaultHostName != null) + mainPage.setHostName(defaultHostName); + + if (mainPage != null && getSystemType() != null) + mainPage.restrictSystemType(getSystemType().getName()); + + String defaultProfileName = RSEUIPlugin.getDefault().getSystemRegistry().getSystemProfileManager().getDefaultPrivateSystemProfile().getName(); + + mainPage.setProfileNames(activeProfileNames); + // if there is no connection currently selected, default the profile to + // place the new connection into to be the first of: + // 1. the profile the last connection was created in, in this session + // 3. the default profile. + if (currentlySelectedConnection == null) { + if (lastProfile != null && "".equals(lastProfile))lastProfile = null; //$NON-NLS-1$ + if (lastProfile == null && activeProfileNames != null) { + List profileNames = Arrays.asList(activeProfileNames); + if (defaultProfileName != null && profileNames.contains(defaultProfileName)) + lastProfile = defaultProfileName; + + // find the first non empty profile if any. + for (int i = 0; i < activeProfileNames.length && lastProfile == null; i++) { + if (!"".equals(activeProfileNames[i])) { //$NON-NLS-1$ + lastProfile = activeProfileNames[i]; + } + } + } + + if (lastProfile != null) + mainPage.setProfileNamePreSelection(lastProfile); + } + + addPage(mainPage); + } catch (Exception exc) { + SystemBasePlugin.logError("New connection: Error in createPages: ", exc); //$NON-NLS-1$ + } + } + + /** + * Creates the wizard's main page. This method is an override from the parent class. + */ + protected RSEDefaultNewConnectionWizardMainPage createMainPage(IRSESystemType systemType) { + mainPage = new RSEDefaultNewConnectionWizardMainPage(this, getPageTitle(), SystemResources.RESID_NEWCONN_PAGE1_DESCRIPTION); + return mainPage; + } + + public String getPageTitle() { + + String pageTitle = null; + + if (getSystemType() == null) { + pageTitle = SystemResources.RESID_NEWCONN_PAGE1_TITLE; + } else { + String onlySystemType = getSystemType().getName(); + + if (onlySystemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL)) { + pageTitle = SystemResources.RESID_NEWCONN_PAGE1_LOCAL_TITLE; + } else { + pageTitle = SystemResources.RESID_NEWCONN_PAGE1_REMOTE_TITLE; + pageTitle = SystemMessage.sub(pageTitle, "&1", onlySystemType); //$NON-NLS-1$ + } + } + + return pageTitle; + } + + /** + * Set the currently selected connection. Used to better default entry fields. + */ + public void setCurrentlySelectedConnection(IHost conn) { + this.currentlySelectedConnection = conn; + } + + /** + * For "new" mode, allows setting of the initial user Id. Sometimes subsystems + * like to have their own default userId preference page option. If so, query + * it and set it here by calling this. + */ + public void setUserId(String userId) { + defaultUserId = userId; + if (mainPage != null) + mainPage.setUserId(userId); + } + + /** + * Preset the connection name + */ + public void setConnectionName(String name) { + defaultConnectionName = name; + if (mainPage != null) + mainPage.setConnectionName(name); + } + + /** + * Preset the host name + */ + public void setHostName(String name) { + defaultHostName = name; + if (mainPage != null) + mainPage.setHostName(name); + } + + /** + * Set's an error message to the wizard if a page, which is not the current page + * is having a page error. + */ + private void setPageError(IWizardPage page) { + IWizardPage currentPage = getContainer().getCurrentPage(); + if (currentPage != page) { + SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_WIZARD_PAGE_ERROR); + if (currentPage instanceof WizardPage) + ((WizardPage)currentPage).setErrorMessage(msg.getLevelOneText()); + } + } + + /** + * Completes processing of the wizard. If this + * method returns true, the wizard will close; + * otherwise, it will stay active. + * This method is an override from the parent Wizard class. + * + * @return whether the wizard finished successfully + */ + public boolean performFinish() { + boolean ok = mainPage.performFinish(); + if (!ok) + setPageError(mainPage); + else if (ok && hasAdditionalPages()) { + for (int idx = 0; ok && (idx < subsystemFactorySuppliedWizardPages.length); idx++) { + ok = subsystemFactorySuppliedWizardPages[idx].performFinish(); + if (!ok) + setPageError((IWizardPage)subsystemFactorySuppliedWizardPages[idx]); + } + } + if (ok) { + boolean cursorSet = true; + setBusyCursor(true); + ISystemRegistry sr = RSEUIPlugin.getDefault().getSystemRegistry(); + + // if private profile is not null, then we have to rename the private profile + // with the new profile name + if (privateProfile != null) { + try { + String newName = activeProfileNames[privateProfileIndex]; + sr.renameSystemProfile(privateProfile, newName); + } catch (SystemMessageException exc) { + SystemMessageDialog.displayMessage(getShell(), exc); + + ok = false; + } catch (Exception exc) { + setBusyCursor(false); + cursorSet = false; + String msg = "Exception renaming profile "; //$NON-NLS-1$ + SystemBasePlugin.logError(msg, exc); + SystemMessageDialog.displayExceptionMessage(getShell(), exc); + ok = false; + } + } + + if (ok) { + try { + String sysType = getSystemType() != null ? getSystemType().getName() : null; + IHost conn = sr.createHost(mainPage.getProfileName(), sysType, mainPage.getConnectionName(), mainPage.getHostName(), + mainPage.getConnectionDescription(), mainPage.getDefaultUserId(), mainPage.getDefaultUserIdLocation(), + subsystemFactorySuppliedWizardPages); + + setBusyCursor(false); + cursorSet = false; + + // a tweak that is the result of UCD feedback. Phil + if ((conn != null) && SystemPerspectiveHelpers.isRSEPerspectiveActive()) { + if (sysType.equals(IRSESystemType.SYSTEMTYPE_ISERIES)) { + ISubSystem[] objSubSystems = sr.getSubSystemsBySubSystemConfigurationCategory("nativefiles", conn); //$NON-NLS-1$ + if ((objSubSystems != null) && (objSubSystems.length > 0))// might be in product that doesn't have iSeries plugins + sr.expandSubSystem(objSubSystems[0]); + else + sr.expandHost(conn); + } else + sr.expandHost(conn); + } + + lastProfile = mainPage.getProfileName(); + } catch (Exception exc) { + if (cursorSet) + setBusyCursor(false); + cursorSet = false; + String msg = "Exception creating connection "; //$NON-NLS-1$ + SystemBasePlugin.logError(msg, exc); + SystemMessageDialog.displayExceptionMessage(getShell(), exc); + ok = false; + } + } + //getShell().setCursor(null); + //busyCursor.dispose(); + if (cursorSet) + setBusyCursor(false); + return ok; + } + return ok; + } + + // callbacks from rename page + + /** + * Set the new profile name specified on the rename profile page... + */ + protected void setNewPrivateProfileName(String newName) { + activeProfileNames[privateProfileIndex] = newName; + if (mainPage != null) { + mainPage.setProfileNames(activeProfileNames); + mainPage.setProfileNamePreSelection(newName); + } + } + + /** + * Return the main page of this wizard + */ + public IWizardPage getMainPage() { + if (mainPage == null) { + addPages(); + } + + return mainPage; + } + + /** + * Return the form of the main page of this wizard + */ + // public SystemConnectionForm getMainPageForm() + // { + // return (mainPage).getForm(); + // } + // ---------------------------------------- + // CALLBACKS FROM SYSTEM CONNECTION PAGE... + // ---------------------------------------- + /** + * Event: the user has selected a system type. + */ + public void systemTypeSelected(String systemType, boolean duringInitialization) { + subsystemFactorySuppliedWizardPages = getAdditionalWizardPages(systemType); + if (!duringInitialization) + getContainer().updateButtons(); + } + + /* + * Private method to get all the wizard pages from all the subsystem factories, given a + * system type. + */ + protected ISystemNewConnectionWizardPage[] getAdditionalWizardPages(String systemType) { + // this query is expensive, so only do it once... + subsystemFactorySuppliedWizardPages = (ISystemNewConnectionWizardPage[])ssfWizardPagesPerSystemType.get(systemType); + if (subsystemFactorySuppliedWizardPages == null) { + // query all affected subsystems for their list of additional wizard pages... + Vector additionalPages = new Vector(); + ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); + ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType, true); + for (int idx = 0; idx < factories.length; idx++) { + ISubSystemConfigurationAdapter adapter = (ISubSystemConfigurationAdapter)factories[idx].getAdapter(ISubSystemConfigurationAdapter.class); + + ISystemNewConnectionWizardPage[] pages = adapter.getNewConnectionWizardPages(factories[idx], this); + if (pages != null) { + for (int widx = 0; widx < pages.length; widx++) + additionalPages.addElement(pages[widx]); + } + } + subsystemFactorySuppliedWizardPages = new ISystemNewConnectionWizardPage[additionalPages.size()]; + for (int idx = 0; idx < subsystemFactorySuppliedWizardPages.length; idx++) + subsystemFactorySuppliedWizardPages[idx] = (ISystemNewConnectionWizardPage)additionalPages.elementAt(idx); + ssfWizardPagesPerSystemType.put(systemType, subsystemFactorySuppliedWizardPages); + } + return subsystemFactorySuppliedWizardPages; + } + + /** + * Return true if there are additional pages. This decides whether to enable the Next button + * on the main page + */ + protected boolean hasAdditionalPages() { + return (subsystemFactorySuppliedWizardPages != null) && (subsystemFactorySuppliedWizardPages.length > 0); + } + + /** + * Return the first additional page to show when user presses Next on the main page + */ + protected ISystemNewConnectionWizardPage getFirstAdditionalPage() { + if ((subsystemFactorySuppliedWizardPages != null) && (subsystemFactorySuppliedWizardPages.length > 0)) { + IWizardPage previousPage = mainPage; + for (int idx = 0; idx < subsystemFactorySuppliedWizardPages.length; idx++) { + ((IWizardPage)subsystemFactorySuppliedWizardPages[idx]).setPreviousPage(previousPage); + previousPage = (IWizardPage)subsystemFactorySuppliedWizardPages[idx]; + } + return subsystemFactorySuppliedWizardPages[0]; + } else + return null; + } + + // -------------------- + // PARENT INTERCEPTS... + // -------------------- + + /** + * Intercept of Wizard method so we can get the Next button behaviour to work right for the + * dynamically managed additional wizard pages. + */ + public IWizardPage getNextPage(IWizardPage page) { + if (!hasAdditionalPages()) + return null; + else { + int index = getAdditionalPageIndex(page); + if ((index == (subsystemFactorySuppliedWizardPages.length - 1))) + // last page or page not found + return null; + return (IWizardPage)subsystemFactorySuppliedWizardPages[index + 1]; + } + } + + /** + * @see org.eclipse.rse.ui.wizards.newconnection.RSEAbstractNewConnectionWizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getPreviousPage(IWizardPage page) { + return null; + } + + private int getAdditionalPageIndex(IWizardPage page) { + for (int idx = 0; idx < subsystemFactorySuppliedWizardPages.length; idx++) { + if (page == subsystemFactorySuppliedWizardPages[idx]) + return idx; + } + return -1; + } + + /** + * Intercept of Wizard method so we can take into account our additional pages + */ + public boolean canFinish() { + boolean ok = mainPage.isPageComplete(); + + if (ok && hasAdditionalPages()) { + for (int idx = 0; ok && (idx < subsystemFactorySuppliedWizardPages.length); idx++) + ok = subsystemFactorySuppliedWizardPages[idx].isPageComplete(); + } + return ok; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java new file mode 100644 index 00000000000..5e2920d77e4 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEDefaultNewConnectionWizardMainPage.java @@ -0,0 +1,304 @@ +/******************************************************************************** + * Copyright (c) 2002, 2007 IBM Corporation 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 + * + * 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, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Uwe Stieber (Wind River) - Reworked new connection wizard extension point. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards.newconnection; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.ui.ISystemConnectionFormCaller; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemConnectionForm; +import org.eclipse.rse.ui.validators.ISystemValidator; +import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + + + +/** + * Default main page of the "New Connection" wizard. + * This page asks for the primary information, including: + *
        + *
      • Connection Name + *
      • Hostname/IP-address + *
      • UserId + *
      • Description + *
      + */ + +public class RSEDefaultNewConnectionWizardMainPage extends AbstractSystemWizardPage implements ISystemConnectionFormCaller { + + protected String[] restrictSystemTypesTo; + protected final SystemConnectionForm form; + protected String parentHelpId; + + /** + * Constructor. Use this when you want to supply your own title and + * description strings. + */ + public RSEDefaultNewConnectionWizardMainPage(IWizard wizard, String title, String description) { + super(wizard, "NewConnection", title, description); //$NON-NLS-1$ + + parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$ + setHelp(parentHelpId); + form = new SystemConnectionForm(this, this); + } + + /** + * Call this to restrict the system type that the user is allowed to choose + * + * @param systemType The system type to restrict the page to. Must be not null. + */ + public void restrictSystemType(String systemType) { + assert systemType != null; + restrictSystemTypesTo = new String[] { systemType }; + form.restrictSystemTypes(restrictSystemTypesTo); + } + + /** + * Overrride this if you want to supply your own form. This may be called + * multiple times so please only instantatiate if the form instance variable + * is null, and then return the form instance variable. + * @see org.eclipse.rse.ui.SystemConnectionForm + */ + public SystemConnectionForm getForm() { + return form; + } + + /** + * Call this to specify a validator for the connection name. It will be called per keystroke. + */ + public void setConnectionNameValidators(ISystemValidator[] v) { + form.setConnectionNameValidators(v); + } + + /** + * Call this to specify a validator for the hostname. It will be called per keystroke. + */ + public void setHostNameValidator(ISystemValidator v) { + form.setHostNameValidator(v); + } + + /** + * Call this to specify a validator for the userId. It will be called per keystroke. + */ + public void setUserIdValidator(ISystemValidator v) { + form.setUserIdValidator(v); + } + + /** + * This method allows setting of the initial user Id. Sometimes subsystems + * like to have their own default userId preference page option. If so, query + * it and set it here by calling this. + */ + public void setUserId(String userId) { + form.setUserId(userId); + } + + /** + * Set the profile names to show in the combo + */ + public void setProfileNames(String[] names) { + form.setProfileNames(names); + } + + /** + * Set the profile name to preselect + */ + public void setProfileNamePreSelection(String name) { + form.setProfileNamePreSelection(name); + } + + /** + * Set the currently selected connection so as to better initialize input fields + */ + public void setCurrentlySelectedConnection(IHost connection) { + form.setCurrentlySelectedConnection(connection); + } + + /** + * Preset the connection name + */ + public void setConnectionName(String name) { + form.setConnectionName(name); + } + + /** + * Preset the host name + */ + public void setHostName(String name) { + form.setHostName(name); + } + + /** + * CreateContents is the one method that must be overridden from the parent class. + * In this method, we populate an SWT container with widgets and return the container + * to the caller (JFace). This is used as the contents of this page. + */ + public Control createContents(Composite parent) { + return form.createContents(parent, SystemConnectionForm.CREATE_MODE, parentHelpId); + } + + /** + * Return the Control to be given initial focus. + * Override from parent. Return control to be given initial focus. + */ + protected Control getInitialFocusControl() { + return form.getInitialFocusControl(); + } + + /** + * Completes processing of the wizard. If this + * method returns true, the wizard will close; + * otherwise, it will stay active. + * This method is an override from the parent Wizard class. + * + * @return whether the wizard finished successfully + */ + public boolean performFinish() { + return form.verify(true); + } + + // --------------------------------- // + // METHODS FOR EXTRACTING USER DATA ... + // --------------------------------- // + + /** + * Return user-entered Connection Name. + * Call this after finish ends successfully. + */ + public String getConnectionName() { + return form.getConnectionName(); + } + + /** + * Return user-entered Host Name. + * Call this after finish ends successfully. + */ + public String getHostName() { + return form.getHostName(); + } + + /** + * Return user-entered Default User Id. + * Call this after finish ends successfully. + */ + public String getDefaultUserId() { + return form.getDefaultUserId(); + } + + /** + * Return location where default user id is to be set. + * @see org.eclipse.rse.core.IRSEUserIdConstants + */ + public int getDefaultUserIdLocation() { + return form.getUserIdLocation(); + } + + /** + * Return user-entered Description. + * Call this after finish ends successfully. + */ + public String getConnectionDescription() { + return form.getConnectionDescription(); + } + + /** + * Return name of profile to contain new connection. + * Call this after finish ends successfully. + */ + public String getProfileName() { + return form.getProfileName(); + } + + + /** + * Return true if the page is complete, so to enable Finish. + * Called by wizard framework. + */ + public boolean isPageComplete() { + //System.out.println("Inside isPageComplete. " + form.isPageComplete()); + if (form != null) + return form.isPageComplete() && form.isConnectionUnique(); + else + return false; + } + + /** + * Intercept of WizardPage so we know when Next is pressed + */ + public IWizardPage getNextPage() { + //if (wizard == null) + //return null; + //return wizard.getNextPage(this); + + // verify contents of page before going to main page + // this is done because the main page may have input that is not valid, but can + // only be verified when next is pressed since it requires a long running operation + boolean verify = form.verify(true); + + if (!verify) { + return null; + } + + RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null; + if (newConnWizard != null) { + return (IWizardPage)newConnWizard.getFirstAdditionalPage(); + } else + return super.getNextPage(); + } + + /** + * Intercept of WizardPge so we know when the wizard framework is deciding whether + * to enable next or not. + */ + public boolean canFlipToNextPage() { + //return isPageComplete() && getNextPage() != null; + + RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null; + if (newConnWizard != null) { + return (isPageComplete() && newConnWizard.hasAdditionalPages() && form.isConnectionUnique()); + } else + return super.canFlipToNextPage(); + } + + // ---------------------------------------- + // CALLBACKS FROM SYSTEM CONNECTION FORM... + // ---------------------------------------- + /** + * Event: the user has selected a system type. + */ + public void systemTypeSelected(String systemType, boolean duringInitialization) { + RSEDefaultNewConnectionWizard newConnWizard = getWizard() instanceof RSEDefaultNewConnectionWizard ? (RSEDefaultNewConnectionWizard)getWizard() : null; + if (newConnWizard != null) { + newConnWizard.systemTypeSelected(systemType, duringInitialization); + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.ISystemNewConnectionWizardMainPage#getSystemType() + */ + public IRSESystemType getSystemType() { + if (getWizard() instanceof RSEDefaultNewConnectionWizard) { + RSEDefaultNewConnectionWizard wizard = (RSEDefaultNewConnectionWizard)getWizard(); + return wizard.getSystemType(); + } + + return null; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java new file mode 100644 index 00000000000..7de118d1c46 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSEMainNewConnectionWizard.java @@ -0,0 +1,246 @@ +/******************************************************************************** + * Copyright (c) 2000, 2007 IBM Corporation 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 + * + * 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, + * 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. + ********************************************************************************/ + +package org.eclipse.rse.ui.wizards.newconnection; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.IWizard; +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.ui.ISystemIconConstants; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemResources; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.INewWizard; +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 { + private IWizard selectedWizard; + private IRSESystemType selectedSystemType; + + private final RSENewConnectionWizardSelectionPage mainPage; + private final List initializedWizards = new LinkedList(); + private final List selectionChangedListener = new LinkedList(); + + private IRSESystemType[] restrictedSystemTypes; + private boolean onlySystemType; + + /** + * Constructor. + */ + public RSEMainNewConnectionWizard() { + super(); + setWindowTitle(SystemResources.RESID_NEWCONN_TITLE); + setForcePreviousAndNextButtons(true); + setNeedsProgressMonitor(true); + + mainPage = new RSENewConnectionWizardSelectionPage(); + initializedWizards.clear(); + selectionChangedListener.clear(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#getDefaultPageImage() + */ + public Image getDefaultPageImage() { + return RSEUIPlugin.getDefault().getImage(ISystemIconConstants.ICON_SYSTEM_NEWCONNECTIONWIZARD_ID); + } + + /** + * 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) { + restrictToSystemTypes(new IRSESystemType[] { systemType }); + } + + /** + * 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); + onSelectedSystemTypeChanged(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + assert listener != null; + if (!selectionChangedListener.contains(listener)) selectionChangedListener.add(listener); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + assert listener != null; + selectionChangedListener.remove(listener); + } + + /** + * Notify the registered selection changed listener about a changed selection. + */ + private void fireSelectionChanged() { + SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); + Iterator iterator = selectionChangedListener.iterator(); + while (iterator.hasNext()) { + ISelectionChangedListener listener = (ISelectionChangedListener)iterator.next(); + listener.selectionChanged(event); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() + */ + public ISelection getSelection() { + IRSESystemType selected = onlySystemType ? restrictedSystemTypes[0] : selectedSystemType; + return selected != null ? new StructuredSelection(selected) : null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) + */ + public void setSelection(ISelection selection) { + if (selection instanceof IStructuredSelection + && ((IStructuredSelection)selection).getFirstElement() instanceof IRSESystemType) { + selectedSystemType = (IRSESystemType)((IStructuredSelection)selection).getFirstElement(); + onSelectedSystemTypeChanged(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + setSelection(selection); + } + + /** + * Returns the wizard for the currently selected system type. + * + * @return The wizard for the currently selected system type. Must be never null. + */ + public IWizard getSelectedWizard() { + return selectedWizard; + } + + /** + * Called either by restrictToSystemTypes(...) or + * setSelectedSystemType(...) to notify that the selected system + * type has changed. + */ + 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; + selectedWizard = descriptor != null ? descriptor.getWizard() : null; + + // register the newly selected wizard as selection changed listener + if (selectedWizard instanceof ISelectionChangedListener) { + addSelectionChangedListener((ISelectionChangedListener)selectedWizard); + } + + // notify the selection changed event to the listeners + fireSelectionChanged(); + + // Initialize the wizard pages and remember which wizard we have initialized already + if (selectedWizard != null && !initializedWizards.contains(selectedWizard)) { + selectedWizard.addPages(); + initializedWizards.add(selectedWizard); + } + + // Update the wizard container UI elements + IWizardContainer container = getContainer(); + if (container != null && container.getCurrentPage() != null) { + container.updateWindowTitle(); + container.updateTitleBar(); + container.updateButtons(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#getStartingPage() + */ + public IWizardPage getStartingPage() { + if (onlySystemType && getSelectedWizard() != null) return getSelectedWizard().getStartingPage(); + return super.getStartingPage(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.AbstractSystemWizard#addPages() + */ + public void addPages() { + // It we are not restricted to only one system type, add the + // system type selection page. + if (!onlySystemType) addPage(mainPage); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) + */ + public IWizardPage getNextPage(IWizardPage page) { + IWizardPage nextPage = null; + if (page != null && page == mainPage && getSelectedWizard() != null) { + nextPage = getSelectedWizard().getStartingPage(); + } + + if (nextPage == null) super.getNextPage(page); + if (nextPage != null) nextPage.setPreviousPage(page); + + return nextPage; + } + + /* (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; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardDescriptor.java new file mode 100644 index 00000000000..b1243548a3c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardDescriptor.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.SystemTypeMatcher; +import org.eclipse.rse.ui.RSESystemTypeAdapter; +import org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardRegistry; +import org.eclipse.rse.ui.wizards.registries.RSEWizardDescriptor; + + +/** + * RSE new connection wizard descriptor implementation + */ +public class RSENewConnectionWizardDescriptor extends RSEWizardDescriptor implements IRSENewConnectionWizardDescriptor { + private final SystemTypeMatcher systemTypeMatcher; + + // The list of resolved system types supported by this wizard. + private List resolvedSystemTypes; + + /** + * Constructor + * + * @param wizardRegistry The parent wizard registry this element belongs to. Must be not null. + * @param element The configuration element which is declaring a wizard. Must be not null. + */ + public RSENewConnectionWizardDescriptor(RSEAbstractWizardRegistry wizardRegistry, IConfigurationElement element) { + super(wizardRegistry, element); + systemTypeMatcher = new SystemTypeMatcher(getDeclaredSystemTypeIds()); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.newconnection.INewConnectionWizardDescriptor#getDeclaredSystemTypeIds() + */ + public String getDeclaredSystemTypeIds() { + return getConfigurationElement().getAttribute("systemTypeIds"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.newconnection.INewConnectionWizardDescriptor#getSystemTypeIds() + */ + public String[] getSystemTypeIds() { + if (resolvedSystemTypes == null) { + resolvedSystemTypes = 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)); + } 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 + // change ones it has been initialized, we filter out the not matching ones + // here directly. + IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes(); + for (int i = 0; i < systemTypes.length; i++) { + IRSESystemType systemType = systemTypes[i]; + RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class)); + if (systemTypeMatcher.matches(systemType) + || (adapter != null + && adapter.acceptWizardDescriptor(getConfigurationElement().getName(), this))) { + if (!resolvedSystemTypes.contains(systemType.getId())) { + resolvedSystemTypes.add(systemType.getId()); + } + } + } + } + } + + return (String[])resolvedSystemTypes.toArray(new String[resolvedSystemTypes.size()]); + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardRegistry.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardRegistry.java new file mode 100644 index 00000000000..10de0e0c5fc --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardRegistry.java @@ -0,0 +1,144 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement; +import org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardRegistry; + +/** + * RSE New connection wizard registry implementation. + */ +public class RSENewConnectionWizardRegistry extends RSEAbstractWizardRegistry { + private final Map cache = new HashMap(); + + // Initialize-On-Demand Holder Class idiom: + // Lazy initialization and thread-safe single instance. + // See http://www-106.ibm.com/developerworks/java/library/j-jtp03304/ + private static class LazyInstanceHolder { + public static RSENewConnectionWizardRegistry instance = new RSENewConnectionWizardRegistry(); + } + + /** + * Return the parser instance. + */ + public static RSENewConnectionWizardRegistry getInstance() { + return LazyInstanceHolder.instance; + } + + /** + * Constructor. + */ + protected RSENewConnectionWizardRegistry() { + super(); + cache.clear(); + } + + protected IRSEWizardRegistryElement createWizardRegistryElementFor(IConfigurationElement element) { + IRSEWizardRegistryElement wizardElement = null; + + if ("newConnectionWizard".equals(element.getName())) wizardElement = new RSENewConnectionWizardDescriptor(this, element); //$NON-NLS-1$ + + return wizardElement != null ? wizardElement : super.createWizardRegistryElementFor(element); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardRegistry#getExtensionPointId() + */ + protected String getExtensionPointId() { + return RSEUIPlugin.getDefault().getBundle().getSymbolicName() + ".newConnectionWizard"; //$NON-NLS-1$ + } + + /** + * Returns the new connection wizard descriptor to use for the specified selection. + * The selection is expected to contain the selected system type as first element. + * + * @see #getWizardForSystemType(IRSESystemType) for more information. + * + * @param selection A structure selection containing the selected system type as first element. Must be not null. + * @return A registered new connection wizard descriptor or null. + */ + public IRSENewConnectionWizardDescriptor getWizardForSelection(IStructuredSelection selection) { + assert selection != null && selection.getFirstElement() instanceof IRSESystemType; + return getWizardForSystemType((IRSESystemType)selection.getFirstElement()); + } + + /** + * Returns the new connection wizard to use for the specified system type. + * Once queried for a specific system type, the method returns always the same wizard + * instance. If there are multiple wizards registered for a specific system type, + * the first wizard found will be taken and the other wizards will be dropped. If + * this case is happening, a corresponding warning message is send to the error log. + * + * @param systemType The selected system type to query the wizard for. Must be not null. + * @return A registered new connection wizard or the default RSE new connection wizard. Can be only null + * if the default RSE new connection wizard contribution has been removed from plugin.xml! + */ + public IRSENewConnectionWizardDescriptor getWizardForSystemType(IRSESystemType systemType) { + assert systemType != null; + + IRSENewConnectionWizardDescriptor descriptor = null; + String id = systemType.getId(); + + if (cache.containsKey(id)) { + Object candidate = cache.get(id); + if (candidate instanceof IRSENewConnectionWizardDescriptor) { + descriptor = (IRSENewConnectionWizardDescriptor)candidate; + } else { + cache.remove(id); + } + } + + // check if there is any wizard explicitly registered for the given system type + if (descriptor == null) { + // Get the list of all wizards and always walk through _all_ of them + // to find possible duplicates (which will be notified as warnings to + // the user) + IRSEWizardRegistryElement[] elements = getElements(); + for (int i = 0; i < elements.length; i++) { + IRSEWizardRegistryElement element = elements[i]; + if (element instanceof IRSENewConnectionWizardDescriptor) { + IRSENewConnectionWizardDescriptor candidate = (IRSENewConnectionWizardDescriptor)element; + String[] systemTypeIds = candidate.getSystemTypeIds(); + if (Arrays.asList(systemTypeIds).contains(id)) { + if (descriptor == null) { + descriptor = candidate; + } else { + String message = "Duplicated new connection wizard registration for system type ''{0}'' (wizard id = {1})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { id, candidate.getId()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } + } + } + } + + // if the descriptor here is still null, always return the default RSE + // new connection wizard descriptor + if (descriptor == null) { + IRSEWizardRegistryElement element = findElementById("org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard"); //$NON-NLS-1$ + if (element instanceof IRSENewConnectionWizardDescriptor) { + descriptor = (IRSENewConnectionWizardDescriptor)element; + } + } + } + + return descriptor; + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java new file mode 100644 index 00000000000..443fc5be7a9 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionPage.java @@ -0,0 +1,263 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ + +package org.eclipse.rse.ui.wizards.newconnection; + +import java.util.Arrays; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.AbstractTreeViewer; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +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.ViewerFilter; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.ui.RSESystemTypeAdapter; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemResources; +import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeContentProvider; +import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeLabelProvider; +import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreePatternFilter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; + +/** + * The New Connection Wizard main page that allows selection of system type. + */ +public class RSENewConnectionWizardSelectionPage extends WizardPage { + private final String helpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$; + + private IRSESystemType[] restrictedSystemTypes; + + private FilteredTree filteredTree; + private PatternFilter filteredTreeFilter; + private ViewerFilter filteredTreeWizardStateFilter; + private RSENewConnectionWizardSelectionTreeDataManager filteredTreeDataManager; + + 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) + */ + public boolean select(Viewer viewer, Object parentElement, Object element) { + Object[] children = ((ITreeContentProvider) ((AbstractTreeViewer) viewer).getContentProvider()).getChildren(element); + 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; + } + + RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(systemType.getAdapter(IRSESystemType.class)); + if (adapter != null) { + return adapter.isEnabled(systemType); + } + } + + return true; + } + } + + /** + * Constructor. + */ + public RSENewConnectionWizardSelectionPage() { + super("RSENewConnectionWizardSelectionPage"); //$NON-NLS-1$ + setTitle(getDefaultTitle()); + setDescription(getDefaultDescription()); + } + + /** + * Returns the default page title. + * + * @return The default page title. Must be never null. + */ + protected String getDefaultTitle() { + return SystemResources.RESID_NEWCONN_MAIN_PAGE_TITLE; + } + + /** + * Returns the default page description. + * + * @return The default page description. Must be never null. + */ + protected String getDefaultDescription() { + return SystemResources.RESID_NEWCONN_MAIN_PAGE_DESCRIPTION; + } + + /** + * 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 null. + */ + 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 null. + */ + protected IRSESystemType[] getRestrictToSystemTypes() { + return restrictedSystemTypes; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + 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); + filteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + + 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.setAutoExpandLevel(2); + + filteredTreeWizardStateFilter = new NewConnectionWizardStateFilter(); + treeViewer.addFilter(filteredTreeWizardStateFilter); + + treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + onSelectionChanged(); + } + }); + treeViewer.addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { +// onSelectionChanged(); + if (canFlipToNextPage()) getWizard().getContainer().showPage(getNextPage()); + } + }); + + filteredTreeDataManager = new RSENewConnectionWizardSelectionTreeDataManager(); + treeViewer.setInput(filteredTreeDataManager); + + // apply the standard dialog font + Dialog.applyDialogFont(composite); + + setControl(composite); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.DialogPage#performHelp() + */ + public void performHelp() { + PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpId); + } + + /** + * Called from the selection and double-click listener to propage the current + * system type selection to the underlaying wizard. + */ + protected void onSelectionChanged() { + IWizard wizard = getWizard(); + if (wizard instanceof ISelectionProvider && filteredTree.getViewer().getSelection() instanceof IStructuredSelection) { + ISelectionProvider selectionProvider = (ISelectionProvider)wizard; + IStructuredSelection filteredTreeSelection = (IStructuredSelection)filteredTree.getViewer().getSelection(); + if (filteredTreeSelection.getFirstElement() instanceof RSENewConnectionWizardSelectionTreeElement) { + RSENewConnectionWizardSelectionTreeElement element = (RSENewConnectionWizardSelectionTreeElement)filteredTreeSelection.getFirstElement(); + selectionProvider.setSelection(new StructuredSelection(element.getSystemType())); + if (element.getDescription() != null) { + setDescription(element.getDescription()); + } else { + if (!getDefaultDescription().equals(getDescription())) setDescription(getDefaultDescription()); + } + } + } + } + + /** + * @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() + */ + public boolean performFinish() { + return true; + } + + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java new file mode 100644 index 00000000000..54d315be0b7 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeDataManager.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.wizards.registries.IRSEWizardCategory; +import org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement; +import org.eclipse.rse.ui.wizards.registries.RSEAbstractWizardSelectionTreeDataManager; +import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeElement; + +/** + * New connection wizard selection tree data manager. + */ +public class RSENewConnectionWizardSelectionTreeDataManager extends RSEAbstractWizardSelectionTreeDataManager { + + /** + * Constructor. + */ + public RSENewConnectionWizardSelectionTreeDataManager() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEAbstractWizardSelectionTreeDataManager#initialize(java.util.Set) + */ + protected void initialize(Set rootElement) { + Map categoryCache = new HashMap(); + + // The new connection wizard selection is combining system types + // with registered new connection wizard. + IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().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); + 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. + String message = "System type " + systemType.getId() + " has no new connection wizard associated!"; //$NON-NLS-1$ //$NON-NLS-2$ + 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); + 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); + continue; + } + + // get the category. If failing, the wizard will end up as root element + IRSEWizardRegistryElement candidate = RSENewConnectionWizardRegistry.getInstance().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)categoryCache.get(category); + if (categoryElement == null) { + categoryElement = new RSEWizardSelectionTreeElement(category); + categoryElement.setParentElement(null); + categoryCache.put(category, categoryElement); + } + 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); + if (!(candidate instanceof IRSEWizardCategory)) { + rootElement.add(categoryElement); + break; + } + + category = (IRSEWizardCategory)candidate; + + RSEWizardSelectionTreeElement parentElement = (RSEWizardSelectionTreeElement)categoryCache.get(category); + if (parentElement == null) { + parentElement = new RSEWizardSelectionTreeElement(category); + parentElement.setParentElement(null); + categoryCache.put(category, parentElement); + } + parentElement.add(categoryElement); + categoryElement.setParentElement(parentElement); + + categoryElement = parentElement; + parentCategoryId = category.getParentCategoryId(); + } + } + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeElement.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeElement.java new file mode 100644 index 00000000000..2807afd25f6 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/newconnection/RSENewConnectionWizardSelectionTreeElement.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.newconnection; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.ui.RSESystemTypeAdapter; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement; +import org.eclipse.rse.ui.wizards.registries.RSEWizardSelectionTreeElement; +import org.eclipse.swt.graphics.Image; + +/** + * New connection wizard selection tree data element. + */ +public class RSENewConnectionWizardSelectionTreeElement extends RSEWizardSelectionTreeElement { + private static final long serialVersionUID = -6061418626602868827L; + + private final IRSESystemType systemType; + + /** + * Constructor. + * + * @param element The wizard registry element to associate. Must be not null. + */ + public RSENewConnectionWizardSelectionTreeElement(IRSESystemType systemType, IRSEWizardRegistryElement element) { + super(element); + assert systemType != null; + this.systemType = systemType; + } + + /** + * Returns the associated system type instance. + * + * @return The associated system type instance. Must be never null. + */ + public IRSESystemType getSystemType() { + return systemType; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEWizardSelectionTreeElement#getLabel() + */ + public String getLabel() { + return getSystemType().getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.internal.wizards.newconnection.RSEWizardSelectionTreeElement#getImage() + */ + public Image getImage() { + ImageRegistry imageRegistry = RSEUIPlugin.getDefault().getImageRegistry(); + String key = getSystemType().getId() + "::" + getWizardRegistryElement().getId(); //$NON-NLS-1$ + Image image = imageRegistry.get(key); + if (image == null) { + RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(getSystemType().getAdapter(IRSESystemType.class)); + if (adapter != null) { + ImageDescriptor descriptor = adapter.getImageDescriptor(getSystemType()); + image = descriptor.createImage(); + imageRegistry.put(key, image); + } + } + + return image; + } + + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (obj instanceof RSENewConnectionWizardSelectionTreeElement) { + return getSystemType().equals(((RSENewConnectionWizardSelectionTreeElement)obj).getSystemType()) + && getWizardRegistryElement().equals(((RSENewConnectionWizardSelectionTreeElement)obj).getWizardRegistryElement()); + } + return super.equals(obj); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return super.hashCode() + getSystemType().hashCode(); + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardCategory.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardCategory.java new file mode 100644 index 00000000000..f76b72bb589 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardCategory.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +/** + * Common wizard category descriptor used by the RSEAbstractWizardRegistry + * to handle wizard categories contributed via a wizard extension point. + *

      + * The IRSEWizardCategory interface is based on + * org.eclipse.ui.wizards.IWizardCategory interface which is + * unfortunately marked as not intended to be implemented by clients! + */ +public interface IRSEWizardCategory extends IRSEWizardRegistryElement { + + /** + * Returns the fully qualified parent category id or null + * if this wizard category is itself a root category. + * + * @return The parent category id or null. + */ + public String getParentCategoryId(); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardDescriptor.java new file mode 100644 index 00000000000..06cf8cca28d --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardDescriptor.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.swt.graphics.Image; + +/** + * Common wizard descriptor used by the RSEAbstractWizardRegistry + * to handle wizards contributed via a wizard extension point. + *

      + * The IRSEWizardDescriptor interface is based on + * org.eclipse.ui.wizards.IWizardDescriptor interface which is + * unfortunately marked as not intended to be implemented by clients! + */ +public interface IRSEWizardDescriptor extends IRSEWizardRegistryElement { + + /** + * The wizard implementation object instance. + * + * @return The wizard instance. Must be never null. + */ + public IWizard getWizard(); + + /** + * Returns a optional short description of the wizards purpose. + * + * @return The short wizard description or null. + */ + public String getDescription(); + + /** + * Returns the fully qualified category id if the wizard belongs + * to a category. If empty or null or the returned + * category id does not exist, the wizard will be sorted in as + * root element. + * + * @return The category id or null. + */ + public String getCategoryId(); + + /** + * Returns if the wizard can be finished without ever showing + * a specific page to the user. + * + * @return True if the wizard can finish without any page presentation, false otherwise. + */ + public boolean canFinishEarly(); + + /** + * Returns if the wizard has pages to show to the user. + * + * @return True if the wizard has presentable pages, false otherwise. + */ + public boolean hasPages(); + + /** + * Returns a optional image for representing the wizard within the UI besides + * the wizard name. The default wizard descriptor implementation returns always + * null. + * + * @return The wizard image or null if none. + */ + public Image getImage(); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardRegistryElement.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardRegistryElement.java new file mode 100644 index 00000000000..053de66655a --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/IRSEWizardRegistryElement.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +/** + * Basic interface of elements which can be handled by + * the RSEAbstractWizardRegistry. + */ +public interface IRSEWizardRegistryElement { + + /** + * Returns the full qualified unique id of the wizard registry element. + * + * @return The unique wizard registry element id. Must be never null. + */ + public String getId(); + + /** + * Returns the UI name of the wizard registry element. + * + * @return The UI name of the wizard registry element. Must be never null. + */ + public String getName(); + + /** + * Validates the wizard registry element. This method should return false + * if any required wizard registry element attribute is missing. Subclasses should + * override this method to validate additional required attribtes. + * + * @return True if the wizard registry element is valid, false otherwise. + */ + public boolean isValid(); + + /** + * Returns the parent wizard registry element if any or null + * if this element is a root element. + * + * @return The parent wizard registry element or null. + */ + public IRSEWizardRegistryElement getParent(); + + /** + * Returns the list of children if this element or an empty list if + * the element does not have children. + * + * @return The list of children wizard registry elements. May be empty but never null. + */ + public IRSEWizardRegistryElement[] getChildren(); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardRegistry.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardRegistry.java new file mode 100644 index 00000000000..cab3d6e5a03 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardRegistry.java @@ -0,0 +1,134 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import java.text.MessageFormat; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.rse.core.RSECorePlugin; + +/** + * Abstract core implementation of a wizard registry. + */ +public abstract class RSEAbstractWizardRegistry { + private final Map elements = new LinkedHashMap(); + private boolean isInitialized = false; + + /** + * Constructor. + */ + public RSEAbstractWizardRegistry() { + } + + /** + * Initialize the wizard registry by reading the associated wizard + * extension point. + */ + protected void initialize() { + elements.clear(); + + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(getExtensionPointId()); + for (int i = 0; i < elements.length; i++) { + IConfigurationElement element = elements[i]; + if (element == null) continue; + internalCreateRegistryElementFor(element); + } + + isInitialized = true; + } + + // Internal handle the creation of wizard registry elements. + private void internalCreateRegistryElementFor(IConfigurationElement element) { + assert element != null; + IRSEWizardRegistryElement wizardElement = createWizardRegistryElementFor(element); + if (wizardElement != null && wizardElement.isValid() && !elements.containsKey(wizardElement.getId())) { + elements.put(wizardElement.getId(), wizardElement); + } else if (wizardElement != null && wizardElement.isValid()){ + String message = "Wizard element contribution skipped. Non-unique element id (plugin: {0}, extension point: {1}, id: {2}, element name: {3})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), getExtensionPointId(), wizardElement.getId(), element.getName()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } else if (wizardElement != null) { + String message = "Wizard element contribution skipped. Invalid or incomplete (plugin: {0}, extension point: {1}, id: {2}, element name: {3})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), getExtensionPointId(), wizardElement.getId(), element.getName()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } else { + String message = "Wizard contribution skipped. Failed to create wizard descriptor (plugin: {0}, extension point: {1}, extension: {2})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), getExtensionPointId(), element.getDeclaringExtension().getLabel()}); + RSECorePlugin.getDefault().getLogger().logWarning(message); + } + } + + /** + * Returns if or if not the wizard registry has been initialized already. + * The initialized state of a wizard registry can be set only by calling + * the method RSEAbstractWizardRegistry.initialize(). + * + * @return true if the wizard registry is initialized, false otherwise. + */ + protected final boolean isInitialized() { + return isInitialized; + } + + /** + * Returns the fully qualified id of the wizard extension point. + * + * @return The fully qualified wizard extension point id. Must be never null. + */ + protected abstract String getExtensionPointId(); + + /** + * Creates a wizard registry element instance for the specified configuration element. + * The method may return null if the creation of the wizard registry element instance fails. + * + * @param element The configuration element. Must be not null. + * @return The wizard registry element instance or null. + */ + protected IRSEWizardRegistryElement createWizardRegistryElementFor(IConfigurationElement element) { + IRSEWizardRegistryElement wizardElement = null; + + if ("category".equals(element.getName())) wizardElement = new RSEWizardCategory(this, element); //$NON-NLS-1$ + if (wizardElement == null) new RSEWizardRegistryElement(this, element); + + return wizardElement; + } + + /** + * Returns the list of registered wizard registry elements. + * + * @return The list of registered wizard registry elements. May be empty but never null. + */ + public IRSEWizardRegistryElement[] getElements() { + if (!isInitialized()) initialize(); + return (IRSEWizardRegistryElement[])elements.values().toArray(new IRSEWizardRegistryElement[elements.values().size()]); + } + + + /** + * Look up a registered wizard registry element by the specified id. If no wizard + * registry element has been registered under this id, the method will return + * null. + * + * @param id The fully qualified wizard registry element id. Must be not null. + * @return The wizard or null. + */ + public IRSEWizardRegistryElement findElementById(String id) { + assert id != null; + IRSEWizardRegistryElement[] elements = getElements(); + for (int i = 0; i < elements.length; i++) { + if (id.equals(elements[i].getId())) return elements[i]; + } + return null; + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardSelectionTreeDataManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardSelectionTreeDataManager.java new file mode 100644 index 00000000000..8e6d93a1f79 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEAbstractWizardSelectionTreeDataManager.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import java.util.HashSet; +import java.util.Set; + + +/** + * Data manager for RSE wizard selection tree's. + */ +public abstract class RSEAbstractWizardSelectionTreeDataManager { + private final Set rootElement = new HashSet(); + + /** + * Constructor. + */ + public RSEAbstractWizardSelectionTreeDataManager() { + rootElement.clear(); + + // start the initialization of the data tree. + initialize(rootElement); + } + + /** + * Returns the children of this wizard selection tree element. + * + * @return The list of children, May be empty but never null. + */ + public RSEWizardSelectionTreeElement[] getChildren() { + return (RSEWizardSelectionTreeElement[])rootElement.toArray(new RSEWizardSelectionTreeElement[rootElement.size()]); + } + + /** + * Initialize the data tree. + * + * @param rootElement The root element which is the container for all user visible tree root elements. Must be not null. + */ + protected abstract void initialize(Set rootElement); +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardCategory.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardCategory.java new file mode 100644 index 00000000000..84f946948a6 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardCategory.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.core.runtime.IConfigurationElement; + +/** + * Default implementation of the IRSEWizardCategory interface. + */ +public class RSEWizardCategory extends RSEWizardRegistryElement implements IRSEWizardCategory { + + /** + * Constructor + * + * @param wizardRegistry The parent wizard registry this element belongs to. Must be not null. + * @param element The configuration element which is declaring a wizard category. Must be not null. + */ + public RSEWizardCategory(RSEAbstractWizardRegistry wizardRegistry, IConfigurationElement element) { + super(wizardRegistry, element); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardCategory#getParentCategoryId() + */ + public String getParentCategoryId() { + return getConfigurationElement().getAttribute("parentCategoryId"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.RSEWizardRegistryElement#getParent() + */ + public IRSEWizardRegistryElement getParent() { + String parentCategoryId = getParentCategoryId(); + if (parentCategoryId != null && !"".equals(parentCategoryId.trim())) { //$NON-NLS-1$ + // Try to get the corresponding wizard category element for this id + return getWizardRegistry().findElementById(parentCategoryId); + } + return super.getParent(); + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardDescriptor.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardDescriptor.java new file mode 100644 index 00000000000..7edec5077b3 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardDescriptor.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.swt.graphics.Image; + +/** + * Default implementation of the IRSEWizardDescriptor interfaces. + */ +public class RSEWizardDescriptor extends RSEWizardRegistryElement implements IRSEWizardDescriptor { + + private IWizard wizard; + + /** + * Constructor + * + * @param wizardRegistry The parent wizard registry this element belongs to. Must be not null. + * @param element The configuration element which is declaring a wizard. Must be not null. + */ + public RSEWizardDescriptor(RSEAbstractWizardRegistry wizardRegistry, IConfigurationElement element) { + super(wizardRegistry, element); + + // Try to instanciate the wizard. + try { + wizard = (IWizard)element.createExecutableExtension("class"); //$NON-NLS-1$ + } catch (CoreException e) { + String message = "RSE new connection wizard failed creation (plugin: {0}, id: {1})."; //$NON-NLS-1$ + message = MessageFormat.format(message, new Object[] { element.getContributor().getName(), element.getDeclaringExtension().getSimpleIdentifier()}); + RSECorePlugin.getDefault().getLogger().logError(message, e); + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#isValid() + */ + public boolean isValid() { + return super.isValid() && wizard != null; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#getWizard() + */ + public IWizard getWizard() { + return wizard; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#canFinishEarly() + */ + public boolean canFinishEarly() { + String canFinishEarly = getConfigurationElement().getAttribute("canFinishEarly"); //$NON-NLS-1$ + if (canFinishEarly != null) return Boolean.TRUE.equals(Boolean.valueOf(canFinishEarly)); + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#getCategoryId() + */ + public String getCategoryId() { + return getConfigurationElement().getAttribute("categoryId"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#getDescription() + */ + public String getDescription() { + return getConfigurationElement().getAttribute("description"); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#hasPages() + */ + public boolean hasPages() { + String hasPages = getConfigurationElement().getAttribute("hasPages"); //$NON-NLS-1$ + if (hasPages != null) return Boolean.TRUE.equals(Boolean.valueOf(hasPages)); + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardDescriptor#getImage() + */ + public Image getImage() { + return null; + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardRegistryElement.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardRegistryElement.java new file mode 100644 index 00000000000..942776a98d4 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardRegistryElement.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.core.runtime.IConfigurationElement; + +/** + * Default implementation of the IRSEWizardRegistryElement interface + */ +public class RSEWizardRegistryElement implements IRSEWizardRegistryElement { + protected final static IRSEWizardRegistryElement[] NO_ELEMENTS = new IRSEWizardRegistryElement[0]; + + private final IConfigurationElement element; + private final RSEAbstractWizardRegistry wizardRegistry; + + private String id; + private String name; + + /** + * Constructor. + * + * @param wizardRegistry The parent wizard registry this element belongs to. Must be not null. + * @param element The configuration element which is declaring a wizard category. Must be not null. + */ + public RSEWizardRegistryElement(RSEAbstractWizardRegistry wizardRegistry, IConfigurationElement element) { + assert wizardRegistry != null && element != null; + + // Store the wizard registry reference + this.wizardRegistry = wizardRegistry; + + // Store the configuration element reference + this.element = element; + + // Read the required attributes from the configuration element and + // check that these attributes are really set. + id = element.getAttribute("id"); //$NON-NLS-1$ + name = element.getAttribute("name"); //$NON-NLS-1$ + } + + /** + * Returns the parent wizard registry of this element. + * + * @return The parent wizard registry. Must be never null. + */ + protected final RSEAbstractWizardRegistry getWizardRegistry() { + return wizardRegistry; + } + + /** + * Returns the associated configuration element. + * + * @return The configration element. Must be never null. + */ + protected final IConfigurationElement getConfigurationElement() { + assert element != null; + return element; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardCategory#getId() + */ + public String getId() { + return id; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardCategory#getName() + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IWizardCategory#isValid() + */ + public boolean isValid() { + return id != null && name != null; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement#getChildren() + */ + public IRSEWizardRegistryElement[] getChildren() { + return NO_ELEMENTS; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.ui.wizards.registries.IRSEWizardRegistryElement#getParent() + */ + public IRSEWizardRegistryElement getParent() { + return null; + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeContentProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeContentProvider.java new file mode 100644 index 00000000000..eccfde31b48 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeContentProvider.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * Standard RSE wizard selection tree label provider. + */ +public class RSEWizardSelectionTreeContentProvider implements ITreeContentProvider { + private final static Object[] NO_ELEMENTS = new Object[0]; + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof RSEAbstractWizardSelectionTreeDataManager) { + return ((RSEAbstractWizardSelectionTreeDataManager)parentElement).getChildren(); + } else if (parentElement instanceof RSEWizardSelectionTreeElement) { + return ((RSEWizardSelectionTreeElement)parentElement).getChildren(); + } + return NO_ELEMENTS; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + public Object getParent(Object element) { + if (element instanceof RSEWizardSelectionTreeElement) { + return ((RSEWizardSelectionTreeElement)element).getParentElement(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + public boolean hasChildren(Object element) { + return getChildren(element).length > 0; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeElement.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeElement.java new file mode 100644 index 00000000000..7f309a8b09e --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeElement.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.swt.graphics.Image; + +/** + * Data element for RSE wizard selection tree's. + */ +public class RSEWizardSelectionTreeElement { + private final List children = new ArrayList(); + private final IRSEWizardRegistryElement wizardRegistryElement; + private RSEWizardSelectionTreeElement parent; + + /** + * Constructor. + * + * @param element The wizard registry element to associate. Must be not null. + */ + public RSEWizardSelectionTreeElement(IRSEWizardRegistryElement element) { + assert element != null; + wizardRegistryElement = element; + children.clear(); + } + + /** + * Returns the associated wizard registry element + * + * @return The wizard registry element. Must be never null. + */ + public IRSEWizardRegistryElement getWizardRegistryElement() { + return wizardRegistryElement; + } + + /** + * Adds a new child to this RSE wizard selection tree element. If + * the child had been added already before, the method will do nothing. + * + * @param child The child to add. Must be not null. + */ + public void add(RSEWizardSelectionTreeElement child) { + assert child != null; + if (!children.contains(child)) { + children.add(child); + } + } + + /** + * Removes the given child from the list of children. If the child + * has not been added before, the method will do nothing. + * + * @param child The child to remove. Must be not null. + */ + public void remove(RSEWizardSelectionTreeElement child) { + assert child != null; + children.remove(child); + } + + /** + * Returns the children of this wizard selection tree element. + * + * @return The list of children, May be empty but never null. + */ + public RSEWizardSelectionTreeElement[] getChildren() { + return (RSEWizardSelectionTreeElement[])children.toArray(new RSEWizardSelectionTreeElement[children.size()]); + } + + /** + * Associate a parent element to this wizard selection tree element. + * + * @param parent The parent element to associate or null. + */ + public void setParentElement(RSEWizardSelectionTreeElement parent) { + this.parent = parent; + } + + /** + * Returns the associated parent element of this wizard selection tree element. + * + * @return The parent element or null. + */ + public RSEWizardSelectionTreeElement getParentElement() { + return this.parent; + } + + /** + * Returns the description to show in the wizards message area. + * + * @return The description to show in the wizards message are or null. + */ + public String getDescription() { + if (getWizardRegistryElement() instanceof IRSEWizardDescriptor) { + return ((IRSEWizardDescriptor)getWizardRegistryElement()).getDescription(); + } + return null; + } + + /** + * Returns the label to show in the tree. + * + * @return The label to use for the tree node or null. + */ + public String getLabel() { + return getWizardRegistryElement().getName(); + } + + /** + * Returns the image to show in the tree. + * + * @return The image to use for the tree node or null. + */ + public Image getImage() { + if (getWizardRegistryElement() instanceof IRSEWizardDescriptor) { + return ((IRSEWizardDescriptor)getWizardRegistryElement()).getImage(); + } else if (getWizardRegistryElement() instanceof IRSEWizardCategory) { + ImageRegistry imageRegistry = RSEUIPlugin.getDefault().getImageRegistry(); + String key = "category::" + getWizardRegistryElement().getId(); //$NON-NLS-1$ + Image image = imageRegistry.get(key); + if (image == null) { + ImageDescriptor descriptor = RSEUIPlugin.getDefault().getImageDescriptorFromIDE("obj16/fldr_obj.gif"); //$NON-NLS-1$ + if (descriptor != null) { + image = descriptor.createImage(); + imageRegistry.put(key, image); + } + } + return image; + } + + return null; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (obj instanceof RSEWizardSelectionTreeElement) { + return getWizardRegistryElement().equals(((RSEWizardSelectionTreeElement)obj).getWizardRegistryElement()); + } + return super.equals(obj); + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return getWizardRegistryElement().hashCode(); + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeLabelProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeLabelProvider.java new file mode 100644 index 00000000000..41c9a5e7178 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreeLabelProvider.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * Standard RSE wizard selection tree label provider. + */ +public class RSEWizardSelectionTreeLabelProvider extends LabelProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + public Image getImage(Object element) { + Image image = null; + + if (element instanceof RSEWizardSelectionTreeElement) { + image = ((RSEWizardSelectionTreeElement)element).getImage(); + } + + return image; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) + */ + public String getText(Object element) { + String text = super.getText(element); + + if (element instanceof RSEWizardSelectionTreeElement) { + text = ((RSEWizardSelectionTreeElement)element).getLabel(); + } + + return text; + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java new file mode 100644 index 00000000000..1ccaf4c2e4d --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/registries/RSEWizardSelectionTreePatternFilter.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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: + * Uwe Stieber (Wind River) - initial API and implementation. + *******************************************************************************/ +package org.eclipse.rse.ui.wizards.registries; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.ui.dialogs.PatternFilter; + +/** + * Standard RSE wizard selection tree pattern filter. + */ +public class RSEWizardSelectionTreePatternFilter extends PatternFilter { + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.PatternFilter#isElementSelectable(java.lang.Object) + */ + public boolean isElementSelectable(Object element) { + if (element instanceof RSEWizardSelectionTreeElement) { + return !(((RSEWizardSelectionTreeElement)element).getWizardRegistryElement() instanceof IRSEWizardCategory); + } + return super.isElementSelectable(element); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.PatternFilter#isLeafMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object) + */ + 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 { + return wordMatches(treeElement.getLabel()); + } + + } + + return super.isLeafMatch(viewer, element); + } + +} diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.properties b/rse/plugins/org.eclipse.rse.ui/plugin.properties index 9c556fb1a81..7403044e506 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.properties +++ b/rse/plugins/org.eclipse.rse.ui/plugin.properties @@ -20,9 +20,10 @@ pluginName = RSE UI providerName = Eclipse.org +extPoint.newConnectionWizard = New Connection Wizard extPoint.subsystemConfigurations = Remote Subsystem Configurations extPoint.popupMenus = Remote Object Popup Menu Actions -extPoint.propertyPages = RRemote Object Property Pages +extPoint.propertyPages = Remote Object Property Pages extPoint.remoteSystemsViewPreferencesActions = Remote Systems View Preferences Actions extPoint.compile = Remote Compile Commands extPoint.archivehandlers = Remote Archive Handlers @@ -126,4 +127,6 @@ ProjectFilter.description=Hides RSE internal projects # Creation wizard Creation.category.name = Remote System Explorer Creation.connection.name = Connection -Creation.connection.description = Create a new connection to a remote system \ No newline at end of file +Creation.connection.description = Create a new connection to a remote system + +DefaultRSENewConnectionWizard.name=RSE Default New Connection Wizard diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.xml b/rse/plugins/org.eclipse.rse.ui/plugin.xml index cc973a111f7..3baaaff34d2 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.xml +++ b/rse/plugins/org.eclipse.rse.ui/plugin.xml @@ -485,7 +485,7 @@ Contributors: - + @@ -605,6 +605,19 @@ Contributors: + + + + + @@ -616,7 +629,7 @@ Contributors: + + + + + + + + This extension point is used to register new connection creation wizard extensions. New connection creation wizards appear as choices within the "New Connection" dialog, and are used to create connections from the registered system types. New connection creation wizards can be organized in categories. Uncategorized wizards or wizards with invalid category paths will be sorted in as non-categorized root element. +<p> +Each system type must have exactly one new connection wizard associated. In case multiple new connection wizard contributions would match the same system type, the new connection wizard which matched the system type first, will be used. +<p> +One new connection wizard may be registered for multiple system types. Such wizards should implement the <code>org.eclipse.jface.viewers.ISelectionChangedListener</code> interface to get notified about the currently selected system type within the new connection system type selection page. +<p> +New connection wizard may have the need of contributing different attribute values for the same attribute dependent on the current system type selection. These wizards should implement the <code>org.eclipse.rse.ui.wizards.newconnection.IRSEDynamicNewConnectionWizard</code>. + + + + + + + (no description available) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A unique identifier. + + + + + + + A translatable name that will be used in the UI. + + + + + + + + + + A translatable short description of the wizard. + + + + + + + + + + A semicolon separated list of RSE system type id's this wizard will be registered for. RSE system type id's which have already a new connection creation wizard registered are ignored. Wildcards '*' and '?' are allowed. If empty, all registered RSE system types will be queried if accepting this new connection creation wizard by id. + + + + + + + A fully qualified name of the Java class implementing <code>org.eclipse.jface.wizard.IWizard</code>. + + + + + + + + + + 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. + + + + + + + + Whether the wizard is capable of finishing without ever showing pages to the user. + + + + + + + Whether the wizard provides any pages. + + + + + + + + + + + + A unique identifier. + + + + + + + A translatable name that will be used in the UI. + + + + + + + + + + The fully qualified id of the parent category or empty if it is a root category. + + + + + + + + + + + + + The following is an example of this extension point's usage: + +<p> +<pre> + <extension + point="org.eclipse.rse.ui.newConnectionWizard"> + <category id="org.eclipse.rse.ui.wizards.newconnection.default.category" + name="%Creation.category.name"/> + <newConnectionWizard + id="org.eclipse.rse.ui.wizards.newconnection.RSEDefaultnNewConnectionWizard" + class="org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard" + name="%DefaultRSENewConnectionWizard.name" + canFinishEarly="false" + categoryId="org.eclipse.rse.ui.wizards.newconnection.default.category" + hasPages="true"> + </newConnectionWizard> + </extension> +</pre> +</p> + + + + + + + + + The provider of a new connection creation wizard for a certain system type must implement <samp>org.eclipse.jface.wizard.IWizard</samp>. + + + + + + + + + The default RSE new connection wizard as contributed from <code>org.eclipse.rse.ui</code> plug-in. + + + + + + + + + Copyright (c) 2006, 2007 IBM Corporation 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: +IBM Corporation - initial API and implementation +Uwe Stieber (Wind River) - rework to take standard Eclipse IWizard's + + + + diff --git a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegates.exsd b/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegates.exsd deleted file mode 100644 index ec56499c397..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/schema/newConnectionWizardDelegates.exsd +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - This extension point allows a New Connection wizard delegate to be provided for a certain system type. This is useful for those system types that need New Connection wizard pages which are different from the default pages supplied by RSE. - - - - - - - (no description available) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (no description available) - - - - - - - A unique identifier for this extension. - - - - - - - The system type ID. If not specified, all registered system types will be checked if any of them accepts this contributed new connection wizard delegate. - - - - - - - A class that implements <samp>org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate</samp> - - - - - - - - - - - - - - - The following is an example of this extension point's usage: - -<p> -<pre> - <extension point="org.eclipse.rse.ui.newConnectionWizardDelegates"> - <newConnectionWizardDelegate - class="com.abc.SerialConnectionWizardDelegate" - systemType="Embedded-Linux-Serial"/> - </extension> -</pre> -</p> - - - - - - - - - The provider of a new connection delegate for a certain system type must implement <samp>org.eclipse.rse.ui.wizards.IRSENewConnectionWizardDelegate</samp>. Instead of extending the interface, it is recommended that the abstract class <samp>org.eclipse.rse.ui.wizards.RSENewConnectionWizardDelegate</samp> be extended. - - - - - - - - - By default there are not contributions to this. - - - - - - - - - Copyright (c) 2006 IBM Corporation. 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: -IBM Corporation - initial API and implementation - - - - diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/internal/subsystems/SubSystemConfigurationProxy.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/internal/subsystems/SubSystemConfigurationProxy.java index 90b44f73da2..ea7fde2d277 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/internal/subsystems/SubSystemConfigurationProxy.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/internal/subsystems/SubSystemConfigurationProxy.java @@ -20,10 +20,8 @@ package org.eclipse.rse.core.internal.subsystems; import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.regex.Pattern; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; @@ -31,6 +29,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.core.SystemTypeMatcher; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; import org.eclipse.rse.core.subsystems.SubSystemConfiguration; @@ -54,9 +53,7 @@ public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy // The list of associated system types by id as it appears in the plugin.xml private String systemTypeIds; - // The list of resolved system types supported by this subsystem configuration. This - // list is build from the list of registered system types cleaned up by the ones not - // matching either by name or id. + // The list of resolved system types supported by this subsystem configuration. private List resolvedSystemTypes; // The subsystem configuration vendor @@ -79,90 +76,6 @@ public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy private final SystemTypeMatcher systemTypeMatcher; - // Internal classes encapsulating the logic to match the declared system types against - // a specific given one. - - private final class SystemTypeMatcher { - private final class SystemTypeIdPattern { - private final Pattern pattern; - - /** - * Constructor. - */ - public SystemTypeIdPattern(Pattern pattern) { - assert pattern != null; - this.pattern = pattern; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.internal.subsystems.SubSystemConfigurationProxy.ISystemTypePattern#matches(org.eclipse.rse.core.IRSESystemType) - */ - public boolean matches(IRSESystemType systemType) { - assert systemType != null; - return pattern.matcher(systemType.getId()).matches(); - } - } - - // List of patterns to match. The order is preserved. - private final List patterns = new LinkedList(); - private boolean matchAllTypes = false; - - /** - * Constructor. - * - * @param declaredSystemTypeIds The list of declared system type ids. Might be null. - */ - public SystemTypeMatcher(String declaredSystemTypeIds) { - // Compile the list of patterns out of given lists of declared system types - if (declaredSystemTypeIds != null) { - String[] ids = declaredSystemTypeIds.split(";"); //$NON-NLS-1$ - if (ids != null && ids.length > 0) { - for (int i = 0; i < ids.length; i++) { - String id = ids[i].trim(); - if (id.equals("*")) { //$NON-NLS-1$ - matchAllTypes = true; - patterns.clear(); - return; - } else if(id.length()>0) { - SystemTypeIdPattern pattern = new SystemTypeIdPattern(Pattern.compile(makeRegex(id))); - patterns.add(pattern); - } - } - } - } - } - - private String makeRegex(String pattern) { - assert pattern != null; - String translated = pattern; - if (translated.indexOf('.') != -1) translated = translated.replaceAll("\\.", "\\."); //$NON-NLS-1$ //$NON-NLS-2$ - if (translated.indexOf('*') != -1) translated = translated.replaceAll("\\*", ".*"); //$NON-NLS-1$ //$NON-NLS-2$ - if (translated.indexOf('?') != -1) translated = translated.replaceAll("\\?", "."); //$NON-NLS-1$ //$NON-NLS-2$ - return translated; - } - - /** - * @return true if this matcher supports all system types. - */ - public boolean supportsAllSystemTypes() { - return matchAllTypes; - } - - /** - * Checks if the specified system type is matched by this pattern. - */ - public boolean matches(IRSESystemType systemType) { - assert systemType != null; - if (matchAllTypes) return true; - Iterator iterator = patterns.iterator(); - while (iterator.hasNext()) { - SystemTypeIdPattern matcher = (SystemTypeIdPattern)iterator.next(); - if (matcher.matches(systemType)) return true; - } - return false; - } - } - /** * Constructor * @param element The IConfigurationElement for this factory's plugin @@ -254,7 +167,7 @@ public class SubSystemConfigurationProxy implements ISubSystemConfigurationProxy String[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypeNames(); if (systemTypes != null) resolvedSystemTypes.addAll(Arrays.asList(systemTypes)); } else { - // We have to match the given lists of system type names and ids against + // 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 // change ones it has been initialized, we filter out the not matching ones // here directly.