toolbarstatefactory.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "toolbarstatefactory.h"
00012
00013 #include "toolbarstate.h"
00014 #include "toolbarstatepool.h"
00015 #include "toolbarstateother.h"
00016 #include "toolbarstatearrow.h"
00017 #include "toolbarstatemessages.h"
00018 #include "toolbarstateassociation.h"
00019
00020 #include "umlview.h"
00021
00022 ToolBarStateFactory::ToolBarStateFactory(UMLView *umlView)
00023 {
00024 m_pUMLView = umlView;
00025
00026 for (int i = 0; i < NR_OF_TOOLBAR_STATES; i++)
00027 {
00028 states[i] = NULL;
00029 }
00030 }
00031
00032 ToolBarStateFactory::~ToolBarStateFactory()
00033 {
00034 for (int i = 0; i < NR_OF_TOOLBAR_STATES; i++)
00035 {
00036 if (states[i] != NULL) delete states[i];
00037 }
00038 }
00039
00040
00041 ToolBarState* ToolBarStateFactory::getState(const WorkToolBar::ToolBar_Buttons &toolbarButton)
00042 {
00043 int key = getKey(toolbarButton);
00044
00045 if (states[key] == NULL)
00046 {
00047 switch (key)
00048 {
00049
00050
00051 case 0: states[0] = new ToolBarStateOther(m_pUMLView); break;
00052 case 1: states[1] = new ToolBarStateAssociation(m_pUMLView); break;
00053 case 2: states[2] = new ToolBarStateMessages(m_pUMLView); break;
00054
00055
00056 case 3: states[3] = new ToolBarStateArrow(m_pUMLView); break;
00057 }
00058 }
00059
00060
00061 if (key <= 2) ((ToolBarStatePool *) states[key])->setButton(toolbarButton);
00062
00063 return states[key];
00064 }
00065
00066
00067 int ToolBarStateFactory::getKey(const WorkToolBar::ToolBar_Buttons &toolbarButton) const
00068 {
00069 switch (toolbarButton)
00070 {
00071
00072 case WorkToolBar::tbb_Dependency: return 1;
00073 case WorkToolBar::tbb_Aggregation: return 1;
00074 case WorkToolBar::tbb_Relationship: return 1;
00075 case WorkToolBar::tbb_Generalization: return 1;
00076 case WorkToolBar::tbb_Association: return 1;
00077 case WorkToolBar::tbb_UniAssociation: return 1;
00078 case WorkToolBar::tbb_Composition: return 1;
00079 case WorkToolBar::tbb_Containment: return 1;
00080 case WorkToolBar::tbb_Anchor: return 1;
00081 case WorkToolBar::tbb_Coll_Message: return 1;
00082 case WorkToolBar::tbb_State_Transition: return 1;
00083 case WorkToolBar::tbb_Activity_Transition: return 1;
00084
00085
00086 case WorkToolBar::tbb_Seq_Message_Synchronous: return 2;
00087 case WorkToolBar::tbb_Seq_Message_Asynchronous: return 2;
00088
00089
00090 case WorkToolBar::tbb_Arrow: return 3;
00091
00092
00093 default: return 0;
00094 }
00095
00096 }
This file is part of the documentation for umbrello Version 3.1.0.