开发者

Is there a way to force Eclipse to open in the default perspective?

开发者 https://www.devze.com 2023-01-31 05:01 出处:网络
Problem: Whenever I start Eclipse (3.5.2 Galileo) it always opens in the previous perspective I was using. I want it to ALWAYS open in the default perspective, but I can\'t find a way开发者_JAVA百科 o

Problem:

Whenever I start Eclipse (3.5.2 Galileo) it always opens in the previous perspective I was using. I want it to ALWAYS open in the default perspective, but I can't find a way开发者_JAVA百科 of setting that in the preferences.

Background (i.e. why this is important to me - LONG!):

I use a laptop for dev work for which I have a docking station at my desk. When I'm docked, I have two monitors giving me 2400 horizontal pixels of real estate and I work in a perspective that has a full-size code editing screen on one monitor and all other views (console, package explorer, JUnit, etc.) open in floating windows on the other monitor.

When I undock and use the built in screen on the laptop, I "only" have 1920 pixels horizontally. If I open my "2-screen" perspective in this situation, the floating windows are dragged left so that their right-hand edges align with the screen, and they overlap each other and the main coding window. What's worse is that if I exit Eclipse or switch to my 1-screen perspective (which I've set as the default), the current layout of the 2-screen perspective is saved and so I have to drag all the windows back to where they belong when I get back to my docking station.

I try to remember to switch to the 1-screen perspective before I close Eclipse each time, especially if I know I'll be working undocked next time I open Eclipse, but I forget more often than I remember, sadly.

Therefore, I'd like to have Eclipse always open in the default, 1-screen Java perspective. If I'm undocked, that's the perspective I'll use. If I'm docked, I can switch to the 2-screen quickly using one icon in the toolbar.

Any suggestions?


There is no setting in the preferences dialog to do that. However, as a hack you can find the last perspective attribute stored in the file: workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml. It's an XML file, and the attribute you want to freeze is: <perspectives activePerspective="...">.

You can use a simple script to alter that setting before running Eclipse.


Run this script before running eclipse:

perl -p0777i.bak -e "s/activePerspective=\"[^\"]*\"/activePerspective=\"org.eclipse.jst.j2ee.J2EEPerspective\"/g" ~/workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml


If you can find out what that perspective's ID is, you can force Eclipse to reopen with it using the -perspective command line switch (followed by that ID).

0

精彩评论

暂无评论...
验证码 换一张
取 消