Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to open two editors in splitscreen?
icon5.gif  How to open two editors in splitscreen? [message #702411] Tue, 26 July 2011 10:30 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 7
Registered: March 2011
Junior Member
Hello,

how can I open two editors in slit screen?

My code looks like this: (already work but not in split screen ...)
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, getIEditorInput1(), getEditorId1());
IDE.openEditor(page, getIEditorInput2(), getEditorId2());


Best regards,
Stefan
(no subject) [message #702516 is a reply to message #702411] Tue, 26 July 2011 13:14 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 26.07.2011 12:30, sricht10 wrote:
> Hello,
>
> how can I open two editors in slit screen?
AFAIK there is no API to do that.

Dani
>
> My code looks like this: (already work but not in split screen ...)
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
> IDE.openEditor(page, getIEditorInput1(), getEditorId1());
> IDE.openEditor(page, getIEditorInput2(), getEditorId2());
>
>
> Best regards,
> Stefan
icon7.gif  Re: How to open two editors in splitscreen? [message #702650 is a reply to message #702411] Tue, 26 July 2011 16:10 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 7
Registered: March 2011
Junior Member
Ok, I've found the following solution for me.

http://eclipse.dzone.com/tips/programmatically-split-editor-

public EditorSashContainer getEditorArea(IWorkbenchPage workbenchPage) {
	PartPane activeEditorPartPane = ((PartSite) workbenchPage.getActivePart().getSite()).getPane();

	LayoutPart activeLayoutPart = activeEditorPartPane.getPart();
	ILayoutContainer iLayoutContainer1 = activeLayoutPart.getContainer();
	if (iLayoutContainer1 instanceof LayoutPart) {
		ILayoutContainer iLayoutContainer2 = ((LayoutPart) iLayoutContainer1).getContainer();
		if (iLayoutContainer2 instanceof EditorSashContainer) {
			return (EditorSashContainer) iLayoutContainer2;
		}
	}
	return null;
}

@Override
public void run() {
	IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

	IEditorPart editor1 = getEditor1();
	PartPane editor1PartPane = ((PartSite) editor1.getSite()).getPane();

	EditorSashContainer editorArea = getEditorArea(workbenchPage);

	IEditorPart editor2 = getEditor2();
	PartPane editor2PartPane = ((PartSite) editor2.getSite()).getPane();

	EditorStack workbook1 = (EditorStack) editorArea.getEditorWorkbooks().get(0);
	EditorStack workbook2;
	if (editorArea.getEditorWorkbooks().size() > 1) {
		workbook2 = (EditorStack) editorArea.getEditorWorkbooks().get(1);
	} else {
		workbook2 = EditorStack.newEditorWorkbook(editorArea, (WorkbenchPage) workbenchPage);
		editorArea.add(workbook2);
	}

	editorArea.stack(editor1PartPane, workbook1);
	editorArea.stack(editor2PartPane, workbook2);
}


Best regards,
Stefan

[Updated on: Tue, 26 July 2011 16:12]

Report message to a moderator

icon10.gif  Re: How to open two editors in splitscreen? [message #705113 is a reply to message #702411] Fri, 29 July 2011 12:54 Go to previous message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 7
Registered: March 2011
Junior Member
The following code is more reliable ...

// get the current workbench page
IWorkbenchPage activeWorkbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
WorkbenchPage page = (WorkbenchPage) activeWorkbenchPage;

// get the editor area and set the default workbook active
EditorSashContainer editorArea = (EditorSashContainer) page.getEditorPresentation().getLayoutPart();
editorArea.setActiveWorkbookFromID("DefaultEditorWorkbook");

// open the editor for the first part
IDE.openEditor(page, getIEditorInput1(), getEditorId1());

// get the second workbook or create a new one
EditorStack newWorkbook;
if (editorArea.getEditorWorkbooks().size() > 1) {
	newWorkbook = (EditorStack) editorArea.getEditorWorkbooks().get(1);
} else {
	newWorkbook = EditorStack.newEditorWorkbook(editorArea, page);
	editorArea.add(newWorkbook);
}
// activate the second workbook
editorArea.setActiveWorkbook(newWorkbook, true);

// open the second editor
IDE.openEditor(page, getIEditorInput2(), getEditorId2());
Previous Topic:How to resolve project_loc
Next Topic:How can i open editor from context menu
Goto Forum:
  


Current Time: Thu Sep 26 13:12:28 GMT 2024

Powered by FUDForum. Page generated in 0.03927 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top