Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 903f8b72a30463077af5070df74c81f6f637759e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Victor Roldan Betancort - initial API and implementation
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.cdo.internal.ui.perspectives;

import org.eclipse.emf.cdo.internal.ui.views.CDORemoteSessionsView;
import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView;
import org.eclipse.emf.cdo.internal.ui.views.CDOWatchListView;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.PlatformUI;

/**
 * @author Victor Roldan Betancort
 */
public class CDOExplorerPerspective implements IPerspectiveFactory
{
  public static final String ID = "org.eclipse.emf.cdo.ui.CDOExplorerPerspective"; //$NON-NLS-1$

  private IPageLayout pageLayout;

  public CDOExplorerPerspective()
  {
  }

  public IPageLayout getPageLayout()
  {
    return pageLayout;
  }

  public void createInitialLayout(IPageLayout pageLayout)
  {
    this.pageLayout = pageLayout;
    addViews();
    addPerspectiveShortcuts();
    addViewShortcuts();
  }

  protected void addViews()
  {
    IFolderLayout BrowsingFolderLayout0 = pageLayout.createFolder("cdoFolderLayout0", IPageLayout.LEFT, 0.20f, //$NON-NLS-1$
        pageLayout.getEditorArea());
    BrowsingFolderLayout0.addView(IPageLayout.ID_PROJECT_EXPLORER);

    IFolderLayout BrowsingFolderLayout1 = pageLayout.createFolder("cdoFolderLayout1", IPageLayout.BOTTOM, 0.70f, //$NON-NLS-1$
        IPageLayout.ID_PROJECT_EXPLORER);
    BrowsingFolderLayout1.addView(CDOSessionsView.ID);

    IFolderLayout BrowsingFolderLayout2 = pageLayout.createFolder("cdoFolderLayout3", IPageLayout.BOTTOM, 0.70f, //$NON-NLS-1$
        pageLayout.getEditorArea());
    BrowsingFolderLayout2.addView(IPageLayout.ID_PROP_SHEET);
    BrowsingFolderLayout2.addView(CDOWatchListView.ID);
    BrowsingFolderLayout2.addView(CDORemoteSessionsView.ID);

    IFolderLayout BrowsingFolderLayout3 = pageLayout.createFolder("cdoFolderLayout2", IPageLayout.RIGHT, 0.8f, //$NON-NLS-1$
        pageLayout.getEditorArea());
    BrowsingFolderLayout3.addView(IPageLayout.ID_OUTLINE);
  }

  protected void addViewShortcuts()
  {
    pageLayout.addShowViewShortcut(CDOSessionsView.ID);
    pageLayout.addShowViewShortcut(CDOWatchListView.ID);
    pageLayout.addShowViewShortcut(CDORemoteSessionsView.ID);
    pageLayout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
    pageLayout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
    pageLayout.addShowViewShortcut(IPageLayout.ID_PROJECT_EXPLORER);
  }

  protected void addPerspectiveShortcuts()
  {
    pageLayout.addPerspectiveShortcut(ID);
  }

  static public boolean isCurrent()
  {
    return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective().getId()
        .equals(CDOExplorerPerspective.ID);
  }

}

Back to the top