Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 86248
Collapse All | Expand All

(-)Eclipse (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.handlers;
12
13
import java.lang.reflect.Method;
14
15
import org.eclipse.core.commands.ExecutionEvent;
16
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.swt.widgets.Shell;
21
22
/**
23
 * This handler is an adaptation of the widget method handler that implements
24
 * page traversal via {@link SWT#TRAVERSE_PAGE_NEXT} and
25
 * {@link SWT#TRAVERSE_PAGE_PREVIOUS} events.
26
 * 
27
 * @since 3.5
28
 */
29
public class TraversePageHandler extends WidgetMethodHandler {
30
31
	/**
32
	 * The parameters for traverse(int).
33
	 */
34
	private static final Class[] METHOD_PARAMETERS = { int.class };
35
36
	public final Object execute(final ExecutionEvent event) {
37
		Control focusControl = Display.getCurrent().getFocusControl();
38
		if (focusControl != null) {
39
			int traversal= "next".equals(methodName) ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS; //$NON-NLS-1$
40
			Control control = focusControl;
41
			do {
42
				if (control.traverse (traversal))
43
					return null;
44
				if (control instanceof Shell)
45
					return null;
46
				control = control.getParent();
47
			} while (control != null);
48
		}
49
50
		return null;
51
	}
52
53
	/**
54
	 * Looks up the traverse(int) method on the given focus control.
55
	 * 
56
	 * @return The method on the focus control; <code>null</code> if none.
57
	 */
58
	protected Method getMethodToExecute() {
59
		final Control focusControl = Display.getCurrent().getFocusControl();
60
		if (focusControl != null) {
61
			try {
62
				return focusControl.getClass().getMethod("traverse", //$NON-NLS-1$
63
						METHOD_PARAMETERS);
64
			} catch (NoSuchMethodException e) {
65
				// Do nothing.
66
			}
67
		}
68
		return null;
69
	}
70
71
}
(-)plugin.xml (+14 lines)
Lines 1156-1161 Link Here
1156
            name="%command.previousPage.name">
1156
            name="%command.previousPage.name">
1157
      </command>
1157
      </command>
1158
      <command
1158
      <command
1159
            description="%command.nextTab.description"
1160
            id="org.eclipse.ui.navigate.nextTab"
1161
            categoryId="org.eclipse.ui.category.navigate"
1162
            name="%command.nextTab.name"
1163
            defaultHandler="org.eclipse.ui.internal.handlers.TraversePageHandler:next">
1164
      </command>
1165
      <command
1166
            description="%command.previousTab.description"
1167
            id="org.eclipse.ui.navigate.previousTab"
1168
            categoryId="org.eclipse.ui.category.navigate"
1169
            name="%command.previousTab.name"
1170
            defaultHandler="org.eclipse.ui.internal.handlers.TraversePageHandler:previous">
1171
      </command>
1172
      <command
1159
            description="%command.nextSubTab.description"
1173
            description="%command.nextSubTab.description"
1160
            id="org.eclipse.ui.navigate.nextSubTab"
1174
            id="org.eclipse.ui.navigate.nextSubTab"
1161
            categoryId="org.eclipse.ui.category.navigate"
1175
            categoryId="org.eclipse.ui.category.navigate"
(-)plugin.properties (+4 lines)
Lines 188-193 Link Here
188
command.nextPerspective.name = Next Perspective
188
command.nextPerspective.name = Next Perspective
189
command.nextSubTab.name = Next Sub-Tab
189
command.nextSubTab.name = Next Sub-Tab
190
command.nextSubTab.description = Switch to the next sub-tab
190
command.nextSubTab.description = Switch to the next sub-tab
191
command.nextTab.name = Next Tab
192
command.nextTab.description = Switch to the next tab
191
command.nextView.description = Switch to the next view
193
command.nextView.description = Switch to the next view
192
command.nextView.name = Next View
194
command.nextView.name = Next View
193
command.openEditorDropDown.description = Open the editor drop down list
195
command.openEditorDropDown.description = Open the editor drop down list
Lines 209-214 Link Here
209
command.previousPerspective.name = Previous Perspective
211
command.previousPerspective.name = Previous Perspective
210
command.previousSubTab.name = Previous Sub-Tab
212
command.previousSubTab.name = Previous Sub-Tab
211
command.previousSubTab.description = Switch to the previous sub-tab
213
command.previousSubTab.description = Switch to the previous sub-tab
214
command.previousTab.name = Previous Tab
215
command.previousTab.description = Switch to the previous tab
212
command.previousView.description = Switch to the previous view
216
command.previousView.description = Switch to the previous view
213
command.previousView.name = Previous View
217
command.previousView.name = Previous View
214
command.print.description = Print
218
command.print.description = Print

Return to bug 86248