<%@ page import="com.atlassian.jira.ComponentManager" %>
<%@ page import="com.atlassian.jira.exception.IssuePermissionException" %>
<%@ page import="com.atlassian.jira.issue.Issue" %>
<%@ page import="com.atlassian.jira.web.action.issue.IssueSummaryAware" %>
<%@ page import="com.atlassian.jira.web.component.issuesummary.IssueSummaryLayoutBean" %>
<%@ page import="com.atlassian.jira.web.component.issuesummary.IssueSummaryWebComponent" %>
<%@ page import="com.opensymphony.user.User" %>
<%@ page import="com.atlassian.plugin.webresource.WebResourceManager" %>
<%@ page import="com.atlassian.jira.config.properties.APKeys"%>
<%@ page import="com.atlassian.jira.web.action.JiraWebActionSupport"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<%--
    A decorator used to print the 'summary' on the left-hand side of the issue.  To use this decorator
    the action must implement IssueSummaryAware.
--%>
<webwork:property value="/" id="action"/>
<%
    Object action = pageContext.getAttribute("action");
    if (action instanceof IssueSummaryAware)
    {
        IssueSummaryAware issueSummaryAware = (IssueSummaryAware) action;
        Issue issue;
        try
        {
            issue = issueSummaryAware.getSummaryIssue();
            User remoteUser = issueSummaryAware.getRemoteUser();
            IssueSummaryLayoutBean layout = issueSummaryAware.getLayoutBean();
            IssueSummaryWebComponent issueSummary = (IssueSummaryWebComponent) ComponentManager.getComponentInstanceOfType(IssueSummaryWebComponent.class);
%>
<%
    WebResourceManager wrm = ComponentManager.getInstance().getWebResourceManager();
    //Check for global turn-off edit issue AJAX setting
    if(issueSummaryAware.isAjaxIssueOperationsEnabled())
    {
        wrm.requireResource("jira.webresources:yui", out);
        wrm.requireResource("jira.webresources:issueoperations", out);
    }
%>

<%@ include file="/includes/decorators/header.jsp" %>


<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td width="200" bgcolor="#f0f0f0" valign="top">
            <%= issueSummary.getHtml(layout, issue, remoteUser) %>
        </td>
        <td bgcolor="#ffffff" valign="top">
            <div style="padding:10px 10px 10px 10px" id="issueContent">
                <decorator:body/>
            </div>
        </td></tr></table>

<%@ include file="/includes/decorators/footer.jsp" %>

<%
        }
        catch (IssuePermissionException e)
        {
%>
<page:applyDecorator name="navigator" >
        <table cellspacing="0" cellpadding="10" border="0" width="100%" bgcolor="#ffffff">
        <tr>
        <td bgcolor="white" valign="top">
            <%@ include file="/includes/generic-notloggedin.jsp" %>
        </td></tr></table>
</page:applyDecorator>

<%
        }
    }
    else
    {
        throw new UnsupportedOperationException("Action " + action + " does not implement IssueSummaryAware");
    }
%>
