8

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 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?

Community
  • 1
  • 1
Rob Gilliam
  • 2,680
  • 4
  • 26
  • 29

3 Answers3

4

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.

vz0
  • 32,345
  • 7
  • 44
  • 77
  • I'm on XP and don't have perl/python/etc. installed, so scripting is never "simple" but I'll give your approach a try. – Rob Gilliam Dec 15 '10 at 16:53
3

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).

nitind
  • 19,089
  • 4
  • 34
  • 43
2

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
Johan Frick
  • 1,084
  • 1
  • 10
  • 18
  • +1 for the script as I'm sure it'll be useful to someone else, but I don't have perl and I'm on Windows XP (so ~/workspace... won't work for me) – Rob Gilliam Jul 27 '11 at 11:21