//
//  WBMainWindow.h
//  MySQLWorkbench
//
//  Created by Alfredo Kojima on 1/Oct/08.
//  Copyright 2008 Sun Microsystems Inc. All rights reserved.
//

#import "sigobjc++.h"
#import <Cocoa/Cocoa.h>
#include "workbench/wb_context_ui.h"

@class WBMainController;
@class GRTShellViewController;
@class WBToolbarTabView;
@class WBModelSidebarController;
@class WBMenuManager;
@class WBToolbarManager;
@class WBBasePanel;
@class WBOverviewPanel;
@class GRTTreeDataSource;
@class WBOutputPanelController;

@class WBPluginEditorBase;


// Subclass of NSWindow to override makeFirstResponder: and detect key view changes
@interface WBWindow : NSWindow
{
}
@end



@interface WBMainWindow : NSWindowController
{
  IBOutlet NSTextField *statusBarText;

  IBOutlet NSTabView *topTabView;
  IBOutlet NSTabView *bottomTabView;
  
  IBOutlet NSTabView *sideTabView;
  
  IBOutlet NSView *drawerView;
  IBOutlet NSDrawer *drawer;
  
  IBOutlet NSView *sideToolbar;
  
  IBOutlet NSSplitView *sideSplitView;
  IBOutlet NSSplitView *mainSplitView;

  IBOutlet GRTShellViewController *shellController;
  IBOutlet WBModelSidebarController *modelSidebarController;
  IBOutlet WBOutputPanelController *outputController;
  
  IBOutlet NSMenu *contextMenu;
  	
  NSMutableDictionary *_panels;
  
  NSTimer *_backendTimer;
  
  NSMutableArray *_closedTopTabs;
  NSMutableArray *_closedBottomTabs;
  
  WBMainController *_mainController;
  
  WBMenuManager *_menuManager;
  WBToolbarManager *_toolbarManager;

  WBOverviewPanel *_workspace_overview;
  WBOverviewPanel *_physical_overview;
  
  wb::WBContextUI *_wbui;	
}

- (void)load;
- (void)setOwner:(WBMainController*)owner;
- (void)setWBContext:(wb::WBContextUI*)wbui;
- (void)setupReady;
- (NSTabViewItem*)addTopPanel:(WBBasePanel*)panel;
- (NSTabViewItem*)addBottomPanel:(WBBasePanel*)panel;
- (GRTShellViewController*)shell;
- (WBOutputPanelController*)outputPanel;
- (WBBasePanel*) findPanelForPluginType: (Class) type;
- (void) activatePanel: (WBBasePanel*) panel;

- (WBMainController*)owner;

- (WBMenuManager*)menuManager;
- (WBToolbarManager*)toolbarManager;

- (IBAction)showMySQLOverview:(id)sender;
- (IBAction)showOutput:(id)sender;
- (IBAction)showGRTShell:(id)sender;
- (IBAction)toggleGRTSidebar:(id)sender;

- (void)focusSearchField:(id)sender;
- (void)performSearchObject:(id)sender;

- (void)blockGUI:(BOOL)lock;

- (void)popupDiagramMenu:(wb::MenuItemList*)items atPoint:(NSPoint)pos;

- (void)switchToDiagramWithIdentifier:(const char*)identifier;
- (void)reopenBottomTabViewItem:(id)identifier;

- (void)changedIdentifierOfPanel: (WBBasePanel*)panel
                  fromIdentifier: (id)identifier;

- (void)resetWindowLayout;

- (void)refreshGUI:(wb::RefreshType)type
         argument1:(const std::string&)arg1
         argument2:(NativeHandle)arg2;

- (void)setStatusText:(NSString*)text;

- (mdc::CanvasView*)createView:(const char*)oid
                          name:(const char*)name;
- (void)destroyView:(mdc::CanvasView*)view;

- (void)closePanel:(WBBasePanel*)panel;
- (void)closeTopPanelWithIdentifier:(id)identifier;
- (void)closeBottomPanelWithIdentifier:(id)identifier;
- (void)closeEditorsMatching: (NSString*)identifier;

- (WBBasePanel*)activePanel;
- (WBBasePanel*)selectedMainPanel;

- (void)firstResponderChanged: (NSResponder*)responder;

@end
