package samples.javaclient.analyzer;
import oracle.dss.graph.Graph;
import oracle.dss.graph.gui.GraphType;
import oracle.bali.ewt.dialog.JEWTDialog;

/**
 * Dialog for changing the graph type.  
 * This class uses the
 * GraphType dialog provided by BI Beans.
 */
public class GraphTypeDialog extends JEWTDialog  {
  /**
   * The graph whose type to change.
   */
  private Graph m_graph;
  /**
   * The graph type.
   */
  private GraphType m_graphType;
  /**
   * Title text for the dialog: "Graph Type".
   */
  private static final String GRAPH_TYPE = "Graph Type";

  /**
   * Constructor.
   * 
   * @param graph The graph that will be updated.
   */
  public GraphTypeDialog(Graph graph) {
    m_graph = graph;
    setTitle(GRAPH_TYPE);

    // Add ok and cancel buttons
    setButtonMask(BUTTON_CANCEL + BUTTON_OK); 
            
    // Initialize the GraphType panel
    m_graphType = new GraphType(m_graph); 

    // Add the GraphType panel to the dialog
    setContent(m_graphType);

  }

  /**
   * Applies the new graph type to the graph.
   */
  public void applyGraphType() {
    m_graphType.apply();    
  }
}