Two ways to use perspective in eclipse

Source: Internet
Author: User

Here's how to define a perspective for your RCP program or Eclipse plug-in, add a view to the perspective, and define the placement of each view. OK, let's get to the point, define a perspective for our Plug-ins first: The way to define perspective I believe a lot of people are more clear, to extend the org.eclipse.ui.perspectives extension point, well, directly in our Plugin.xml file to add the following line of code is OK:

﹤extension point= "Org.eclipse.ui.perspectives" > 
﹤perspective 
class= "Com.test.blog.core.ui.perspectiv"  E.perspective "
icon=" icons/amc_perspect.gif "
id=" Com.test.blog.core.ui.perspective.Perspective
" Name= "%PERSPECTIVE.AMC" >
﹤/perspective>
﹤/extension>

The above code indicates that our perspective ID is org.talend.amc.plugin.Perspective, well, remember this ID. Now we're going to add our view (views) to this perspective. There are two ways to add a view, one that is added directly by code, and one that is configured directly in the Plugin.xml:

Add a view and layout to a known perspective through code

The above code has already indicated that the corresponding class of the perspective is org.talend.amc.plugin.Perspective, the class needs to implement the Iperspectivefactory interface and implement its createinitiallayout (Ipagelayout layout) method, Createinitiallayout (Ipagelayout Layout) method enables the layout of view in perspective, with detailed code as follows:

Package com.test.blog.core.ui.perspective; 
  Import Org.eclipse.ui.IFolderLayout; 
  Import Org.eclipse.ui.IPageLayout;  
  Import Org.eclipse.ui.IPerspectiveFactory;  Import Com.test.blog.core.ui.views.detaillog.DetailLogsView; Import Com.test.blog.core.ui.views.jobinfo.JobInformationView; Import Com.test.blog.core.ui.views.statinfo.DetailStatsView; 
  Import Com.test.blog.core.ui.views.statinfo.SimpleStatsView; /** *//** * The class define for the test blog perspective. ﹤br/> * * $Id: perspective.java,v 1.9 2007/03/23 07:48:54 Pub EXP $ * */public class perspective implements Spectivefactory ...  {public static final String ID = ' com.test.blog.core.ui.perspective.Perspective ';//$NON-nls-1$ Public void Createinitiallayout (ipagelayout layout) ...         {//here does not need to display editor, so set to invisible layout.seteditorareavisible (false);          String Editorarea = Layout.geteditorarea ();         Here are the location layout definitions for each view, which can be configured directly in Plugin.xml to achieve the same effectLayout.addview (Jobinformationview.id, Ipagelayout.left, 0.45f, Editorarea);                  Layout.addview (Detaillogsview.id, Ipagelayout.bottom, 0.4f, Editorarea);         String Loginfofolderid = "Position.statlog"; Ifolderlayout Bottomfolder = Layout.createfolder (Loginfofolderid, Ipagelayout.bottom, 0.5f, JobInformation         View.id);         Bottomfolder.addview (simplestatsview.id);         Bottomfolder.addview (detailstatsview.id);         Layout.getviewlayout (jobinformationview.id). Setcloseable (false);         Layout.getviewlayout (simplestatsview.id). Setcloseable (false);     Layout.getviewlayout (detailstatsview.id). Setcloseable (false);  }  }

This is just a direct use of the view ID in your code, and if you really want the view of these IDs to be displayed, you also need to give them a definition of these view IDs in your plugin.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.