
/*!
 Copyright 2009 Sun Microsystems, Inc.
 */



#import "WBPluginEditorBase.h"
#import "editor_table_inserts.h"

#include "wb_config.h"

@class DbPrivilegeEditorTab;


class MySQLTableEditorBE;
class MySQLTablePartitionTreeBE;

@class MacTableEditorInformationSource;
@class MacTableEditorColumnsInformationSource;
@class MacTableEditorIndexColumnsInformationSource;
@class MacTableEditorFKColumnsInformationSource;
@class GRTTreeDataSource;


@interface DbMysqlTableEditor : WBPluginEditorBase
{
  IBOutlet NSTabView* mEditorsTabView;
  
  // Table
  IBOutlet NSView* mEditorTable;
  IBOutlet NSTextField* mTableName;
  IBOutlet NSPopUpButton* mTableCollation;
  IBOutlet NSPopUpButton* mTableEngine;
  IBOutlet NSTextView* mTableComment;
  
  // Columns
  IBOutlet NSView* mEditorColumns;
  IBOutlet NSTableView* mColumnsTable;
  IBOutlet NSPopUpButton* mColumnsCollation;
  IBOutlet NSTextView* mColumnsComment;
  IBOutlet NSTextField* mColumnsCommentLabel;
  IBOutlet NSBox* mColumnsDetailsBox;
  IBOutlet NSTextField* mColumnFlagsLabel;
  NSMutableArray* mColumnFlagCheckboxes;
  
  // Indices
  IBOutlet NSView* mEditorIndices;
  IBOutlet NSTableView* mIndicesTable;
  IBOutlet NSTableView* mIndexColumnsTable;
  IBOutlet NSPopUpButton* mIndicesStorageTypes;
  IBOutlet NSTextField* mIndicesBlockSize;
  IBOutlet NSTextField* mIndicesParser;
  IBOutlet NSTextView* mIndicesComment;
  IBOutlet NSBox* mIndicesDetailsBox;
  
  // Foreigh Keys
  IBOutlet NSView* mEditorForeignKeys;
  IBOutlet NSTableView* mFKTable;
  IBOutlet NSTableView* mFKColumnsTable;
  IBOutlet NSPopUpButton* mFKOnUpdate;
  IBOutlet NSPopUpButton* mFKOnDelete;
  IBOutlet NSTextView* mFKComment;
  IBOutlet NSBox* mFKDetailsBox;

  // Triggers
  IBOutlet ScintillaView* mEditorTriggers;
  
  // Partitioning
  IBOutlet NSView* mEditorPartitioning;
  IBOutlet NSButton* mPartitionEnabledCheckbox;
  IBOutlet NSPopUpButton* mPartitionPopup;
  IBOutlet NSPopUpButton* mSubpartitionPopup;
  IBOutlet NSTextField* mPartitionParametersTextField;  
  IBOutlet NSTextField* mSubPartitionParametersTextField;  
  IBOutlet NSComboBox* mPartitionCountCombo;
  IBOutlet NSComboBox* mSubpartitionCountCombo;
  IBOutlet NSButton* mPartitionManualCheckbox;
  IBOutlet NSButton* mSubpartitionManualCheckbox;
  IBOutlet NSOutlineView* mPartitionTable;
  
  // Options
  IBOutlet NSView* mEditorOptions;
  IBOutlet NSPopUpButton* mOptionsPackKeys;
  IBOutlet NSTextField* mOptionsTablePassword;
  IBOutlet NSTextField* mOptionsAutoIncrement;
  IBOutlet NSButton* mOptionsDelayKeyUpdates;
  IBOutlet NSPopUpButton* mOptionsRowFormat;
  IBOutlet NSTextField* mOptionsAvgRowLength;
  IBOutlet NSTextField* mOptionsMinRows;
  IBOutlet NSTextField* mOptionsMaxRows;
  IBOutlet NSButton* mOptionsUseChecksum;
  IBOutlet NSTextField* mOptionsDataDirectory;
  IBOutlet NSTextField* mOptionsIndexDirectory;
  IBOutlet NSTextField* mOptionsUnionTables;
  IBOutlet NSPopUpButton* mOptionsMergeMethod;

  // Inserts
  IBOutlet NSView* mEditorInserts;
  IBOutlet NSTextView* mEditorInsertsText;
  IBOutlet NSButton* mEditorInsertsOpenEditor;
  IBOutlet NSTextField* mEditorInsertsHint;

  IBOutlet NSPanel* mEditorInsertsPanel;
  IBOutlet NSTableView* mEditorInsertsTable;
  IBOutlet NSButton* mEditorInsertsPanelCancel;
  IBOutlet NSButton* mEditorInsertsPanelOK;
  ::bec::TableInsertsGridBE* mGrid;
  
  MySQLTableEditorBE* mBackEnd;
  MacTableEditorColumnsInformationSource* mColumnsDataSource;
  NSArray* mColumnTypes;
  MacTableEditorInformationSource* mIndicesDataSource;
  MacTableEditorIndexColumnsInformationSource* mIndexColumnsDataSource;
  MacTableEditorInformationSource* mFKDataSource;
  MacTableEditorFKColumnsInformationSource* mFKColumnsDataSource;
  GRTTreeDataSource* mPartitionsTreeDataSource;
  
  // Syntax error checking.
  NSTimer* mSyntaxCheckTimer;
  int mErrorCount;
  
  DbPrivilegeEditorTab *mPrivilegesTab;
  
  BOOL mDidAwakeFromNib;
}


- (IBAction) userPickPopup: (id) sender;
- (IBAction) userClickButton: (id) sender;

// Setup for code editor and syntax checking.
- (void) setupEditor;
- (void) resetSyntaxErrors;
- (void) checkSyntax:(NSTimer*) timer;

@end


