/*
* Copyright 2004 Perforce Software. All rights reserved.
*
* Developed by Data Shades Ltd.
*/
#include "P4GTMax.h"
#include "PerforceActionTable.h"
#include "P4GTUtils.h"
#define NumElements(array) (sizeof(array) / sizeof(array[0]))
/*
* Menu actions
*/
static ActionDescription spActions[] = {
ADD_TO_PERFORCE_ACTION,
IDS_ADD_TO_PERFORCE,
IDS_ADD_TO_PERFORCE,
IDS_ADD_TO_PERFORCE,
CHECK_OUT_PERFORCE_ACTION,
IDS_CHECK_OUT_PERFORCE,
IDS_CHECK_OUT_PERFORCE,
IDS_CHECK_OUT_PERFORCE,
CHECK_IN_PERFORCE_ACTION,
IDS_CHECK_IN_PERFORCE,
IDS_CHECK_IN_PERFORCE,
IDS_CHECK_IN_PERFORCE,
LOCK_UNLOCK_PERFORCE_ACTION,
IDS_LOCK_UNLOCK_PERFORCE,
IDS_LOCK_UNLOCK_PERFORCE,
IDS_LOCK_UNLOCK_PERFORCE,
UNDO_ADD_CHECK_OUT_PERFORCE_ACTION,
IDS_UNDO_ADD_CHECK_OUT_PERFORCE,
IDS_UNDO_ADD_CHECK_OUT_PERFORCE,
IDS_UNDO_ADD_CHECK_OUT_PERFORCE,
LAST_RESULTS_PERFORCE_ACTION,
IDS_RESULTS_PERFORCE,
IDS_RESULTS_PERFORCE,
IDS_RESULTS_PERFORCE,
DOCUMENT_STATUS_PERFORCE_ACTION,
IDS_STATUS_PERFORCE,
IDS_STATUS_PERFORCE,
IDS_STATUS_PERFORCE,
DOCUMENT_HISTORY_PERFORCE_ACTION,
IDS_HISTORY_PERFORCE,
IDS_HISTORY_PERFORCE,
IDS_HISTORY_PERFORCE,
CHECKED_OUT_PERFORCE_ACTION,
IDS_CHECKED_OUT_PERFORCE,
IDS_CHECKED_OUT_PERFORCE,
IDS_CHECKED_OUT_PERFORCE,
INFO_PERFORCE_ACTION,
IDS_INFO_PERFORCE,
IDS_INFO_PERFORCE,
IDS_INFO_PERFORCE,
OPEN_DEPOT_PERFORCE_ACTION,
IDS_OPEN_DEPOT_PERFORCE,
IDS_OPEN_DEPOT_PERFORCE,
IDS_OPEN_DEPOT_PERFORCE,
OPTIONS_PERFORCE_ACTION,
IDS_OPTIONS_PERFORCE,
IDS_OPTIONS_PERFORCE,
IDS_OPTIONS_PERFORCE,
HELP_PERFORCE_ACTION,
IDS_HELP_PERFORCE,
IDS_HELP_PERFORCE,
IDS_HELP_PERFORCE,
ABOUT_PERFORCE_ACTION,
IDS_ABOUT_PERFORCE,
IDS_ABOUT_PERFORCE,
IDS_ABOUT_PERFORCE,
SERVER_ONLINE_ACTION,
IDS_ONLINE_PERFORCE,
IDS_ONLINE_PERFORCE,
IDS_ONLINE_PERFORCE,
};
PerforceActionTable::PerforceActionTable( HINSTANCE hInstance ) : ActionTable ( PerforceActions,
PerforceContext,
TSTR(_T("Perforce")),
NULL,
NumElements(spActions),
spActions,
hInstance )
{
}
BOOL PerforceActionTable::GetMenuText( int cmdId, TSTR& menuText )
{
// If first item on menu then get file information
if ( cmdId == ADD_TO_PERFORCE_ACTION ) {
P4GT_RefreshMenuState();
}
if ( cmdId == LOCK_UNLOCK_PERFORCE_ACTION ) {
menuText = P4GT_LockUnlockLabel();
return TRUE;
}
else if ( cmdId == UNDO_ADD_CHECK_OUT_PERFORCE_ACTION ) {
menuText = P4GT_UndoLabel();
return TRUE;
}
else if ( cmdId == SERVER_ONLINE_ACTION ) {
menuText = P4GT_EnableDisableLabel();
return TRUE;
}
else {
return ActionTable::GetMenuText( cmdId, menuText );
}
}
BOOL PerforceActionTable::IsEnabled( int cmdId )
{
switch ( cmdId ) {
case ADD_TO_PERFORCE_ACTION:
return P4GT_AddEnabled();
case CHECK_OUT_PERFORCE_ACTION:
return P4GT_CheckOutEnabled();
case CHECK_IN_PERFORCE_ACTION:
return P4GT_CheckInEnabled();
case LOCK_UNLOCK_PERFORCE_ACTION:
return P4GT_LockUnlockEnabled();
case UNDO_ADD_CHECK_OUT_PERFORCE_ACTION:
return P4GT_UndoEnabled();
case DOCUMENT_STATUS_PERFORCE_ACTION:
return P4GT_DocumentStatusEnabled();
case DOCUMENT_HISTORY_PERFORCE_ACTION:
return P4GT_DocumentHistoryEnabled();
case LAST_RESULTS_PERFORCE_ACTION:
return P4GT_ResultsEnabled();
case CHECKED_OUT_PERFORCE_ACTION:
return P4GT_CheckedOutEnabled();
case INFO_PERFORCE_ACTION:
return P4GT_InfoEnabled();
case OPEN_DEPOT_PERFORCE_ACTION:
return P4GT_OpenEnabled();
}
return true;
}
BOOL PerforceActionCallBack::ExecuteAction( int id )
{
switch (id) {
case ADD_TO_PERFORCE_ACTION:
P4GT_Add();
return true;
case CHECK_OUT_PERFORCE_ACTION:
P4GT_Edit();
return true;
case CHECK_IN_PERFORCE_ACTION:
P4GT_Submit();
return true;
case LOCK_UNLOCK_PERFORCE_ACTION:
P4GT_ToggleLock();
return true;
case UNDO_ADD_CHECK_OUT_PERFORCE_ACTION:
P4GT_Revert();
return true;
case LAST_RESULTS_PERFORCE_ACTION:
P4GT_ShowLastResults();
return true;
case DOCUMENT_STATUS_PERFORCE_ACTION:
P4GT_ShowStatus();
return true;
case DOCUMENT_HISTORY_PERFORCE_ACTION:
P4GT_ShowHistory();
return true;
case CHECKED_OUT_PERFORCE_ACTION:
P4GT_ShowOpenFiles();
return true;
case INFO_PERFORCE_ACTION:
P4GT_ShowInfo();
return true;
case OPEN_DEPOT_PERFORCE_ACTION:
P4GT_ShowOpenDepot();
return true;
case OPTIONS_PERFORCE_ACTION:
P4GT_ShowOptions();
return true;
case HELP_PERFORCE_ACTION:
P4GT_ShowHelp();
return true;
case ABOUT_PERFORCE_ACTION:
P4GT_ShowAbout();
return true;
case SERVER_ONLINE_ACTION:
P4GT_ToggleOnline();
return true;
}
return false;
}