package pointGroups.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import pointGroups.gui.event.EventDispatcher;
import pointGroups.gui.symchooser.SymmetryChooser;


public class MainFrame
  extends JFrame
{

  private static final long serialVersionUID = 1886397100814345247L;

  protected JMenuBar menuBar;
  protected JPanel schlegelView;
  protected JPanel pointPicker = new JPanel();
  protected JPanel symmetryChooser;
  protected JPanel coordinates;
  protected JPanel statusBar;
  protected JFrame log;
  
  protected JSplitPane mainSplitPane;
  protected JSplitPane leftTopComponent;
  protected JSplitPane leftComponent;
  
  protected EventDispatcher dispatcher = EventDispatcher.get();

  public MainFrame() {
    
    setTitle("Point groups");
    setSize(1000, 800);
    setLocationRelativeTo(null); // center window
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    log = new LogFrame();
    
    // setting up main split pane
    schlegelView = new SchlegelView();
    Component leftPanel = setUpLeftPanel();   
    
    // ensures to drag the divider all the way to both sides
    Dimension minimumSize = new Dimension(0, 0);
    leftPanel.setMinimumSize(minimumSize);
    schlegelView.setMinimumSize(minimumSize);
    
    mainSplitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, schlegelView);
    mainSplitPane.setResizeWeight(0);
    mainSplitPane.setDividerLocation(320);
    mainSplitPane.setOneTouchExpandable(true);
    mainSplitPane.setBorder(BorderFactory.createEmptyBorder());

    menuBar = new Menubar(dispatcher);
    statusBar = new StatusBar(dispatcher);

    add(menuBar, BorderLayout.NORTH);
    add(mainSplitPane, BorderLayout.CENTER);
    add(statusBar, BorderLayout.SOUTH);
    
    setVisible(true);
  }

  private Component setUpLeftPanel() {

    symmetryChooser = new SymmetryChooser();
    pointPicker = new PointPicker(false);
    coordinates = new CoordinateView(3, 4, dispatcher);
    
    leftTopComponent = new JSplitPane(JSplitPane.VERTICAL_SPLIT, symmetryChooser, pointPicker);
    leftComponent = new JSplitPane(JSplitPane.VERTICAL_SPLIT, leftTopComponent, coordinates);

    leftComponent.setBorder(BorderFactory.createEmptyBorder());
    leftTopComponent.setBorder(BorderFactory.createEmptyBorder());
    leftComponent.setOneTouchExpandable(true);
    leftTopComponent.setOneTouchExpandable(true);

    leftComponent.setDividerLocation(600);
    leftTopComponent.setDividerLocation(500);

    return leftComponent;
  }

  public static void main(String args[]) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          new MainFrame();
        }
      });
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

@@ -125,16 +125,89 @@
 mension;
+%0Aimport java.awt.event.ActionEvent;%0Aimport java.awt.event.ActionListener;
 %0A%0Aimport
@@ -460,16 +460,301 @@
 atcher;%0A
+import pointGroups.gui.event.EventHandler;%0Aimport pointGroups.gui.event.types.ShowCoordinateEvent;%0Aimport pointGroups.gui.event.types.ShowCoordinateHandler;%0Aimport pointGroups.gui.event.types.ShowFundamentalDomainEvent;%0Aimport pointGroups.gui.event.types.ShowFundamentalDomainHandler;%0A
 import p
@@ -1008,23 +1008,8 @@
 cker
- = new JPanel()
 ;%0A  
@@ -1314,16 +1314,97 @@
 r.get();
+%0A  protected MenuBarEventHandler menuBarEventHandler = new MenuBarEventHandler();
 %0A%0A  publ
@@ -3176,34 +3176,1330 @@
 0);%0A
+    
 %0A    
-return leftComponent;
+// add EventHandler for View menubar item%0A    dispatcher.addHandler(ShowFundamentalDomainEvent.TYPE, menuBarEventHandler);%0A    dispatcher.addHandler(ShowCoordinateEvent.TYPE, menuBarEventHandler);%0A%0A  %7D%0A  %0A  %0A  /**%0A   * Method to hide CoordinateView and PointPickerView only!%0A   * @param component JSplitPane containing CoordinateView or PointPicker%0A   */%0A  private void hideView(JSplitPane component) %7B%0A    component.setLastDividerLocation(component.getDividerLocation());%0A    component.setDividerLocation(1.0);%0A  %7D%0A  %0A  /**%0A   * Method to show CoordinateView and PointPickerView only!%0A   * @param component JSplitPane containing CoordinateView or PointPicker%0A   */%0A  private void showView(JSplitPane component) %7B%0A    component.setDividerLocation(component.getLastDividerLocation());%0A  %7D%0A  %0A  private class MenuBarEventHandler implements ShowCoordinateHandler, ShowFundamentalDomainHandler %7B%0A%0A    @Override%0A    public void onShowCoordinateEvent(ShowCoordinateEvent event) %7B%0A      if (event.getVisible())%0A        showView(leftComponent);%0A      else%0A        hideView(leftComponent);%0A    %7D%0A%0A    @Override%0A    public void onShowFundamentalDomainEvent(ShowFundamentalDomainEvent event) %7B%0A      if (event.getVisible())%0A        showView(leftTopComponent);%0A      else%0A        hideView(leftTopComponent);%0A      %0A    %7D%0A    
 %0A  %7D

resolve merge conflicts with remote branch