1 #include "UpdatePanel.h"
2 #include "FileManagerForm.h"
5 using namespace Tizen::Base;
6 using namespace Tizen::Graphics;
7 using namespace Tizen::Ui;
8 using namespace Tizen::Ui::Controls;
9 using namespace Tizen::Ui::Scenes;
12 UpdatePanel::UpdatePanel(void)
13 : __currentFeaturePath("")
14 , __currentImagePath("")
15 , __prevFeaturesCount(0)
19 UpdatePanel::~UpdatePanel(void)
24 UpdatePanel::Initialize()
26 Panel::Construct(L"IDC_UPDATE_MODE_PANEL");
31 UpdatePanel::OnInitializing(void)
35 Button *pButton = null;
36 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
37 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
39 Rectangle clienRect = pForm->GetClientAreaBounds();
40 this->SetBounds(clienRect);
42 pButton = static_cast<Button*>(GetControl(L"IDC_BUTTON_LOAD_FEATURE_SET", true));
45 pButton->SetActionId(ID_BUTTON_LOAD_FEATURE_SET);
46 pButton->AddActionEventListener(*this);
53 UpdatePanel::OnTerminating(void)
60 UpdatePanel::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
62 SceneManager* pSceneManager = SceneManager::GetInstance();
63 AppAssert(pSceneManager);
67 case ID_BUTTON_LOAD_FEATURE_SET:
69 pSceneManager->GoForward(
70 ForwardSceneTransition("ChooseExistingFeatureSetScene",
71 SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN,
72 SCENE_HISTORY_OPTION_ADD_HISTORY,
73 SCENE_DESTROY_OPTION_KEEP), 0);
81 UpdatePanel::OnSceneActivatedN(
82 const Tizen::Ui::Scenes::SceneId& previousSceneId,
83 const Tizen::Ui::Scenes::SceneId& currentSceneId,
84 Tizen::Base::Collection::IList* pArgs)
87 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
88 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
89 Footer* pFooter = pForm->GetFooter();
91 if ((previousSceneId == "ChooseImageScene") && pArgs)
93 if (pArgs->GetCount() > 0)
95 __currentImagePath = *(dynamic_cast<String*>(pArgs->GetAt(0)));
96 pForm->AppendImageFolder(__currentImagePath, this);
98 Footer* pFooter = pForm->GetFooter();
99 pFooter->SetItemEnabled(0, true);
102 else if ((previousSceneId == "ChooseExistingFeatureSetScene") && pArgs)
104 if (pArgs->GetCount() > 0)
106 __currentFeaturePath = *(dynamic_cast<String*>(pArgs->GetAt(0)));
107 if (E_SUCCESS != pForm->GetFeatureManager()->Load(__currentFeaturePath))
109 __currentFeaturePath = "";
113 __prevFeaturesCount = pForm->GetFeatureManager()->GetTotalNumberOfFeatures();
114 pFooter->SetItemEnabled(0, false);
118 else if (previousSceneId == "GenerationModeScene")
120 pForm->GetFeatureManager()->Load(__currentFeaturePath);
121 __prevFeaturesCount = pForm->GetFeatureManager()->GetTotalNumberOfFeatures();
122 pFooter->SetItemEnabled(0, false);
125 else if (previousSceneId == "ManageScene")
127 if (pForm->GetFeatureManager()->GetTotalNumberOfFeatures() != __prevFeaturesCount)
129 Footer* pFooter = pForm->GetFooter();
130 pFooter->SetItemEnabled(0, true);
136 pArgs->RemoveAll(true);
141 Label* pLabel = null;
142 pLabel = static_cast<Label*>(GetControl(L"IDC_FEATURE_SET_PATH_LABEL", true));
145 pLabel->SetText(__currentFeaturePath);
149 if (__currentFeaturePath.IsEmpty())
151 pFooter->SetItemEnabled(0, false);
152 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, false);
156 pFooter->SetButtonEnabled(BUTTON_POSITION_LEFT, true);
161 UpdatePanel::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
162 const Tizen::Ui::Scenes::SceneId& nextSceneId)
167 UpdatePanel::OnImageProcessed(int imNo, int total)
169 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
170 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
171 pForm->OnImageProcessed(imNo, total);
176 UpdatePanel::OnFinish(void)
178 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
179 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
181 __currentImagePath = "";
182 Button* pButtonPath = static_cast<Button*>(GetControl(L"IDC_BUTTON_UPDATE_IMAGE_FOLDER", true));
185 pButtonPath->SetText(__currentImagePath);
188 if (pForm->GetFeatureManager()->GetTotalNumberOfFeatures() != __prevFeaturesCount)
190 Footer* pFooter = pForm->GetFooter();
191 pFooter->SetItemEnabled(0, true);
198 UpdatePanel::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
200 SceneManager* pSceneManager = SceneManager::GetInstance();
201 AppAssert(pSceneManager);
205 case UpdatePanel::REQUEST_ADD:
207 pSceneManager->GoForward(
208 ForwardSceneTransition("ChooseImageScene",
209 SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN,
210 SCENE_HISTORY_OPTION_ADD_HISTORY,
211 SCENE_DESTROY_OPTION_KEEP), /*pList*/null);
214 case UpdatePanel::REQUEST_DELETE:
216 pSceneManager->GoForward(
217 ForwardSceneTransition("ManageScene",
218 SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_IN,
219 SCENE_HISTORY_OPTION_ADD_HISTORY,
220 SCENE_DESTROY_OPTION_KEEP), null);
223 case UpdatePanel::REQUEST_UPDATE:
225 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
226 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
228 //Disabling update button
229 Footer* pFooter = pForm->GetFooter();
230 pFooter->SetItemEnabled(0, false);
232 if (E_SUCCESS == pForm->GetFeatureManager()->Flush(0))
234 pForm->GetFeatureManager()->Load(__currentFeaturePath);
240 int currentFeaturesCount = pForm->GetFeatureManager()->GetTotalNumberOfFeatures();
242 if (__prevFeaturesCount > currentFeaturesCount)
244 message.Format(80, L"Feature set successfully updated.\nDeleted %i features.", __prevFeaturesCount - currentFeaturesCount);
248 message.Format(80, L"Feature set successfully updated.\nAdded %i features.", currentFeaturesCount - __prevFeaturesCount);
251 __prevFeaturesCount = currentFeaturesCount;
253 msgBox.Construct("Update", message, MSGBOX_STYLE_OK, 0);
254 msgBox.ShowAndWait(res);
262 msgBox.Construct("Update", "Feature set failed to update.", MSGBOX_STYLE_OK, 0);
263 msgBox.ShowAndWait(res);
265 pForm->GetFeatureManager()->Load(__currentFeaturePath);