Skip to content

Commit d08ee37

Browse files
authored
Merge pull request #9 from fishca/features/add_constants
Fix constants display in metadata tree
2 parents 7dc4b70 + 31f4342 commit d08ee37

6 files changed

Lines changed: 147 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ __history/
6969
# RAD Studio user settings
7070
*.dproj.local
7171
*.cbproj.local
72+
Compile
7273

7374
# Deployment files
7475
*.deployproj

src/MainUnit.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "EventSubscriptions.h"
3838
#include "Roles.h"
3939
#include "CommonCommands.h"
40+
#include "TConstants.h"
4041
#include "CommonPictures.h"
4142
#include "CommandGroups.h"
4243
#include "CommonForms.h"
@@ -1556,6 +1557,19 @@ void __fastcall TMainForm::FillVirtualTree() {
15561557
{
15571558
FillTreeMD(parentNode, MainForm->mdCalculationRegisters, md_CalculationRegisters, category.imgIndex);
15581559
}
1560+
else if (category.name == md_Constants)
1561+
{
1562+
// Константы
1563+
for (int i = 0; i < MainForm->mdConstants->Count; i++)
1564+
{
1565+
PVirtualNode childNodeConst = VirtualStringTreeValue1C->AddChild(parentNode);
1566+
VirtualTreeData *childDataConst = (VirtualTreeData*)VirtualStringTreeValue1C->GetNodeData(childNodeConst);
1567+
TConstants* CurConstant = static_cast<TConstants*>(MainForm->mdConstants->Items[i]);
1568+
childDataConst->Name = CurConstant->name;
1569+
childDataConst->Age = 30;
1570+
childDataConst->ImgIndex = category.imgIndex;
1571+
}
1572+
}
15591573
else if (category.name == md_InformationRegisters)
15601574
{
15611575
FillTreeMD(parentNode, MainForm->mdInformationRegisters, md_InformationRegisters, category.imgIndex);
@@ -2996,7 +3010,10 @@ void fill_md(tree* tr, String guid_md, std::vector<String> &md_list)
29963010
else if (guid_md == GUID_WSReferences)
29973011
{}
29983012
else if (guid_md == GUID_Constants)
2999-
{}
3013+
{
3014+
TConstants* CurConstant = new TConstants(cf, curNode->get_value(), val);
3015+
MainForm->mdConstants->Add(CurConstant);
3016+
}
30003017
else if (guid_md == GUID_Documents)
30013018
{
30023019
TDocuments* CurDocuments = new TDocuments(cf, curNode->get_value(), val);
@@ -3183,7 +3200,7 @@ void get_cf_name(tree* tr, Messager* mess)
31833200

31843201
// константы
31853202
fill_md(tr, GUID_Constants, MainForm->Constants);
3186-
mess->AddMessage(L"Константы обработаны", MessageState::msInfo);
3203+
mess->AddMessage(L"Константы обработаны: " + IntToStr((int)MainForm->Constants.size()), MessageState::msInfo);
31873204

31883205
// обработки
31893206
fill_md(tr, GUID_DataProcessors, MainForm->DataProcessors);

src/MetaDataManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "Bots.h"
1313
#include "CommonAttributes.h"
1414
#include "CommonCommands.h"
15+
#include "TConstants.h"
1516
#include "CommandGroups.h"
1617
#include "CommonTemplates.h"
1718
#include "ExchangePlans.h"
@@ -723,3 +724,9 @@ vector<shared_ptr<TInterfaces>>& MetaDataManager::getInterfaces()
723724
{
724725
return Interfaces;
725726
}
727+
728+
// Метод для получения списка констант
729+
vector<shared_ptr<TConstants>>& MetaDataManager::getConstants()
730+
{
731+
return Constants;
732+
}

src/MetaDataManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Bots.h"
2525
#include "CommonAttributes.h"
2626
#include "CommonCommands.h"
27+
#include "TConstants.h"
2728
#include "CommonTemplates.h"
2829
#include "CommandGroups.h"
2930
#include "ExchangePlans.h"
@@ -47,6 +48,7 @@ class MetaDataManager {
4748
vector<shared_ptr<TBots>> Bots;
4849
vector<shared_ptr<TCommonAttributes>> CommonAttributes;
4950
vector<shared_ptr<TCommonCommands>> CommonCommands;
51+
vector<shared_ptr<TConstants>> Constants;
5052
vector<shared_ptr<TCommonTemplates>> CommonTemplates;
5153
vector<shared_ptr<TCommandGroups>> CommandGroups;
5254
vector<shared_ptr<TExchangePlans>> ExchangePlans;
@@ -68,6 +70,7 @@ class MetaDataManager {
6870
vector<shared_ptr<TBots>>& getBots();
6971
vector<shared_ptr<TCommonAttributes>>& getCommonAttributes();
7072
vector<shared_ptr<TCommonCommands>>& getCommonCommands();
73+
vector<shared_ptr<TConstants>>& getConstants();
7174
vector<shared_ptr<TCommonTemplates>>& getCommonTemplates();
7275
vector<shared_ptr<TCommandGroups>>& getCommandGroups();
7376
vector<shared_ptr<TExchangePlans>>& getExchangePlans();

src/TConstants.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//---------------------------------------------------------------------------
2+
3+
#pragma hdrstop
4+
5+
#include "TConstants.h"
6+
//---------------------------------------------------------------------------
7+
#pragma package(smart_init)
8+
9+
10+
__fastcall TConstants::TConstants() : BaseMetadataObject()
11+
{
12+
name = "";
13+
}
14+
15+
__fastcall TConstants::TConstants(v8catalog* _parent, const String& _guid) : BaseMetadataObject(_parent, _guid)
16+
{
17+
name = "";
18+
}
19+
20+
__fastcall TConstants::TConstants(v8catalog* _parent, const String& _guid, const String& _name) : BaseMetadataObject(_parent, _guid, _name)
21+
{
22+
name = _name;
23+
}
24+
25+
__fastcall TConstants::~TConstants()
26+
{
27+
}
28+
29+
String __fastcall TConstants::GetConstantsName()
30+
{
31+
return name;
32+
}
33+
34+
void __fastcall TConstants::SetConstantsName(String _name)
35+
{
36+
name = _name;
37+
}
38+
39+
std::vector<std::unique_ptr<TRequisite>>& TConstants::getAttributes()
40+
{
41+
return attributes;
42+
}
43+
44+
std::vector<std::unique_ptr<TComand>>& TConstants::getCommands()
45+
{
46+
return commands;
47+
}
48+
49+
std::vector<std::unique_ptr<TMoxel>>& TConstants::getLayouts()
50+
{
51+
return layouts;
52+
}
53+
54+
std::vector<std::unique_ptr<TTabular>>& TConstants::getTabularSections()
55+
{
56+
return tabularSections;
57+
}
58+
59+
std::vector<std::unique_ptr<TForm1C>>& TConstants::getForms()
60+
{
61+
return forms;
62+
}
63+
64+
void __fastcall TConstants::initializeFromTree()
65+
{
66+
// Инициализация константы из дерева метаданных
67+
// Имя константы уже установлено в конструкторе
68+
}

src/TConstants.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//---------------------------------------------------------------------------
2+
3+
#ifndef TConstantsH
4+
#define TConstantsH
5+
6+
#include "BaseMetadataObject.h"
7+
//---------------------------------------------------------------------------
8+
9+
/**
10+
* @class TConstants
11+
* @brief Класс для хранения констант (md_Constants)
12+
*
13+
* Константы - это объекты метаданных, которые содержат
14+
* постоянные значения, используемые в различных частях конфигурации.
15+
*/
16+
class TConstants : public BaseMetadataObject
17+
{
18+
private:
19+
// constantsName хранится в унаследованном поле name из BaseMetadataObject
20+
21+
public:
22+
__fastcall TConstants();
23+
__fastcall TConstants(v8catalog* _parent, const String& _guid);
24+
__fastcall TConstants(v8catalog* _parent, const String& _guid, const String& _name);
25+
virtual __fastcall ~TConstants();
26+
27+
// Методы для получения имени константы
28+
String __fastcall GetConstantsName();
29+
void __fastcall SetConstantsName(String _name);
30+
31+
// Реализация виртуальных методов BaseMetadataObject
32+
std::vector<std::unique_ptr<TRequisite>>& getAttributes() override;
33+
std::vector<std::unique_ptr<TComand>>& getCommands() override;
34+
std::vector<std::unique_ptr<TMoxel>>& getLayouts() override;
35+
std::vector<std::unique_ptr<TTabular>>& getTabularSections() override;
36+
std::vector<std::unique_ptr<TForm1C>>& getForms() override;
37+
38+
void __fastcall initializeFromTree() override;
39+
40+
private:
41+
// Внутренние хранилища для совместимости с интерфейсом
42+
std::vector<std::unique_ptr<TRequisite>> attributes;
43+
std::vector<std::unique_ptr<TComand>> commands;
44+
std::vector<std::unique_ptr<TMoxel>> layouts;
45+
std::vector<std::unique_ptr<TTabular>> tabularSections;
46+
std::vector<std::unique_ptr<TForm1C>> forms;
47+
};
48+
49+
#endif

0 commit comments

Comments
 (0)