/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.dynamo.dialog;

import java.util.*;
import com.silverwrist.dynamo.iface.*;

class DefaultDialogLAF implements DialogPLAF
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private ResourceBundle m_captions;

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  DefaultDialogLAF()
  {
    m_captions = ResourceBundle.getBundle("com.silverwrist.dynamo.dialog.ButtonCaptions",Locale.getDefault());

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface DialogPLAF
   *--------------------------------------------------------------------------------
   */

  public Object getButtonRendering(String button_name)
  {
    String caption;
    try
    { // get the default caption
      caption = m_captions.getString(button_name);

    } // end try
    catch (MissingResourceException e)
    { // default to just using the button name
      caption = button_name;

    } // end catch

    StringBuffer buf = new StringBuffer("<input type=\"submit\" name=\"");
    buf.append(button_name).append("\" value=\"").append(caption).append("\" />");
    return buf.toString();

  } // end getButtonRendering

  public boolean isButtonClicked(Request r, String button_name)
  {
    return r.getParameters().containsKey(button_name);

  } // end isButtonClicked

  public Object getContentHeader(String title, String subtitle)
  {
    StringBuffer buf = new StringBuffer("<span class=\"chdrtitle\">");
    buf.append(title).append("</span>\n");
    if (subtitle!=null)
      buf.append("&nbsp;&nbsp;<span class=\"chdrsubtitle\">").append(subtitle).append("</span>\n");
    buf.append("<hr align=\"left\" size=\"2\" width=\"90%\" noshade=\"noshade\" />\n");
    return buf.toString();

  } // end getContentHeader

} // end class DefaultDialogLAF
