Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 138299 Details for
Bug 276942
connector discovery wizard keyboard navigation and focus management
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch that manages traversal
clipboard.txt (text/plain), 7.31 KB, created by
David Green
on 2009-06-04 11:22:42 EDT
(
hide
)
Description:
patch that manages traversal
Filename:
MIME Type:
Creator:
David Green
Created:
2009-06-04 11:22:42 EDT
Size:
7.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.discovery.ui >Index: src/org/eclipse/mylyn/internal/discovery/ui/wizards/ConnectorDiscoveryWizardMainPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.discovery.ui/src/org/eclipse/mylyn/internal/discovery/ui/wizards/ConnectorDiscoveryWizardMainPage.java,v >retrieving revision 1.41 >diff -u -r1.41 ConnectorDiscoveryWizardMainPage.java >--- src/org/eclipse/mylyn/internal/discovery/ui/wizards/ConnectorDiscoveryWizardMainPage.java 4 Jun 2009 14:25:12 -0000 1.41 >+++ src/org/eclipse/mylyn/internal/discovery/ui/wizards/ConnectorDiscoveryWizardMainPage.java 4 Jun 2009 15:19:52 -0000 >@@ -57,6 +57,7 @@ > import org.eclipse.mylyn.internal.discovery.ui.DiscoveryImages; > import org.eclipse.mylyn.internal.discovery.ui.DiscoveryUi; > import org.eclipse.mylyn.internal.discovery.ui.util.DiscoveryUiUtil; >+import org.eclipse.mylyn.internal.discovery.ui.util.TraverseManager; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes; > import org.eclipse.mylyn.internal.provisional.commons.ui.GradientCanvas; >@@ -167,6 +168,8 @@ > > private ScrolledComposite bodyScrolledComposite; > >+ private TraverseManager traverseManager; >+ > public ConnectorDiscoveryWizardMainPage() { > super(ConnectorDiscoveryWizardMainPage.class.getSimpleName()); > setTitle(org.eclipse.mylyn.internal.discovery.ui.wizards.Messages.ConnectorDiscoveryWizardMainPage_connectorDiscovery); >@@ -271,6 +274,7 @@ > } > > } >+ traverseManager = new TraverseManager(container); > { // container > body = new Composite(container, SWT.NULL); > GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 480).applyTo(body); >@@ -519,6 +523,12 @@ > > bodyScrolledComposite.setContent(scrolledContents); > >+ body.getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ traverseManager.manage(body); >+ } >+ }); >+ > Dialog.applyDialogFont(body); > // we've changed it so it needs to know > body.layout(true); >@@ -671,6 +681,7 @@ > connector.getProvider(), connector.getLicense())); > > infoLabel = new Label(connectorContainer, SWT.NULL); >+ infoLabel.setData(TraverseManager.KEY_ACCEPT_FOCUS, true); > configureLook(infoLabel, background); > if (hasTooltip(connector)) { > infoLabel.setImage(infoImage); >Index: src/org/eclipse/mylyn/internal/discovery/ui/util/TraverseManager.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/discovery/ui/util/TraverseManager.java >diff -N src/org/eclipse/mylyn/internal/discovery/ui/util/TraverseManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/discovery/ui/util/TraverseManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,156 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Tasktop Technologies 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: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.discovery.ui.util; >+ >+import java.util.ArrayList; >+import java.util.HashSet; >+import java.util.List; >+import java.util.Set; >+import java.util.Stack; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.TraverseEvent; >+import org.eclipse.swt.events.TraverseListener; >+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.Link; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+/** >+ * @author David Green >+ */ >+public class TraverseManager implements TraverseListener, DisposeListener { >+ >+ public static final String KEY_ACCEPT_FOCUS = TraverseManager.class.getName() + "#acceptFocus"; //$NON-NLS-1$ >+ >+ private boolean handleEvent = true; >+ >+ private final Composite control; >+ >+ private final Set<Control> managedControls = new HashSet<Control>(); >+ >+ public TraverseManager(Composite control) { >+ this.control = control; >+ } >+ >+ public void widgetDisposed(DisposeEvent e) { >+ managedControls.remove(e.widget); >+ } >+ >+ public void manage(Control control) { >+ if (managedControls.add(control)) { >+ control.addTraverseListener(this); >+ control.addDisposeListener(this); >+ } >+ List<Control> focusCandidates = getFocusCandidates(null); >+ for (Control c : focusCandidates) { >+ if (managedControls.add(c)) { >+ c.addTraverseListener(this); >+ c.addDisposeListener(this); >+ } >+ } >+ } >+ >+ public void keyTraversed(TraverseEvent event) { >+ if (!handleEvent) { >+ return; >+ } >+ Control focusControl = Display.getCurrent().getFocusControl(); >+ switch (event.detail) { >+ case SWT.TRAVERSE_TAB_PREVIOUS: >+ case SWT.TRAVERSE_ARROW_PREVIOUS: { >+ List<Control> focusCandidates = getFocusCandidates(focusControl); >+ if (focusCandidates.size() > 0) { >+ Control nextFocus = focusCandidates.get(focusCandidates.size() - 1); >+ if (!nextFocus.forceFocus()) { >+ nextFocus.setFocus(); >+ } >+ } >+ break; >+ } >+ case SWT.TRAVERSE_TAB_NEXT: >+ case SWT.TRAVERSE_ARROW_NEXT: { >+ List<Control> focusCandidates = getFocusCandidates(null); >+ int i = focusControl == null ? -1 : focusCandidates.indexOf(focusControl); >+ if (i >= 0 && (i < (focusCandidates.size() - 1))) { >+ Control nextFocus = focusCandidates.get(i + 1); >+ if (!nextFocus.forceFocus()) { >+ nextFocus.setFocus(); >+ } >+ } >+ break; >+ } >+ default: >+ handleEvent = false; >+ event.doit = true; >+ Control c = control; >+ Shell shell = c.getShell(); >+ while (c != null) { >+ if (c.traverse(event.detail)) { >+ break; >+ } >+ if (!event.doit || control == shell) { >+ break; >+ } >+ c = c.getParent(); >+ } >+ handleEvent = true; >+ break; >+ } >+ } >+ >+ private List<Control> getFocusCandidates(Control stop) { >+ List<Control> candidates = new ArrayList<Control>(20); >+ // document order traversal (depth-first) >+ Stack<Control> controls = new Stack<Control>(); >+ controls.push(control); >+ while (!controls.isEmpty()) { >+ Control c = controls.pop(); >+ if (c == stop) { >+ break; >+ } >+ if (accept(c)) { >+ if (c.isEnabled()) { >+ candidates.add(c); >+ } >+ } else { >+ if (c instanceof ScrolledComposite) { >+ controls.push(((ScrolledComposite) c).getContent()); >+ } else if (c instanceof Composite) { >+ Control[] children = ((Composite) c).getChildren(); >+ for (int x = children.length - 1; x >= 0; --x) { >+ controls.push(children[x]); >+ } >+ } >+ } >+ } >+ return candidates; >+ } >+ >+ protected boolean accept(Control c) { >+ Class<? extends Control> classOfControl = c.getClass(); >+ if (classOfControl == Button.class || classOfControl == Link.class || classOfControl == Text.class) { >+ return true; >+ } >+ if (c.getData(KEY_ACCEPT_FOCUS) != null) { >+ return true; >+ } >+ return false; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 276942
:
138085
| 138299 |
138300
|
138303