/*******************************************************************************
 * Copyright (c) 2010 Oak Ridge National Laboratory.
 *  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
 ******************************************************************************/
package org.csstudio.alarm.beast.ui;

import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.console.IConsoleConstants;

/** Alarm Perspective
 *  @author Kay Kasemir
 */
@SuppressWarnings("nls")
public class Perspective implements IPerspectiveFactory
{
    /** ID of this perspective, registered in plugin.xml */
    final public static String ID = "org.csstudio.alarm.beast.ui.perspective";

    // Ideally, these constants would come from e.g.
    // org.csstudio.alarm.beast.ui.alarmtree.AlarmTreeView.ID,
    // but that would add a (circular) dependency to that plugin.
    // This way, one could replace the table or tree view plugins.
    final private static String ID_SNS_PV_UTIL =
        "org.csstudio.diag.pvfields.view.PVFieldsView";
    final private static String ID_ALARM_TREE =
        "org.csstudio.alarm.beast.ui.alarmtree.View";
    final private static String ID_ALARM_TABLE =
        "org.csstudio.alarm.beast.ui.alarmtable.view";

    @Override
    @SuppressWarnings("deprecation")
    public void createInitialLayout(IPageLayout layout)
    {
        // left | editor
        //      |
        //      |
        //      +-------------
        //      | bottom
        String editor = layout.getEditorArea();
        IFolderLayout left = layout.createFolder("left",
                        IPageLayout.LEFT, 0.25f, editor);
        IFolderLayout bottom = layout.createFolder("bottom",
                        IPageLayout.BOTTOM, 0.66f, editor);
        // Stuff for 'left'
        left.addView(ID_ALARM_TREE);
        left.addPlaceholder(IPageLayout.ID_RES_NAV);
        left.addPlaceholder(IPageLayout.ID_PROP_SHEET);
        left.addPlaceholder(ID_SNS_PV_UTIL);

        // Stuff for 'bottom'
        bottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
        bottom.addView(ID_ALARM_TABLE);

        // Populate the "Window/Views..." menu with suggested views
        layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
        layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
    }
}

@@ -611,16 +611,50 @@
 actory;%0A
+import org.eclipse.ui.PlatformUI;%0A
 import o
@@ -1318,24 +1318,122 @@
 ieldsView%22;%0A
+    final private static String ID_ALARM_PANEL =%0A        %22org.csstudio.alarm.beast.ui.areapanel%22;%0A
     final pr
@@ -1714,16 +1714,22 @@
 lLayout(
+final 
 IPageLay
@@ -1867,19 +1867,22 @@
 tom%0A    
-   
+%09final
  String 
@@ -1914,32 +1914,38 @@
 Area();%0A        
+final 
 IFolderLayout le
@@ -2043,16 +2043,22 @@
         
+final 
 IFolderL
@@ -2154,32 +2154,50 @@
 0.66f, editor);%0A
+        %0A        %0A
         // Stuff
@@ -2208,16 +2208,225 @@
  'left'%0A
+        if (isViewAvaialble(ID_ALARM_PANEL))%0A        %7B%0A        %09final IFolderLayout topleft = layout.createFolder(%22topleft%22, IPageLayout.TOP, 0.4f, %22left%22);%0A        %09topleft.addView(ID_ALARM_PANEL);%0A        %7D%0A
         
@@ -2950,11 +2950,233 @@
 );%0A    %7D
+%0A%0A    /** Check if view is available, i.e. suitable plugin was included in product */%0A%09private boolean isViewAvaialble(final String view)%0A    %7B%0A%09%09return PlatformUI.getWorkbench().getViewRegistry().find(view) != null;%0A    %7D
 %0A%7D%0A

Include areapanel in alarm perspective (if available)