Geodatabase Designer
bin\TruncateGeodatabase.cls

' Copyright 2008 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
' 




Option Explicit

Private Const COMMAND_CAPTION As String = "Truncate Object"
Private Const MODULE_NAME As String = "TruncateGeodatabase.cls"

Private mPictureDisp As IPictureDisp
Private mApplication As esriFramework.IApplication

Implements ICommand

Private Sub Class_Initialize()
    Set mPictureDisp = LoadResPicture("GD_TRUNCATE", 0)
End Sub

Private Sub Class_Terminate()
    Set mPictureDisp = Nothing
    Set mApplication = Nothing
End Sub

Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
    ICommand_Bitmap = mPictureDisp
End Property

Private Property Get ICommand_Caption() As String
    ICommand_Caption = COMMAND_CAPTION
End Property

Private Property Get ICommand_Category() As String
    ICommand_Category = COMMAND_CATEGORY
End Property

Private Property Get ICommand_Checked() As Boolean
    '
End Property

Private Property Get ICommand_Enabled() As Boolean
    Dim pGxApplication As esriCatalogUI.IGxApplication
    Dim pGxObject As esriCatalog.IGxObject
    Dim pGxDatabase As esriCatalog.IGxDatabase
    Dim pGxDataset As esriCatalog.IGxDataset
    '
    Set pGxApplication = mApplication
    Set pGxObject = pGxApplication.SelectedObject
    '
    If TypeOf pGxObject Is esriCatalog.IGxDatabase Then
        Set pGxDatabase = pGxObject
        If pGxDatabase.WorkspaceName.Type <> esriFileSystemWorkspace Then
            ICommand_Enabled = True
        Else
            ICommand_Enabled = False
        End If
    Else
        If TypeOf pGxObject Is esriCatalog.IGxDataset Then
            Set pGxDataset = pGxObject
            Select Case pGxDataset.Type
            Case esriGeoDatabase.esriDatasetType.esriDTFeatureClass
                ICommand_Enabled = True
            Case esriGeoDatabase.esriDatasetType.esriDTTable
                ICommand_Enabled = True
            Case esriGeoDatabase.esriDatasetType.esriDTFeatureDataset
                ICommand_Enabled = True
            Case Else
                ICommand_Enabled = False
            End Select
        Else
            ICommand_Enabled = False
        End If
    End If
End Property

Private Property Get ICommand_HelpContextID() As Long
    '
End Property

Private Property Get ICommand_HelpFile() As String
    '
End Property

Private Property Get ICommand_Message() As String
    ICommand_Message = COMMAND_CAPTION
End Property

Private Property Get ICommand_Name() As String
    ICommand_Name = "GeodatabaseDesigner_TruncateGeodatabase"
End Property

Private Sub ICommand_OnClick()
    On Error GoTo ErrorHandler
    '
    Select Case MsgBox("This command will remove all rows/features from the selected object." & vbCrLf & "Are you sure?", vbYesNoCancel, App.FileDescription)
    Case vbCancel, vbNo
        Exit Sub
    Case vbYes
        '-----------
        ' Let's Go!
        '-----------
    Case Else
        Exit Sub
    End Select
    '
    Call modUtility.TruncateGeodatabase(mApplication)
    '
    Exit Sub
ErrorHandler:
    Call HandleError(True, "ICommand_OnClick " & MODULE_NAME & " (" & CStr(Erl) & ")", Err.Number, Err.Source, Err.Description)
End Sub

Private Sub ICommand_OnCreate(ByVal hook As Object)
    Set mApplication = hook
End Sub

Private Property Get ICommand_Tooltip() As String
    ICommand_Tooltip = COMMAND_CAPTION
End Property