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 364046
Collapse All | Expand All

(-)a/bundles/org.eclipse.ui.workbench/Eclipse (+64 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 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
12
package org.eclipse.ui.internal;
13
14
import java.util.List;
15
import org.eclipse.core.commands.AbstractHandler;
16
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
18
import org.eclipse.e4.core.di.annotations.Execute;
19
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
20
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
21
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
22
import org.eclipse.e4.ui.workbench.modeling.EModelService;
23
import org.eclipse.ui.IWorkbenchWindow;
24
import org.eclipse.ui.handlers.HandlerUtil;
25
26
27
/**
28
 * @since 3.5
29
 *
30
 */
31
public class FlipPerspectiveWithNextHandler extends AbstractHandler {
32
33
	/**
34
	 * @throws ExecutionException
35
	 */
36
	@Execute
37
	public Object execute(ExecutionEvent event) throws ExecutionException {
38
		MPerspectiveStack perspectiveStack = findPerspectiveStack(event);
39
		MPerspective selectedPerspective = perspectiveStack.getSelectedElement();
40
		List<MPerspective> perspectives = perspectiveStack.getChildren();
41
		int selectedIndex = perspectives.indexOf(selectedPerspective);
42
		int maxIndex = perspectives.size() - 1;
43
		try {
44
			if (selectedIndex < maxIndex) {
45
				int nextIndex = selectedIndex + 1;
46
				MPerspective nextPerspective = perspectives.remove(nextIndex);
47
				perspectives.add(selectedIndex, nextPerspective);
48
			}
49
		} catch (Exception e) {
50
			System.out.println(e);
51
		}
52
		return null;
53
	}
54
55
	private MPerspectiveStack findPerspectiveStack(ExecutionEvent event) {
56
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
57
		MWindow model = (MWindow) window.getService(MWindow.class);
58
		EModelService modelService = (EModelService) window.getService(EModelService.class);
59
		List<MPerspectiveStack> perspectiveStacks = modelService.findElements(model, null,
60
				MPerspectiveStack.class, null);
61
		return perspectiveStacks.get(0);
62
	}
63
64
}
(-)a/bundles/org.eclipse.ui/plugin.properties (+1 lines)
Lines 189-194 Link Here
189
command.nextPage.description = Switch to the next page
189
command.nextPage.description = Switch to the next page
190
command.nextPerspective.description = Switch to the next perspective
190
command.nextPerspective.description = Switch to the next perspective
191
command.nextPerspective.name = Next Perspective
191
command.nextPerspective.name = Next Perspective
192
command.flipPerspectiveWithNext.name = Flip current perspective with the next one
192
command.nextSubTab.name = Next Sub-Tab
193
command.nextSubTab.name = Next Sub-Tab
193
command.nextSubTab.description = Switch to the next sub-tab
194
command.nextSubTab.description = Switch to the next sub-tab
194
command.nextTab.name = Next Tab
195
command.nextTab.name = Next Tab
(-)a/bundles/org.eclipse.ui/plugin.xml (+10 lines)
Lines 102-107 Link Here
102
   </extension>
102
   </extension>
103
   
103
   
104
   <extension point="org.eclipse.ui.bindings">
104
   <extension point="org.eclipse.ui.bindings">
105
    <key
106
      		commandId="org.eclipse.ui.perspectives.FlipPerspectiveWithNext"
107
      		sequence="M1+M2+F11"
108
      		schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
105
      <key
109
      <key
106
            commandId="org.eclipse.ui.newWizard"
110
            commandId="org.eclipse.ui.newWizard"
107
            sequence="M1+N"
111
            sequence="M1+N"
Lines 1102-1107 Link Here
1102
            categoryId="org.eclipse.ui.category.window"
1106
            categoryId="org.eclipse.ui.category.window"
1103
            id="org.eclipse.ui.window.nextPerspective" />
1107
            id="org.eclipse.ui.window.nextPerspective" />
1104
      <command
1108
      <command
1109
             id="org.eclipse.ui.perspectives.FlipPerspectiveWithNext"
1110
             name="%command.flipPerspectiveWithNext.name"/>
1111
      <command
1105
            name="%command.previousPerspective.name"
1112
            name="%command.previousPerspective.name"
1106
            description="%command.previousPerspective.description"
1113
            description="%command.previousPerspective.description"
1107
            categoryId="org.eclipse.ui.category.window"
1114
            categoryId="org.eclipse.ui.category.window"
Lines 1934-1939 Link Here
1934
     </extension>
1941
     </extension>
1935
   <extension
1942
   <extension
1936
         point="org.eclipse.ui.handlers">
1943
         point="org.eclipse.ui.handlers">
1944
	  <handler
1945
            class= "org.eclipse.ui.internal.FlipPerspectiveWithNextHandler"
1946
            commandId="org.eclipse.ui.perspectives.FlipPerspectiveWithNext"/>
1937
      <handler
1947
      <handler
1938
            class="org.eclipse.ui.internal.ActivateEditorHandler"
1948
            class="org.eclipse.ui.internal.ActivateEditorHandler"
1939
            commandId="org.eclipse.ui.window.activateEditor">
1949
            commandId="org.eclipse.ui.window.activateEditor">

Return to bug 364046