1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-09 10:05:24 +02:00

[164520] Use SelectionListener instead of Listener to handle dbl click in New Wizard in a more platform neutral way

This commit is contained in:
Martin Oberhuber 2006-11-27 08:56:30 +00:00
parent 8e856c7e0b
commit 86b044d99c

View file

@ -1,5 +1,5 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation. All rights reserved. * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the terms * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -11,7 +11,8 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Javier Montalvo Orús (Symbian) - Bug 149151: New Connection first page should use a Listbox for systemtype * 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; package org.eclipse.rse.ui.wizards;
@ -23,19 +24,18 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemResources; import org.eclipse.rse.ui.SystemResources;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
/** /**
* The New Connection Wizard main page that allows selection of system type. * The New Connection Wizard main page that allows selection of system type.
*/ */
public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements Listener { public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage implements SelectionListener {
protected String parentHelpId; protected String parentHelpId;
protected List textSystemType; protected List textSystemType;
@ -50,8 +50,8 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
* @param description the description of the wizard page. * @param description the description of the wizard page.
*/ */
public RSENewConnectionWizardMainPage(IRSENewConnectionWizard wizard, String title, String description) { public RSENewConnectionWizardMainPage(IRSENewConnectionWizard wizard, String title, String description) {
super(wizard, "NewConnectionSystemType", title, description); super(wizard, "NewConnectionSystemType", title, description); //$NON-NLS-1$
parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; parentHelpId = RSEUIPlugin.HELPPREFIX + "wncc0000"; //$NON-NLS-1$
setHelp(parentHelpId); setHelp(parentHelpId);
} }
@ -82,12 +82,10 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
textSystemType = SystemWidgetHelpers.createSystemTypeListBox(parent, null, systemTypeNames); textSystemType = SystemWidgetHelpers.createSystemTypeListBox(parent, null, systemTypeNames);
} }
textSystemType.addListener(SWT.MouseDoubleClick, this);
textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP); textSystemType.setToolTipText(SystemResources.RESID_CONNECTION_SYSTEMTYPE_TIP);
SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003"); SystemWidgetHelpers.setHelp(textSystemType, RSEUIPlugin.HELPPREFIX + "ccon0003"); //$NON-NLS-1$
textSystemType.addListener(SWT.Selection, this); textSystemType.addSelectionListener(this);
descriptionSystemType = SystemWidgetHelpers.createMultiLineTextField(parent,null,30); descriptionSystemType = SystemWidgetHelpers.createMultiLineTextField(parent,null,30);
descriptionSystemType.setEditable(false); descriptionSystemType.setEditable(false);
@ -147,14 +145,11 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
} }
/** /**
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) * Handle single-click on list
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
public void handleEvent(Event event) { public void widgetSelected(SelectionEvent e) {
if (((event.type == SWT.Selection) || (event.type == SWT.MouseDoubleClick)) && event.widget == textSystemType) {
IWizard wizard = getWizard(); IWizard wizard = getWizard();
if (wizard instanceof IRSENewConnectionWizard) { if (wizard instanceof IRSENewConnectionWizard) {
String systemTypeStr = textSystemType.getSelection()[0]; String systemTypeStr = textSystemType.getSelection()[0];
IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard; IRSENewConnectionWizard newConnWizard = (IRSENewConnectionWizard)wizard;
@ -162,11 +157,18 @@ public class RSENewConnectionWizardMainPage extends AbstractSystemWizardPage imp
IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr); IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeStr);
newConnWizard.setSelectedSystemType(systemType); newConnWizard.setSelectedSystemType(systemType);
descriptionSystemType.setText(systemType.getDescription()); descriptionSystemType.setText(systemType.getDescription());
}
}
if (event.type == SWT.MouseDoubleClick) { /**
newConnWizard.getContainer().showPage(getNextPage()); * 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());
} }
} }
} }