DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Maximizing Efficiency With the Test Automation Pyramid: Leveraging API Tests for Optimal Results
  • Containerize Gradle Apps and Deploy to Kubernetes With JKube Kubernetes Gradle Plugin
  • Building a Reusable API Platform With WSO2 API Manager
  • Building Your Next Microservice With Eclipse MicroProfile (Updated)

Trending

  • .NET Performance Optimization Techniques for Expert Developers
  • How To Aim for High GC Throughput
  • Protect Your Keys: Lessons from the Azure Key Breach
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Programmatically split an editor area to show two editors side by side.

Programmatically split an editor area to show two editors side by side.

Dimitri Missoh user avatar by
Dimitri Missoh
·
Oct. 20, 08 · Interview
Like (0)
Save
Tweet
Share
12.86K Views

Join the DZone community and get the full member experience.

Join For Free

Last time a workmate of mine asked me if it is possible, to programmatically split the editor area of an eclipse RCP application.

We all know that if you have two editors opened in the workbench, you can drag one of the editors and drop it in one of the regions of the editor area (bottom, top, left or right) so that both editors are side by side.

I started to analyze the eclipse code and look for a public API that I can use to achieve this task. I didn’t find anything. My first idea was to simulate the Drag&Drop behavior, but it came out to be a very challenging task.

So I’ve decided to use some of the API calls, which the eclipse team discourages to use. And it works. I bundled my code into a plug-in. Maybe someone will find this useful.

Here is the most important part of the code:

/**
* Split the editor area if there is at least two editors in it.
*/
private void splitEditorArea() {
IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPart part = workbenchPage.getActivePart();
PartPane partPane = ((PartSite) part.getSite()).getPane();
LayoutPart layoutPart = partPane.getPart();

IEditorReference[] editorReferences = workbenchPage.getEditorReferences();
// Do it only if we have more that one editor
if (editorReferences.length > 1) {
// Get PartPane that correspond to the active editor
PartPane currentEditorPartPane = ((PartSite) workbenchPage.getActiveEditor().getSite()).getPane();
EditorSashContainer editorSashContainer = null;
ILayoutContainer rootLayoutContainer = layoutPart.getContainer();
if (rootLayoutContainer instanceof LayoutPart) {
ILayoutContainer editorSashLayoutContainer = ((LayoutPart) rootLayoutContainer).getContainer();
if (editorSashLayoutContainer instanceof EditorSashContainer) {
editorSashContainer = ((EditorSashContainer) editorSashLayoutContainer);
}
}
/*
* Create a new part stack (i.e. a workbook) to home the
* currentEditorPartPane which hold the active editor
*/
PartStack newPart = createStack(editorSashContainer);
editorSashContainer.stack(currentEditorPartPane, newPart);
if (rootLayoutContainer instanceof LayoutPart) {
ILayoutContainer cont = ((LayoutPart) rootLayoutContainer).getContainer();
if (cont instanceof PartSashContainer) {
// "Split" the editor area by adding the new part
((PartSashContainer) cont).add(newPart);
}
}
}
}

/**
* A method to create a part stack container (a new workbook)
*
* @param editorSashContainer the <code>EditorSashContainer</code> to set for the returned <code>PartStack</code>
* @return a new part stack container
*/
private PartStack createStack(EditorSashContainer editorSashContainer) {
WorkbenchPage workbenchPage = (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
EditorStack newWorkbook = EditorStack.newEditorWorkbook(editorSashContainer, workbenchPage);
return newWorkbook;
}

 

You can download the full eclipse plug-in code from my blog: http://swarmy.free.fr/wordpress/ 

Eclipse Task (computing) API application teams Drops (app) Rich client platform Analyze (imaging software)

Opinions expressed by DZone contributors are their own.

Related

  • Maximizing Efficiency With the Test Automation Pyramid: Leveraging API Tests for Optimal Results
  • Containerize Gradle Apps and Deploy to Kubernetes With JKube Kubernetes Gradle Plugin
  • Building a Reusable API Platform With WSO2 API Manager
  • Building Your Next Microservice With Eclipse MicroProfile (Updated)

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: