First version of the new GUI in development. You can enable this UI with "alieve...
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveFileDialog.cxx
CommitLineData
2e29a658 1#include <TGLabel.h>
2#include <TGComboBox.h>
3#include <TGButton.h>
4#include <TG3DLine.h>
5#include <TGTextEntry.h>
6#include <TMath.h>
7
8#include <TGFileDialog.h>
9
10#include "AliEveUtil.h"
11#include "AliEveFileDialog.h"
12
13ClassImp(AliEveFileDialog)
14
15AliEveFileDialog::AliEveFileDialog(const TGWindow* p,const TGWindow* main, EAliEveFileDialogMode mode)
16 : TGTransientFrame(p, main, 100,50, kVerticalFrame)
17
18{
19 SetCleanup(kDeepCleanup);
20
21 /************************
22 *** Local Files Frame ***
23 *************************/
24 //ESD Frame
25 fESDFilesFrame = new TGHorizontalFrame(this, 100, 100);
26 TGLabel* esdLabel = new TGLabel(fESDFilesFrame, "ESD File:");
27 esdLabel->Resize(110, esdLabel->GetDefaultHeight());
28 esdLabel->SetMargins(0,0,0,0);
29
30 fPathEntryESD= new TGTextEntry(fESDFilesFrame);
31 fPathEntryESD->Resize(250, fPathEntryESD->GetDefaultHeight());
32
33 TGTextButton* browseButtonESD = new TGTextButton(fESDFilesFrame, "Browse...");
34 browseButtonESD->Connect("Clicked()", "AliEveFileDialog", this, "onBrowseESDFile()");
35
36 fESDFilesFrame->AddFrame(esdLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 3, 3, 3));
37 fESDFilesFrame->AddFrame(fPathEntryESD, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
38 fESDFilesFrame->AddFrame(browseButtonESD, new TGLayoutHints(kLHintsNormal, 3, 3, 3, 3));
39
40 AddFrame(fESDFilesFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
41
42 //Advanced Options Frame
43 fAdvancedOptsFrame = new TGHorizontalFrame(this, 100, 100);
44 fAdvancedOptsButton = new TGCheckButton(fAdvancedOptsFrame, "Advanced Options");
45 fAdvancedOptsButton->Connect("Toggled(Bool_t)", "AliEveFileDialog", this, "showAdvancedOpts(Bool_t)");
46
47 fAdvancedOptsFrame->AddFrame(fAdvancedOptsButton, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
48
49 AddFrame(fAdvancedOptsFrame,new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
50
51 // AOD Frame
52 fAODFilesFrame = new TGHorizontalFrame(this, 100, 100);
53 TGLabel* aodLabel = new TGLabel(fAODFilesFrame, "AOD File:");
54 aodLabel->Resize(110, aodLabel->GetDefaultHeight());
55
56 fPathEntryAOD = new TGTextEntry(fAODFilesFrame);
57 fPathEntryAOD->Resize(250, fPathEntryAOD->GetDefaultHeight());
58
59 TGTextButton* browseButtonAOD = new TGTextButton(fAODFilesFrame, "Browse...");
60 browseButtonAOD->Connect("Clicked()", "AliEveFileDialog", this, "onBrowseAODFile()");
61
62 fAODFilesFrame->AddFrame(aodLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 3, 3, 3));
63 fAODFilesFrame->AddFrame(fPathEntryAOD, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
64 fAODFilesFrame->AddFrame(browseButtonAOD, new TGLayoutHints(kLHintsNormal, 3, 3, 3, 3));
65
66 AddFrame(fAODFilesFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
67
68 // AODfriend Frame
69 fAODfriendFilesFrame = new TGHorizontalFrame(this, 100, 100);
70 TGLabel* aodFriendLabel = new TGLabel(fAODfriendFilesFrame, "AODfriend File:");
71 aodFriendLabel->Resize(110, aodFriendLabel->GetDefaultHeight());
72
73 fPathEntryAODfriend = new TGTextEntry(fAODfriendFilesFrame);
74 fPathEntryAODfriend->Resize(250, fPathEntryAODfriend->GetDefaultHeight());
75
76 TGTextButton* browseButtonAODfriend = new TGTextButton(fAODfriendFilesFrame, "Browse...");
77 browseButtonAODfriend->Connect("Clicked()", "AliEveFileDialog", this, "onBrowseAODfriendFile()");
78
79 fAODfriendFilesFrame->AddFrame(aodFriendLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 3, 3, 3));
80 fAODfriendFilesFrame->AddFrame(fPathEntryAODfriend, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
81 fAODfriendFilesFrame->AddFrame(browseButtonAODfriend, new TGLayoutHints(kLHintsNormal, 3, 3, 3, 3));
82
83 AddFrame(fAODfriendFilesFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
84
85 // Raw Frame
86 fRawFilesFrame = new TGHorizontalFrame(this, 100, 100);
87 TGLabel* rawLabel = new TGLabel(fRawFilesFrame, "Raw File:");
88 rawLabel->Resize(110, rawLabel->GetDefaultHeight());
89
90 fPathEntryRawFile = new TGTextEntry(fRawFilesFrame);
91 fPathEntryRawFile->Resize(250, fPathEntryRawFile->GetDefaultHeight());
92
93 TGTextButton* browseButtonRawFile = new TGTextButton(fRawFilesFrame, "Browse...");
94 browseButtonRawFile->Connect("Clicked()", "AliEveFileDialog", this, "onBrowseRawFile()");
95
96 fRawFilesFrame->AddFrame(rawLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 3, 3, 3));
97 fRawFilesFrame->AddFrame(fPathEntryRawFile, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
98 fRawFilesFrame->AddFrame(browseButtonRawFile, new TGLayoutHints(kLHintsNormal, 3, 3, 3, 3));
99
100 AddFrame(fRawFilesFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
101
102
103 /****************
104 *** Url Frame ***
105 *****************/
106 fUrlFrame = new TGHorizontalFrame(this, 100, 100);
107 TGLabel* urlLabel = new TGLabel(fUrlFrame, "Url:");
108 urlLabel->Resize(110, urlLabel->GetDefaultHeight());
109
110 fPathEntryUrl= new TGTextEntry(fUrlFrame, "alien:///alice/");
111 fPathEntryUrl->Resize(250, fPathEntryUrl->GetDefaultHeight());
112
113 fUrlFrame->AddFrame(urlLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 3, 3, 3, 3));
114 fUrlFrame->AddFrame(fPathEntryUrl, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
115
116 AddFrame(fUrlFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3));
117
118 /****************
119 *** CDB Frame ***
120 *****************/
121 fCDBFrame = new TGHorizontalFrame(this, 100, 100);
122 TGLabel *cdbLabel = new TGLabel(fCDBFrame, "CDB Storage:");
123 fCDBPathCB = new TGComboBox(fCDBFrame);
124 fCDBPathCB->SetEditable(kFALSE);
125
126 fCDBPathCB->AddEntry("local", AliEveUtil::CDB_LOCAL);
127 fCDBPathCB->AddEntry("raw", AliEveUtil::CDB_RAW);
128 fCDBPathCB->AddEntry("mcideal", AliEveUtil::CDB_MCIDEAL);
129 fCDBPathCB->AddEntry("mcresidual", AliEveUtil::CDB_MCRESIDUAL);
130 fCDBPathCB->AddEntry("mcfull", AliEveUtil::CDB_MCFULL);
131
132 fCDBPathCB->Resize(100, fPathEntryESD->GetDefaultHeight());
133 fCDBPathCB->Select(0, kTRUE);
134
135 fCDBFrame->AddFrame(cdbLabel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 3, 3, 3) );
136 fCDBFrame->AddFrame(fCDBPathCB, new TGLayoutHints(kLHintsNormal | kLHintsCenterY, 3, 3, 3, 3) );
137
138 AddFrame(fCDBFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 3, 3, 3, 3) );
139
140 /***************************
141 *** Dialog Buttons Frame ***
142 ****************************/
143 fDialogButtonsFrame = new TGHorizontalFrame(this, 100, 100);
144
145 TGTextButton* okButton = new TGTextButton(fDialogButtonsFrame, "OK");
146 okButton->Associate(this);
147 okButton->Resize(50, okButton->GetDefaultHeight());
148 okButton->Connect("Clicked()", "AliEveFileDialog", this, "onAccept()");
149
150 TGTextButton* cancelButton = new TGTextButton(fDialogButtonsFrame, "Cancel");
151 okButton->Associate(this);
152 cancelButton->Connect("Clicked()", "AliEveFileDialog", this, "onReject()");
153 cancelButton->Resize(50, cancelButton->GetDefaultHeight());
154
155 fDialogButtonsFrame->AddFrame(new TGHorizontal3DLine, new TGLayoutHints(kLHintsExpandX, 3, 3, 3, 3));
156 fDialogButtonsFrame->AddFrame(okButton, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 3, 3, 3, 3));
157 fDialogButtonsFrame->AddFrame(cancelButton,new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 3, 3, 3, 3));
158
159 AddFrame(fDialogButtonsFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 3, 3, 3, 3) );
160
161 setMode(mode);
162
163 TGDimension size = GetDefaultSize();
164
165 Resize(size);
166 SetWindowName("Open File...");
167
168 Layout();
169 HideFrame(this);
170 UnmapWindow();
171}
172
173AliEveFileDialog::~AliEveFileDialog()
174{
175
176}
177
178const TString AliEveFileDialog::GetPathESD() const
179{
180 return TString(fPathEntryESD->GetText());
181}
182
183const TString AliEveFileDialog::GetPathAOD() const
184{
185 return TString(fPathEntryAOD->GetText());
186}
187
188const TString AliEveFileDialog::GetPathAODfriend() const
189{
190 return TString(fPathEntryAODfriend->GetText());
191}
192
193const TString AliEveFileDialog::GetPathRaw() const
194{
195 return TString(fPathEntryRawFile->GetText());
196}
197
198const TString AliEveFileDialog::GetUrl() const
199{
200 return TString(fPathEntryUrl->GetText());
201}
202
203const TString AliEveFileDialog::GetCDBStoragePath() const
204{
205 TString cdbSelected;
206
207 switch(fCDBPathCB->GetSelected()){
208 case AliEveUtil::CDB_LOCAL:
209 cdbSelected = "local://";
210 break;
211 case AliEveUtil::CDB_MCFULL:
212 cdbSelected = "mcfull://";
213 break;
214 case AliEveUtil::CDB_MCIDEAL:
215 cdbSelected = "mcideal://";
216 break;
217 case AliEveUtil::CDB_MCRESIDUAL:
218 cdbSelected = "mcresidual://";
219 break;
220 case AliEveUtil::CDB_RAW:
221 cdbSelected = "raw://";
222 break;
223 default:
224 cdbSelected= "local://";
225 }
226
227
228 return cdbSelected;
229}
230
231void AliEveFileDialog::onBrowseESDFile()
232{
233 TGFileInfo* fileInfo = new TGFileInfo;
234
235 const char* types[] = { "ALICE ESD file", "*.root",
236 "ROOT Archive", "*.zip",
237 0, 0};
238
239 fileInfo->fFileTypes = types;
240
241 new TGFileDialog(GetParent(), GetMain(), kFDOpen, fileInfo);
242
243 fPathEntryESD->SetText(fileInfo->fFilename);
244
245 delete fileInfo;
246
247}
248
249void AliEveFileDialog::onBrowseAODFile()
250{
251 TGFileInfo* fileInfo = new TGFileInfo;
252
253 const char* types[] = { "ALICE AOD file", "*.root",
254 "ROOT Archive", "*.zip",
255 0, 0};
256
257 fileInfo->fFileTypes = types;
258
259 new TGFileDialog(GetParent(), GetMain(), kFDOpen, fileInfo);
260
261 fPathEntryAOD->SetText(fileInfo->fFilename);
262
263 delete fileInfo;
264
265}
266
267void AliEveFileDialog::onBrowseAODfriendFile()
268{
269 TGFileInfo* fileInfo = new TGFileInfo;
270
271 const char* types[] = { "ALICE AODfriend file", "*.root",
272 "ROOT Archive", "*.zip",
273 0, 0};
274
275 fileInfo->fFileTypes = types;
276
277 new TGFileDialog(GetParent(), GetMain(), kFDOpen, fileInfo);
278
279 fPathEntryAODfriend->SetText(fileInfo->fFilename);
280
281 delete fileInfo;
282
283}
284
285void AliEveFileDialog::onBrowseRawFile()
286{
287 TGFileInfo* fileInfo = new TGFileInfo;
288
289 const char* types[] = { "ALICE RAW file", "*.root",
290 "ROOT Archive", "*.zip",
291 0, 0};
292
293 fileInfo->fFileTypes = types;
294
295 new TGFileDialog(GetParent(), GetMain(), kFDOpen, fileInfo);
296
297 fPathEntryRawFile->SetText(fileInfo->fFilename);
298
299 delete fileInfo;
300
301}
302
303void AliEveFileDialog::onAccept()
304{
305 fIsAccepted = kTRUE;
306 UnmapWindow();
307}
308
309void AliEveFileDialog::onReject()
310{
311 fIsAccepted = kFALSE;
312 UnmapWindow();
313}
314
315void AliEveFileDialog::setMode(EAliEveFileDialogMode mode)
316{
317 fMode = mode;
318}
319
320void AliEveFileDialog::MapWindow()
321{
322 if(IsMapped()) return;
323
324 MapSubwindows();
325 TGTransientFrame::MapWindow();
326 Layout();
327
328 gClient->WaitFor(this);
329}
330
331void AliEveFileDialog::UnmapWindow()
332{
333 TGTransientFrame::UnmapWindow();
334 gClient->ResetWaitFor(this);
335}
336
337void AliEveFileDialog::MapSubwindows()
338{
339 TGTransientFrame::MapSubwindows();
340
341 // Show/Hide Widgets according to the current Mode
342 if(fMode==kAliEveFDLocal){
343 ShowFrame(fESDFilesFrame);
344 showAdvancedOpts(fAdvancedOptsButton->IsDown());
345
346 HideFrame(fUrlFrame);
347 }
348 else{ // remote file
349 HideFrame(fESDFilesFrame);
350 HideFrame(fAdvancedOptsFrame);
351 HideFrame(fAODFilesFrame);
352 HideFrame(fAODfriendFilesFrame);
353 HideFrame(fRawFilesFrame);
354
355 ShowFrame(fUrlFrame);
356 }
357
358}
359
360void AliEveFileDialog::showAdvancedOpts(Bool_t shown)
361{
362 UInt_t w, h;
363 if(shown){
364 ShowFrame(fAODFilesFrame);
365 ShowFrame(fAODfriendFilesFrame);
366 ShowFrame(fRawFilesFrame);
367 Layout();
368
369 h = fESDFilesFrame->GetSize().fHeight+fAdvancedOptsFrame->GetSize().fHeight+fAODFilesFrame->GetSize().fHeight;
370 h+= fAODfriendFilesFrame->GetSize().fHeight+fRawFilesFrame->GetSize().fHeight+fCDBFrame->GetSize().fHeight+fDialogButtonsFrame->GetSize().fHeight;
371 }else{
372 HideFrame(fAODFilesFrame);
373 HideFrame(fAODfriendFilesFrame);
374 HideFrame(fRawFilesFrame);
375 Layout();
376
377 h = fESDFilesFrame->GetSize().fHeight+fAdvancedOptsFrame->GetSize().fHeight+fCDBFrame->GetSize().fHeight+fDialogButtonsFrame->GetSize().fHeight;
378 }
379
380 TGDimension size = GetSize();
381 w = size.fWidth;
382
383
384 Resize(w,h+40);
385
386}
387
388void AliEveFileDialog::CloseWindow()
389{
390 onReject();
391}