GME  13
GMEBrowser.cpp
Go to the documentation of this file.
00001 // GMEBrowser.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "GMEApp.h"
00006 #include "GMEstd.h"
00007 #include "mainfrm.h"
00008 #include "GMEDoc.h"
00009 #include "GMEView.h"
00010 #include "GMEBrowser.h"
00011 #include "guimeta.h"
00012 
00013 #ifdef _DEBUG
00014 #define new DEBUG_NEW
00015 #undef THIS_FILE
00016 static char THIS_FILE[] = __FILE__;
00017 #endif
00018 
00019 
00020 
00021 #define MULTIPLE_OPEN_VIEW
00022 
00024 // CGMEBrowser dialog
00025 
00026 
00027 CGMEBrowser *CGMEBrowser::theInstance = 0;
00028 
00029 CGMEBrowser::CGMEBrowser(CWnd* /*pParent =NULL*/)
00030 {
00031         //{{AFX_DATA_INIT(CGMEBrowser)
00032         //}}AFX_DATA_INIT
00033         VERIFY(theInstance == 0);
00034         theInstance = this;
00035 }
00036 
00037 
00038 void CGMEBrowser::DoDataExchange(CDataExchange* pDX)
00039 {
00040         //{{AFX_DATA_MAP(CGMEBrowser)
00041         DDX_Control(pDX, IDC_GME_ACTIVE_BROWSER_CTRL, m_GMEActiveBrowser);
00042         //}}AFX_DATA_MAP
00043 }
00044 
00045 void CGMEBrowser::CloseProject()
00046 {
00047         m_GMEActiveBrowser.CloseCurrentProject();
00048 }
00049 
00050 bool CGMEBrowser::GetSelectedItems(CComPtr<IMgaObjects> &items)
00051 {
00052         LPUNKNOWN lpSelObjs = m_GMEActiveBrowser.GetSelectedMgaObjects();
00053         CComQIPtr<IMgaObjects> objs( lpSelObjs);
00054         long cnt = 0;
00055         if( objs) COMTHROW( objs->get_Count( &cnt));
00056         if( cnt > 0)
00057                 items = objs;
00058 
00059         return cnt > 0;
00060 }
00061 
00062 //#pragma warning ( disable : 4100 ) // Unreferenced formal param
00063 bool CGMEBrowser::GetSelectedItem(CComPtr<IMgaObject>&)
00064 {
00065         HRESULT hr = S_OK;
00066 
00067         return hr == S_OK;
00068 }
00069 //#pragma warning ( default : 4100 ) // Unreferenced formal param
00070 
00071 void CGMEBrowser::SetProject(CComPtr<IMgaProject>& mgaProject)
00072 {
00073         m_GMEActiveBrowser.SetCurrentProject(mgaProject);
00074 }
00075 
00076 void CGMEBrowser::RefreshAll()
00077 {
00078         m_GMEActiveBrowser.RefreshAll();
00079 }
00080 
00081 void CGMEBrowser::ShowObject(LPUNKNOWN selected) 
00082 {
00083         if (CGMEDoc::theInstance) {
00084                 CGMEDoc::theInstance->ShowObject(selected);
00085         }
00086 }
00087 
00088 void CGMEBrowser::ShowObjectInParent( LPUNKNOWN selected)
00089 {
00090         if (CGMEDoc::theInstance) {
00091                 CGMEDoc::theInstance->ShowObject(selected, true);
00092         }
00093 }
00094 
00095 void CGMEBrowser::ShowFindDlg()
00096 {
00097         if( CGMEDoc::theInstance && CMainFrame::theInstance)
00098                 CMainFrame::theInstance->ShowFindDlg();
00099 }
00100 
00101 void CGMEBrowser::ShowObjInsp()
00102 {
00103         if( CGMEDoc::theInstance && CMainFrame::theInstance && CGMEObjectInspector::theInstance)
00104         {
00105                 HWND hwnd = CGMEObjectInspector::theInstance->GetSafeHwnd();
00106                 if( hwnd) ::SetFocus( hwnd);
00107         }
00108 }
00109 
00110 void CGMEBrowser::CycleObjInsp( VARIANT_BOOL frwd)
00111 {
00112         if( CGMEObjectInspector::theInstance)
00113         {
00114                 CGMEObjectInspector::theInstance->CyclePanel( frwd);
00115         }
00116 }
00117 
00118 void CGMEBrowser::FocusItem(BSTR Id)
00119 {
00120         m_GMEActiveBrowser.FocusItem(Id);
00121 }
00122 
00123 BEGIN_MESSAGE_MAP(CGMEBrowser, CDockablePane)
00124         //{{AFX_MSG_MAP(CGMEBrowser)
00125         ON_WM_CREATE()
00126         ON_WM_SIZE()
00127         //}}AFX_MSG_MAP
00128 END_MESSAGE_MAP()
00129 
00131 // CGMEBrowser message handlers
00132 
00133 int CGMEBrowser::OnCreate(LPCREATESTRUCT lpCreateStruct) 
00134 {
00135         if (CDockablePane::OnCreate(lpCreateStruct) == -1)
00136                 return -1;
00137 
00138         if(!m_GMEActiveBrowser.Create(_T("ttt"),WS_CHILD | WS_VISIBLE,CRect(0,0,100,100),this,IDC_GME_ACTIVE_BROWSER_CTRL))
00139                 return -1;
00140 
00141 /*      m_szMin = CSize(200,200);
00142     m_szFloat = CSize(350,600); 
00143         m_szHorz = CSize(300,200);
00144     m_szVert = CSize(250,300);
00145 */      
00146         return 0;
00147 }
00148 
00149 void CGMEBrowser::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
00150 {
00151         CDockablePane::OnUpdateCmdUI(pTarget, bDisableIfNoHndler);
00152 
00153         UpdateDialogControls(pTarget, bDisableIfNoHndler);
00154 }
00155 
00156 
00157 void CGMEBrowser::OnSize(UINT nType, int cx, int cy) 
00158 {
00159         CDockablePane::OnSize(nType, cx, cy);
00160         
00161         CRect rc;
00162         GetClientRect(rc);      
00163         m_GMEActiveBrowser.MoveWindow(rc);
00164 }
00165 
00166 BEGIN_EVENTSINK_MAP(CGMEBrowser, CDockablePane)
00167     //{{AFX_EVENTSINK_MAP(CGMEBrowser)
00168         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 1 /* DblClickMgaObject */, OnDblClickMgaObjectGmeActiveBrowserCtrl, VTS_UNKNOWN)
00169         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 2 /* ShowAttributes */, OnShowAttributesGmeActiveBrowserCtrl, VTS_UNKNOWN)
00170         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 3 /* ShowPreferences */, OnShowPreferencesGmeActiveBrowserCtrl, VTS_UNKNOWN)
00171         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 4 /* ShowProperties */, OnShowPropertiesGmeActiveBrowserCtrl, VTS_NONE)
00172         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 5 /* ClickMgaObject */, OnClickMgaObjectGmeActiveBrowserCtrl, VTS_UNKNOWN)
00173         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 6 /* ShowInParentMgaObject */, OnShowInParentMgaObjectGmeActiveBrowserCtrl, VTS_UNKNOWN)
00174         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 7 /* RootFolderNameChanged */, OnRootFolderNameChangedGmeActiveBrowserCtrl, VTS_NONE)
00175         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 8 /* ShowFindDlg */, OnShowFindDlgGmeActiveBrowserCtrl, VTS_NONE)
00176         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 9 /* ShowObjInspDlg */, OnShowObjInspDlgGmeActiveBrowserCtrl, VTS_NONE)
00177         ON_EVENT(CGMEBrowser, IDC_GME_ACTIVE_BROWSER_CTRL, 10 /*CycleObjInsp*/ , OnCycleObjsInspGmeActiveBrowserCtrl, VTS_BOOL)
00178         //}}AFX_EVENTSINK_MAP
00179 END_EVENTSINK_MAP()
00180 
00181 void CGMEBrowser::OnDblClickMgaObjectActivebrowserCtlr1(LPUNKNOWN selected) 
00182 {
00183         ShowObject(selected);
00184 }
00185 
00186 void CGMEBrowser::OnCRonObjectActivebrowserCtlr1(LPUNKNOWN selected) 
00187 {
00188         ShowObject(selected);
00189 }
00190 
00191 BOOL CGMEBrowser::PreTranslateMessage(MSG* pMsg) 
00192 {
00193         if( pMsg->message == WM_KEYDOWN )
00194         {
00195                 switch(pMsg->wParam)
00196                 {
00197                         case VK_RETURN:
00198                         case VK_ESCAPE:
00199                         case VK_DELETE:
00200                         // Modification by Volgyesi (undo problems)
00201                         case VK_CONTROL:
00202                         case 'z':
00203                         case 'Z':
00204                         // Modification End
00205                         case VK_TAB:    // for JIRA GME-178
00206                                 ::TranslateMessage(pMsg);
00207                                 ::DispatchMessage(pMsg);
00208                                 return TRUE;
00209                 }
00210         }
00211 
00212         return CDockablePane::PreTranslateMessage(pMsg);
00213 }
00214 
00215 void CGMEBrowser::ShowAttrPref(bool isAttr, LPUNKNOWN selected) {
00216 
00217         CComPtr<IUnknown> sunk = selected;
00218 
00219         /* Converting single selection to multiple 
00220         CComPtr<IMgaObjects> ccpSelectedObjects;
00221         COMTHROW(ccpSelectedObjects.CoCreateInstance(L"Mga.MgaObjects"));
00222         CComPtr<IMgaObject>ccpMgaObject(fco);
00223         ccpSelectedObjects->Append(ccpMgaObject);
00224         CGMEObjectInspector::theInstance->SetFCOs(ccpSelectedObjects);
00225         */
00226 
00227         
00228         SetCurrObject(selected);
00229         CGMEObjectInspector::theInstance->ShowPanel(!isAttr);
00230 }
00231 
00232 void CGMEBrowser::SetCurrObject(LPUNKNOWN pMgaObject)
00233 {
00234         CComPtr<IUnknown> sunk = pMgaObject;
00235         LPUNKNOWN pUnknown=m_GMEActiveBrowser.GetSelectedMgaObjects();
00236         CComQIPtr<IMgaObjects> ccpSelectedObjects(pUnknown);
00237         pUnknown->Release();
00238         ASSERT(ccpSelectedObjects!=NULL);
00239 //      CComQIPtr<IMgaObjects> ccpSelectedObjects(pMgaObject);
00240         CGMEObjectInspector::theInstance->SetObjects(ccpSelectedObjects);
00241     CGMESearch::theInstance->SetSelMgaObjects(ccpSelectedObjects);
00242 }
00243 
00244 void CGMEBrowser::OnShowAttributesActivebrowserctrl1(LPUNKNOWN object) 
00245 {
00246         ShowAttrPref(true, object);
00247 }
00248 
00249 void CGMEBrowser::OnShowPreferencesActivebrowserctrl1(LPUNKNOWN object) 
00250 {
00251         ShowAttrPref(false, object);
00252 }
00253 
00254 void CGMEBrowser::OnDblClickMgaObjectGmeActiveBrowserCtrl(LPUNKNOWN pMgaObject) 
00255 {
00256         ShowObject(pMgaObject);
00257 //      ShowAttrPref(true, pMgaObject);
00258         
00259 }
00260 
00261 void CGMEBrowser::OnShowAttributesGmeActiveBrowserCtrl(LPUNKNOWN pMgaObject) 
00262 {
00263         ShowAttrPref(true, pMgaObject);
00264         
00265 }
00266 
00267 void CGMEBrowser::OnShowPreferencesGmeActiveBrowserCtrl(LPUNKNOWN pMgaObject) 
00268 {
00269         ShowAttrPref(false, pMgaObject);
00270 }
00271 
00272 void CGMEBrowser::OnShowPropertiesGmeActiveBrowserCtrl() 
00273 {
00274         
00275         LPUNKNOWN pUnknown=m_GMEActiveBrowser.GetSelectedMgaObjects();
00276         CComQIPtr<IMgaObjects> ccpSelectedObjects(pUnknown);
00277         pUnknown->Release();
00278         ASSERT(ccpSelectedObjects!=NULL);
00279         CGMEObjectInspector::theInstance->SetObjects(ccpSelectedObjects);
00280 
00281         CGMEObjectInspector::theInstance->ShowPanel(2);
00282         
00283 }
00284 
00285 void CGMEBrowser::OnClickMgaObjectGmeActiveBrowserCtrl(LPUNKNOWN pMgaObject) 
00286 {
00287         SetCurrObject(pMgaObject);
00288 }
00289 
00290 void CGMEBrowser::OnShowInParentMgaObjectGmeActiveBrowserCtrl(LPUNKNOWN pMgaObject) 
00291 {
00292         ShowObjectInParent(pMgaObject);
00293 }
00294 
00295 void CGMEBrowser::OnShowFindDlgGmeActiveBrowserCtrl()
00296 {
00297         ShowFindDlg();
00298 }
00299 
00300 void CGMEBrowser::OnShowObjInspDlgGmeActiveBrowserCtrl()
00301 {
00302         ShowObjInsp();
00303 }
00304 
00305 void CGMEBrowser::OnCycleObjsInspGmeActiveBrowserCtrl(VARIANT_BOOL frwd)
00306 {
00307         CycleObjInsp( frwd);
00308 }
00309 
00310 void CGMEBrowser::OnRootFolderNameChangedGmeActiveBrowserCtrl()
00311 {
00312         theApp.UpdateProjectName(true);
00313 }