<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:sec="http://www.springframework.org/security/tags"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head/>

    <h:body>
        <ui:composition template="#{root}/templates/CommonTemplate.xhtml">
            <ui:define name="content">

                <ui:insert name="furtherForms"/>

                <p:layout id="layout" fullPage="true">

                    <p:layoutUnit position="north" collapsible="false">
                        <h:form id="menuForm">
                            <p:toolbar>
                                <p:toolbarGroup align="left">
                                    <h:outputText styleClass="kieker-title" value="Kieker #{showProjectName ? '&raquo;' : ''} #{showProjectName ? globalPropertiesBean.shortenLongName(projectName, 30) : ''}#{unsavedModifications ? '*' : ''}"/>
                                </p:toolbarGroup>
                                <p:toolbarGroup align="right">

                                    <p:commandButton styleClass="perspective-button" icon="ui-icon-home" onclick="toHomeConfirmation.show()" disabled="#{pagename == 'projectOverview'}" rendered="#{unsavedModifications}" />
                                    <p:button styleClass="perspective-button" icon="ui-icon-home" outcome="projectOverview" disabled="#{pagename == 'projectOverview'}" rendered="#{not unsavedModifications}" />

                                    <p:separator/>

                                    <p:commandButton styleClass="perspective-button" icon="ui-icon-analysisEditor" value="#{localizedMessages.lblAnalysisEditor}" onclick="toAnalysisEditorConfirmation.show()" disabled="#{pagename == 'analysisEditor' or empty projectName}" rendered="#{unsavedModifications}" />
                                    <p:button styleClass="perspective-button" icon="ui-icon-analysisEditor" value="#{localizedMessages.lblAnalysisEditor}" outcome="analysisEditor" disabled="#{pagename == 'analysisEditor' or empty projectName}" rendered="#{not unsavedModifications}" >
                                        <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                                    </p:button>

                                    <c:if test="#{sec:areAnyGranted('User, Administrator')}">
                                        <p:commandButton styleClass="perspective-button" icon="ui-icon-cockpitEditor" value="#{localizedMessages.lblCockpitEditor}" onclick="toCockpitEditorConfirmation.show()" disabled="#{pagename == 'cockpitEditor' or empty projectName}" rendered="#{unsavedModifications}" />
                                        <p:button styleClass="perspective-button" icon="ui-icon-cockpitEditor" value="#{localizedMessages.lblCockpitEditor}" outcome="cockpitEditor" disabled="#{pagename == 'cockpitEditor' or empty projectName}" rendered="#{not unsavedModifications}" >
                                            <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                                        </p:button>
                                    </c:if>

                                    <p:separator/>

                                    <c:if test="#{sec:areAnyGranted('User, Administrator')}">
                                        <p:commandButton styleClass="perspective-button" icon="ui-icon-analysis" value="#{localizedMessages.lblAnalysis}" onclick="toControllerConfirmation.show()" disabled="#{pagename == 'controller' or empty projectName}" rendered="#{unsavedModifications}" />
                                        <p:button styleClass="perspective-button" icon="ui-icon-analysis" value="#{localizedMessages.lblAnalysis}" outcome="controller" disabled="#{pagename == 'controller' or empty projectName}" rendered="#{not unsavedModifications}" >
                                            <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                                        </p:button>
                                    </c:if>

                                    <p:commandButton styleClass="perspective-button" icon="ui-icon-cockpit" value="#{localizedMessages.lblCockpit}" onclick="toCockpitConfirmation.show()" disabled="#{pagename == 'cockpit' or empty projectName}" rendered="#{unsavedModifications}" />
                                    <p:button styleClass="perspective-button" icon="ui-icon-cockpit" value="#{localizedMessages.lblCockpit}" outcome="cockpit" disabled="#{pagename == 'cockpit' or empty projectName}" rendered="#{not unsavedModifications}" >
                                        <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                                    </p:button>

                                    <c:if test="#{sec:areAnyGranted('Administrator')}">
                                        <p:separator/>

                                        <p:commandButton styleClass="perspective-button" icon="ui-icon-userManagement" value="#{localizedMessages.lblUserManagement}" onclick="toUserManagmentConfirmation.show()" disabled="#{pagename == 'userManagement'}" rendered="#{unsavedModifications}" />
                                        <p:button styleClass="perspective-button" icon="ui-icon-userManagement" value="#{localizedMessages.lblUserManagement}" outcome="userManagement" disabled="#{pagename == 'userManagement'}" rendered="#{not unsavedModifications}" >
                                            <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                                        </p:button>
                                    </c:if>
                                </p:toolbarGroup>
                            </p:toolbar>

                            <p:menubar> 

                                <ui:insert name="furtherMenuBarEntries"/>

                                <p:submenu label="#{localizedMessages.lblHelp}">
                                    <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-userGuide" value="  #{localizedMessages.lblUserGuide}" ajax="false" url="http://kieker-monitoring.net/documentation/"/>
                                    <p:separator/>
                                    <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-about" value="  #{localizedMessages.lblAbout}" onclick="aboutDlg.show()" ajax="true"/>
                                </p:submenu>

                                <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username} (#{userBean.userrole})" ajax="true" url="#{request.contextPath}/j_spring_security_logout" rendered="#{not unsavedModifications}"/>
                                <p:menuitem styleClass="logOutButton element-with-whitespace" icon="ui-icon-logout" value=" #{userBean.username} (#{userBean.userrole})" onclick="logOutConfirmation.show()" ajax="true" rendered="#{unsavedModifications}"/>
                            </p:menubar>
                            <ui:insert name="furtherMenuBar"/>
                        </h:form>
                    </p:layoutUnit>

                    <ui:insert name="centerLayout"/>

                    <ui:insert name="furtherLayoutUnits"/>

                </p:layout>

                <p:dialog  header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toHomeConfirmation" >  

                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:commandButton id="confirm" value="#{localizedMessages.lblYes}" ajax="false" oncomplete="toHomeConfirmation.hide()" action="ProjectOverviewPage.xhtml?faces-redirect=true" />  
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toHomeConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toAnalysisEditorConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}" outcome="analysisEditor"> 
                                <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                            </p:button>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toAnalysisEditorConfirmation.hide()" type="button" /> 
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toControllerConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}" outcome="controller"> 
                                <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                            </p:button>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toControllerConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toCockpitEditorConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}" outcome="cockpitEditor"> 
                                <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                            </p:button>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toCockpitEditorConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toCockpitConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}" outcome="cockpit"> 
                                <f:param name="projectName" value="#{projectName}" rendered="#{not empty projectName}"/>
                            </p:button>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toCockpitConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="toUserManagmentConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}" outcome="userManagement"/>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="toUserManagmentConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  
                <p:dialog header="#{localizedMessages.lblUnsavedChangesShort}" resizable="false" widgetVar="logOutConfirmation" >  
                    <h:form>  
                        <div style="text-align: center">
                            <h:outputText value="#{localizedMessages.lblUnsavedChangesLong}" /> 
                        </div>

                        <hr/>
                        <div class="dialog-button-box">
                            <p:button id="confirm" value="#{localizedMessages.lblYes}"  href="#{request.contextPath}/j_spring_security_logout"/>
                            <p:commandButton id="decline" value="#{localizedMessages.lblCancel}" onclick="logOutConfirmation.hide()" type="button" />   
                        </div>
                    </h:form>
                </p:dialog>  

                <!-- Include the about-dialog. -->
                <ui:include src="../dialogs/AboutDialog.xhtml" />
                <!-- Include the dialog for the configuration. -->
                <ui:include src="../dialogs/SettingsDialog.xhtml" />

                <ui:insert name="furtherDialogIncludes"/>
            </ui:define>
        </ui:composition>
    </h:body>

</html>
