How can I switch between opened windows in Eclipse? There is Ctrl+F6, but it\'s asking me which one I want, but I want switch it like tabs in browser o
Custom KeyBinding sequence example : CTRL + TAB to switch between visilble Modules or Editors Forward direction using Eclipse RCP.
you press CTRL + TAB second time to open another editor and close previous editor using RCP Eclipse.
package rcp_demo.Toolbar;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;
public class Forward_Editor extends AbstractHandler{
static String Editor_name; // Active Editor name store in Temporary
static int cnt; // close editor count this variable
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
UserEditorInput std_input = new UserEditorInput();
EmployeeEditorInput emp_input=new EmployeeEditorInput();
ProductEditorInput product_input=new ProductEditorInput();
IEditorReference[] editors = page.getEditorReferences();
//Blank Editor Window to execute..
if(editors.length==0)
{
//First time close editor can open Student_Editor
if(cnt==1 && Editor_name.equals("Student_Editor"))
{
try {
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First time close editor can open Employee_Editor
else if(cnt==1 && Editor_name.equals("Employee_Editor"))
{
try {
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {e.printStackTrace();
}
}
//First time close editor can open Product_Editor
else if(cnt==1 && Editor_name.equals("Product_Editor"))
{
try {
page.openEditor(std_input, UserEditor.ID);
System.out.println("student Editor open");
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("Close::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First Time call // empty editors
else{
try {
page.openEditor(std_input, UserEditor.ID);
System.out.println("student Editor open");
Editor_name=page.getActiveEditor().getTitle();
} catch (PartInitException e) {
e.printStackTrace();
}
}
}//End if condition
//AvtiveEditor(Student_Editor) close to open Employee Editor
else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
{
try {
//page.closeAllEditors(true);
page.closeEditor(page.getActiveEditor(), true);
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//AvtiveEditor(Employee_Editor) close to open Product Editor
else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
{
try {
page.closeAllEditors(true);
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//AvtiveEditor(Product_Editor) close to open Student Editor
else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
{
try {
page.closeAllEditors(true);
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("stud>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//by default open Student Editor
else
{
try {
page.closeAllEditors(true);
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("stud_else>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
return null;
}
}
>Custom KeyBinding sequence example : <kbd> SHIFT + TAB </kbd> to switch between visilble Modules or Editors **Backword** direction using Eclipse RCP.
package rcp_demo.Toolbar;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;
public class Backword_Editor extends AbstractHandler{
static String Editor_name; // Active Editor name store in Temporary
static int cnt;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
//Three object create in EditorInput
UserEditorInput std_input = new UserEditorInput();
EmployeeEditorInput emp_input=new EmployeeEditorInput();
ProductEditorInput product_input=new ProductEditorInput();
IEditorReference[] editors = page.getEditorReferences();
System.out.println("Length : "+editors.length);
if(editors.length==0)
{
//First time close editor can open Student_Editor
if(cnt==1 && Editor_name.equals("Product_Editor"))
{
try {
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First time close editor can open Employee_Editor
else if(cnt==1 && Editor_name.equals("Employee_Editor"))
{
try {
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("Student>>Len:: "+editors.length+"..student::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First time close editor can open Product_Editor
else if(cnt==1 && Editor_name.equals("Student_Editor"))
{
try {
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First Time or empty editors to check this condition
else{
try {
page.openEditor(product_input,ProductEditor.ID);
System.out.println("product Editor open");
} catch (PartInitException e) {
e.printStackTrace();
}
}
}
//AvtiveEditor(Product_Editor) close to open Employee Editor
else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
{
System.out.println("Product:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("Employee Editor open");
} catch (PartInitException e) {
e.printStackTrace();
}
}
//AvtiveEditor(Employee_Editor) close to open Student Editor
else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
{
System.out.println("Emp:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("student Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//AvtiveEditor(Student_Editor) close to open Product Editor
else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
{
System.out.println("Product:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("product Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//by default open Student Editor
else
{
try {
page.closeAllEditors(true);
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("product Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
}
Custom KeyBinding sequence example : SHIFT + TAB to switch between visilble Modules or Editors Backword direction using Eclipse RCP.
package rcp_demo.Toolbar;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import rcp_demo.Editor.EmployeeEditor;
import rcp_demo.Editor.EmployeeEditorInput;
import rcp_demo.Editor.ProductEditor;
import rcp_demo.Editor.ProductEditorInput;
import rcp_demo.Editor.UserEditor;
import rcp_demo.Editor.UserEditorInput;
public class Backword_Editor extends AbstractHandler{
static String Editor_name; // Active Editor name store in Temporary
static int cnt;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
//Three object create in EditorInput
UserEditorInput std_input = new UserEditorInput();
EmployeeEditorInput emp_input=new EmployeeEditorInput();
ProductEditorInput product_input=new ProductEditorInput();
IEditorReference[] editors = page.getEditorReferences();
System.out.println("Length : "+editors.length);
if(editors.length==0)
{
//First time close editor can open Student_Editor
if(cnt==1 && Editor_name.equals("Product_Editor"))
{
try {
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("EMP>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First time close editor can open Employee_Editor
else if(cnt==1 && Editor_name.equals("Employee_Editor"))
{
try {
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("Student>>Len:: "+editors.length+"..student::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First time close editor can open Product_Editor
else if(cnt==1 && Editor_name.equals("Student_Editor"))
{
try {
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("PRO>>Len:: "+editors.length+"..EDi::"+Editor_name);
} catch (PartInitException e) {
e.printStackTrace();
}
}
//First Time or empty editors to check this condition
else{
try {
page.openEditor(product_input,ProductEditor.ID);
System.out.println("product Editor open");
} catch (PartInitException e) {
e.printStackTrace();
}
}
}
//AvtiveEditor(Product_Editor) close to open Employee Editor
else if(page.getActiveEditor().getTitle().equals("Product_Editor"))
{
System.out.println("Product:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(emp_input, EmployeeEditor.Id);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("Employee Editor open");
} catch (PartInitException e) {
e.printStackTrace();
}
}
//AvtiveEditor(Employee_Editor) close to open Student Editor
else if(page.getActiveEditor().getTitle().equals("Employee_Editor"))
{
System.out.println("Emp:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(std_input, UserEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("student Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//AvtiveEditor(Student_Editor) close to open Product Editor
else if(page.getActiveEditor().getTitle().equals("Student_Editor"))
{
System.out.println("Product:: "+page.getActiveEditor().getTitle());
try {
page.closeAllEditors(true);
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("product Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//by default open Student Editor
else
{
try {
page.closeAllEditors(true);
page.openEditor(product_input,ProductEditor.ID);
cnt=1;
Editor_name=page.getActiveEditor().getTitle();
System.out.println("product Editor open");
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
}
Key Sequence
M1 means CTRL
M2 means SHIFT
plugin.xml
<extension point="org.eclipse.ui.commands">
<command
defaultHandler="rcp_demo.Toolbar.Forward_Editor"
id="RCP_Demo.Toolbar.Forward_editor_open_cmd"
name="Forward_Editor">
</command>
<command
defaultHandler="rcp_demo.Toolbar.Backword_Editor"
id="RCP_Demo.Toolbar.backwards_editor_open_cmd"
name="Backword_Editor">
</command>
</extension>
<extension point="org.eclipse.ui.bindings">
<key
commandId="RCP_Demo.Toolbar.Forward_editor_open_cmd"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+TAB">
</key>
<key
commandId="RCP_Demo.Toolbar.backwards_editor_open_cmd"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M2+TAB">
</key>
</extension>
Right
side move : Ctrl + page DownLeft
side move : CTRL + page UpAdditional
Eclipse others Short Cuts
You can set the hotkeys in Preferences -> General -> Keys (or just type "keys" into the filter field at the top of the Preferences dialog.
Once the Keys section is selected, find Next Tab and Previous Tab and assign them your own hotkey by clicking in the "Binding" field and then typing your hotkeys.
Hit Apply or OK to finish the process.
Solved!!
Change Scheme to Microsoft Visual Studio
Window>Preferences>General>Keys
Look for Schemes dropdown
My eclipse version:
Eclipse Java EE IDE for Web Developers.
Version: Juno Service Release 1 Build id: 20120920-0800
CTRL-F6 in Eclipse, like ALT-TAB (on windows), brings up a list of tabs/windows available (if you keep the CTRL / ALT key depressed) and highlights the one you will jump to when you let go of this key. You do not have to select the window. If you want to traverse several tabs at once hold down the CTRL button and tap the TAB button. This is identical behaviour to ALT-TAB on Windows.
In this sense, CTRL-SHIFT-F6 in eclipse is the ALT-SHIFT-TAB analog. Personally, I change these bindings in Eclipse to be like Visual Studio. I.e. CTRL-TAB and CTRL-SHIFT-TAB and I do it like this:
Window>Preferences>General>Keys
Then set "Next Editor"=Ctrl+Tab and "Previous Editor"=Ctrl+Shift+Tab. Don't forget to click "Unbind Command" before setting the new binding.
This is CTRL-PageDown to go right, CTRL-PageUp to go left. Frustratingly, when you get to the end of the list of tabs (say far right hand tab) and then try to go right again Eclipse does not cycle round to the first tab (far left) like most browsers would.
3 line AutoHotKey script (on Windows, anyway):
#IfWinActive ahk_class SWT_Window0
^+Tab::^PgUp
^Tab::^PgDn
Put this in your startup folder (save it as *.ahk, must have AutoHotKey installed) and Eclipse tabs will now work like Chrome or Firefox.