
package com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Data.Component;



import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import com.google.common.base.Preconditions;
import com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.CAbstractNodeComponent;
import com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.Data.Component.Navigation.CNavigationPanel;
import com.google.security.zynamics.binnavi.disassembly.INaviModule;
import com.google.security.zynamics.binnavi.disassembly.views.IViewContainer;
import com.jidesoft.swing.JideSplitPane;

/**
 * This is the component that is shown when the data node of a module is selected in the project
 * tree.
 */
public final class CDataNodeComponent extends CAbstractNodeComponent {
  /**
   * Used for serialization.
   */
  private static final long serialVersionUID = -8854928455082131440L;

  private final DataSectionComponent dataSectionComponent;

  /**
   * Creates a new data node component.
   * 
   * @param module Module whose data is shown in the component.
   * @param originContainer
   */
  public CDataNodeComponent(final INaviModule module, final IViewContainer originContainer) {
    super(new BorderLayout());

    Preconditions.checkNotNull(module, "IE01960: Module argument can not be null");

    final JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);

    splitPane.setDoubleBuffered(true);
    splitPane.setOneTouchExpandable(true);
    splitPane.setMinimumSize(new Dimension(0, 0));
    splitPane.setProportionalLayout(true);
    splitPane.setInitiallyEven(true);

    final JPanel panel = new JPanel(new BorderLayout());
    dataSectionComponent = new DataSectionComponent(module, originContainer);
    panel.add(dataSectionComponent);

    final JTabbedPane pane = new JTabbedPane();
    pane.addTab("Navigation", new CNavigationPanel(dataSectionComponent.getHexView()));

    splitPane.addPane(panel);
    splitPane.addPane(pane);
    add(splitPane);
  }

  public DataSectionComponent getDataSectionComponent() {
    return dataSectionComponent;
  }

  /**
   * Frees allocated resources.
   */
  @Override
  public void dispose() {
  }
}
