CIOC
CIOC

Reputation: 1427

Set tab title for an EditorPart in Eclipse

I currently have en Eclipse plugin that provides a multi-page editor, one page for a visual editor and one page for a source editor, similar to other editors, i.e:

enter image description here

This is the important part of my code:

public class DockerfileEditor extends FormEditor implements IResourceChangeListener {
    ....
    @Override
    protected void addPages() {
        try {
            SourceEditor sourceEditor = new SourceEditor(); // Extends from EditorPart

            addPage(new DesignForm(this, "Design")); //$NON-NLS-1$
            addPage(sourceEditor, sourceEditor.getEditorInput());
        } catch (PartInitException e) {
            e.printStackTrace();
        }
    }
}

In the addPages() method I'm adding my 2 pages, the first of them extends from FormPage so setting the title is really easy, but the second page extends from EditorPart (this will be my source editor), how can I set the title of this page?

Upvotes: 0

Views: 542

Answers (1)

greg-449
greg-449

Reputation: 111142

addPage returns you the index of the page that was added so you can use:

int pageIndex = addPage(sourceEditor, sourceEditor.getEditorInput());

setPageText(pageIndex, "Source");

Upvotes: 1

Related Questions