//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
// RCS-ID:      $Id: dlgPartition.h 7606 2009-02-23 15:30:58Z dpage $
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
// This software is released under the Artistic Licence
//
// dlgPartition.h - Greenplum Partition property 
//
//////////////////////////////////////////////////////////////////////////


#ifndef __DLG_PARTITIONPROP
#define __DLG_PARTITIONPROP

#include "dlg/dlgProperty.h"

class pgSchema;
class pgTable;
class gpPartition;
class pgColumn;

class dlgPartition : public dlgSecurityProperty
{
public:
    dlgPartition(pgaFactory *factory, frmMain *frame, gpPartition *db, pgSchema *sch);
    int Go(bool modal);

    void CheckChange();
    wxString GetSql();
    pgObject *CreateObject(pgCollection *collection);
    pgObject *GetObject();

private:
    pgSchema *schema;
    gpPartition *table;

    void OnOK(wxCommandEvent &ev);
    void OnChangeTable(wxCommandEvent &ev);
#ifdef __WXMAC__
    void OnChangeSize(wxSizeEvent &ev);
#endif

    void OnAddTable(wxCommandEvent &ev);
    void OnRemoveTable(wxCommandEvent &ev);
    void OnSelChangeTable(wxCommandEvent &ev);

    /*void OnAddCol(wxCommandEvent &ev);
    void OnChangeCol(wxCommandEvent &ev);
    void OnRemoveCol(wxCommandEvent &ev);
    void OnSelChangeCol(wxListEvent &ev);*/

    void OnAddConstr(wxCommandEvent &ev);
    void OnRemoveConstr(wxCommandEvent &ev);
    void OnSelChangeConstr(wxListEvent &ev);

    void OnChangeVacuum(wxCommandEvent &ev);

    void FillConstraint();
    void FillAutoVacuumParameters(wxString& setString, wxString& resetStr,
                                 const wxString& parameter, const wxString& val);
    wxString GetItemConstraintType(ctlListView *list, long pos);
    bool hasPK;

    wxArrayString previousColumns, previousConstraints, previousTables;
    wxArrayString tableOids, inheritedTableOids;
    wxTreeItemId columnsItem, constraintsItem;

    wxString GetNumString(wxTextCtrl *ctl, bool enabled, const wxString &val);
    wxString AppendNum(bool &changed, wxTextCtrl *ctl, long val);
    wxString AppendNum(bool &changed, wxTextCtrl *ctl, double val);

    bool tableVacEnabled, hasVacuum, settingAutoVacuum;
    long settingVacBaseThr, settingAnlBaseThr, settingCostDelay, settingCostLimit,
         settingFreezeMinAge, settingFreezeMaxAge, settingFreezeTableAge;
    long tableVacBaseThr, tableAnlBaseThr, tableCostDelay, tableCostLimit,
         tableFreezeMinAge, tableFreezeMaxAge, tableFreezeTableAge;
    double settingVacFactor, settingAnlFactor;
    double tableVacFactor, tableAnlFactor;

    /* Toast Table */
    bool toastTableVacEnabled, toastTableHasVacuum;
    long toastTableVacBaseThr, toastTableAnlBaseThr, toastTableCostDelay, toastTableCostLimit,
         toastTableFreezeMinAge, toastTableFreezeMaxAge, toastTableFreezeTableAge;
    double toastTableVacFactor, toastTableAnlFactor;

    DECLARE_EVENT_TABLE()
};

#endif
