Eclipse has a lot of perspectives, such as Debug, or Java. The following are debug, and Java perspective, it can be found that their structure is not the same, showing the user's picture is not the same.
Let's get down to the chase and develop our own perspective.
Prepare an environment for plug-in engineering to add our own perspective.
Create a new plug-in project
Enter the name of our project
Modify the properties you want to modify by default.
Next, Eclipse automatically generates a plug-in project for us.
Create a Perspective class and add your own view style.
We are starting to really develop a perspective class at this time. Create a class named Firstper
Let this class inherit iperspectivefactory and implement its inheritance method.
1 Packagecom.test.myperspective;2 3 Importorg.eclipse.ui.IPageLayout;4 Importorg.eclipse.ui.IPerspectiveFactory;5 6 Public classFirstperImplementsIperspectivefactory {7 8 @Override9 Public voidcreateinitiallayout (ipagelayout layout) {Ten //TODO auto-generated Method Stub One A } - -}
To see the effect, we define a outline view, a problerm view, and close the edit view when initializing.
Packagecom.test.myperspective;Importorg.eclipse.ui.IFolderLayout;Importorg.eclipse.ui.IPageLayout;Importorg.eclipse.ui.IPerspectiveFactory; Public classFirstperImplementsiperspectivefactory {@Override Public voidcreateinitiallayout (ipagelayout layout) {//TODO auto-generated Method StubString Editorarea =Layout.geteditorarea (); Layout.seteditorareavisible (false); Layout.addview (Ipagelayout.id_outline, Ipagelayout.left,0.25f, Editorarea); Ifolderlayout Bottom= Layout.createfolder ("Bottom", Ipagelayout.bottom,0.66f, Editorarea); Bottom.addview (Ipagelayout.id_problem_view); }}
Create an icon folder and place our own perspective icon.
Add a new folder to your project and store an icon image.
Add a perspective extension point and add the Perspective class, and the icon to the extension Point property bar.
In the Properties Preview view, in the extension Point page extension, add a view extension point.
Find the org.eclipse.ui.perspectives class, Add.
Eclipse will automatically help us generate a new view to add below this extension point
Modify the attributes of the extension point element to match the Firstper class that we just created, and don't forget to save When you're done modifying it.
Run the plug-in project to view the perspective diagram
Now is the time to witness the results. Run the project as an Eclipse application.
In the right-most open Perspective button, choose your own perspective, you can see only one outline, and problerms perspective.