00001
00002
00003
00004
00005
00006
00007
00008 #ifndef COMBINEDVIEWSMODULE_H
00009 #define COMBINEDVIEWSMODULE_H
00010
00011 #include "../TableDataSourceCombinedViews.h"
00012
00013 namespace Impala { namespace Application { namespace MediaTable {
00014
00015 class CombinedViewsModule : public TableDataSourceModule {
00016 public:
00017 CombinedViewsModule() : TableDataSourceModule("CombinedViews") {}
00018
00019 void ButtonSelectionEvent(OglGui::Button *src, void *userData)
00020 {
00021 if(src->GetLabel() == "Next")
00022 {
00023 NextSelected();
00024 } else if(src->GetLabel() == "New " + GetName())
00025 {
00026 NewSelected();
00027 }
00028 else
00029 TableDataSourceModule::ButtonSelectionEvent(src, userData);
00030 }
00031
00032 void NextSelected()
00033 {
00034 StoreConfigWindowValues();
00035 if(mStringValues["First view"] == mStringValues["Second view"])
00036 {
00037 SetErrorMessage(mConfigWindow,
00038 "First and second view can not be the same.");
00039 return;
00040 }
00041 ClearConfigWindowValues();
00042
00043 TableDataSourceModule::DrawConfigWindow();
00044 OglGui::GroupBox* grp = new OglGui::GroupBox(mConfigWindow, mConfigWindow->W()-2, 362, "");
00045
00046 AddTextField(grp, "Name");
00047
00048 AddSelectorWithColumnsOfType(grp, "First column", mStringValues["First view"],
00049 TableDataSource::TYPE_FLAG_ALL, true);
00050 AddSelectorWithColumnsOfType(grp, "Second column", mStringValues["Second view"],
00051 TableDataSource::TYPE_FLAG_ALL, true);
00052 (new OglGui::Button(grp, grp->W()-4, 26, "New "+GetName(), BEV_ETCHED))
00053 ->SetButtonListener(this);
00054
00055 grp->RepositionViewports();
00056 grp->ScaleChildren();
00057 }
00058
00059 void NewSelected() {
00060 StoreConfigWindowValues();
00061 if(mStringValues["Name"] == "")
00062 {
00063 SetErrorMessage(mConfigWindow, "Name can not be empty.");
00064 return;
00065 }
00066 DoHandleNewTableDataSource();
00067 delete mConfigWindow;
00068 DoReleaseConfigWindow();
00069 }
00070
00071 void ModuleSelected()
00072 {
00073 TableDataSourceModule::DrawConfigWindow();
00074 OglGui::GroupBox* grp = new OglGui::GroupBox(mConfigWindow, mConfigWindow->W()-2, 362, "");
00075
00076
00077 AddSelectorWithTableDataViews(grp, "First view");
00078 AddSelectorWithTableDataViews(grp, "Second view");
00079 (new OglGui::Button(grp, grp->W()-4, 26, "Next", BEV_ETCHED))
00080 ->SetButtonListener(this);
00081
00082 grp->RepositionViewports();
00083 grp->ScaleChildren();
00084 }
00085
00086 TableDataSource* NewTableDataSource()
00087 {
00088 TableDataSourceCombinedViews* source;
00089 source = new TableDataSourceCombinedViews();
00090 TableDataView* view1 = TableDataStore::GetInstance()
00091 ->GetTableDataView(mStringValues["First view"]);
00092 TableDataView* view2 = TableDataStore::GetInstance()
00093 ->GetTableDataView(mStringValues["Second view"]);
00094 source->AddTableDataView(view1, mStringValues["First column"]);
00095 source->AddTableDataView(view2, mStringValues["Second column"]);
00096 TableDataStore::GetInstance()->AddTableDataSource(mStringValues["Name"], source);
00097 return source;
00098 }
00099 };
00100
00101 } } }
00102
00103 #endif // COMBINEDVIEWSMODULE_H