PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/bouml_4.21/src/data/PackageData.cpp

#
C++ | 263 lines | 204 code | 27 blank | 32 comment | 27 complexity | a1c376c6ea53aebf3951cd1259327b28 MD5 | raw file
Possible License(s): GPL-2.0
  1. // *************************************************************************
  2. //
  3. // Copyright 2004-2010 Bruno PAGES .
  4. //
  5. // This file is part of the BOUML Uml Toolkit.
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. //
  21. // e-mail : bouml@free.fr
  22. // home : http://bouml.free.fr
  23. //
  24. // *************************************************************************
  25. #include <qcursor.h>
  26. #include "BrowserPackage.h"
  27. #include "PackageData.h"
  28. #include "PackageDialog.h"
  29. #include "myio.h"
  30. #include "ToolCom.h"
  31. #include "mu.h"
  32. PackageData::PackageData() {
  33. }
  34. PackageData::PackageData(PackageData * model)
  35. : SimpleData(model) {
  36. cpp_src_dir = model->cpp_src_dir;
  37. cpp_h_dir = model->cpp_h_dir;
  38. java_dir = model->java_dir;
  39. php_dir = model->php_dir;
  40. python_dir = model->python_dir;
  41. idl_dir = model->idl_dir;
  42. cpp_namespace = model->cpp_namespace;
  43. java_package = model->java_package;
  44. php_namespace = model->php_namespace;
  45. python_package = model->python_package;
  46. idl_module = model->idl_module;
  47. }
  48. PackageData::~PackageData() {
  49. }
  50. void PackageData::edit() {
  51. setName(browser_node->get_name());
  52. (new PackageDialog(this))->show();
  53. }
  54. //
  55. void PackageData::send_cpp_def(ToolCom * com) {
  56. com->write_string(cpp_src_dir);
  57. com->write_string(cpp_h_dir);
  58. com->write_string(cpp_namespace);
  59. }
  60. void PackageData::send_java_def(ToolCom * com) {
  61. com->write_string(java_dir);
  62. com->write_string(java_package);
  63. }
  64. void PackageData::send_php_def(ToolCom * com) {
  65. com->write_string(php_dir);
  66. //com->write_string(php_namespace);
  67. }
  68. void PackageData::send_python_def(ToolCom * com) {
  69. com->write_string(python_dir);
  70. com->write_string(python_package);
  71. }
  72. void PackageData::send_idl_def(ToolCom * com) {
  73. com->write_string(idl_dir);
  74. com->write_string(idl_module);
  75. }
  76. //
  77. bool PackageData::tool_cmd(ToolCom * com, const char * args,
  78. BrowserNode * bn,
  79. const QString & comment) {
  80. if (((unsigned char) args[-1]) >= firstSetCmd) {
  81. if (!bn->is_writable() && !root_permission())
  82. com->write_ack(FALSE);
  83. else {
  84. switch ((unsigned char) args[-1]) {
  85. case setCppSrcDirCmd:
  86. cpp_src_dir = args;
  87. break;
  88. case setCppHDirCmd:
  89. cpp_h_dir = args;
  90. break;
  91. case setCppNamespaceCmd:
  92. cpp_namespace = args;
  93. break;
  94. case setJavaDirCmd:
  95. java_dir = args;
  96. break;
  97. case setJavaPackageCmd:
  98. java_package = args;
  99. break;
  100. case setPhpDirCmd:
  101. php_dir = args;
  102. break;
  103. //case setPhpNamespaceCmd:
  104. //php_namespace = args;
  105. //break;
  106. case setPythonDirCmd:
  107. python_dir = args;
  108. break;
  109. case setPythonPackageCmd:
  110. python_package = args;
  111. break;
  112. case setIdlDirCmd:
  113. idl_dir = args;
  114. break;
  115. case setIdlModuleCmd:
  116. idl_module = args;
  117. break;
  118. default:
  119. return BasicData::tool_cmd(com, args, bn, comment);
  120. }
  121. // ok case
  122. bn->package_modified();
  123. modified();
  124. com->write_ack(TRUE);
  125. }
  126. }
  127. else
  128. return BasicData::tool_cmd(com, args, bn, comment);
  129. return TRUE;
  130. }
  131. //
  132. void PackageData::save(QTextStream & st, QString & warning) const {
  133. BasicData::save(st, warning);
  134. if (!cpp_h_dir.isEmpty()) {
  135. nl_indent(st);
  136. st << "cpp_h_dir ";
  137. save_string(cpp_h_dir, st);
  138. }
  139. if (!cpp_src_dir.isEmpty()) {
  140. nl_indent(st);
  141. st << "cpp_src_dir ";
  142. save_string(cpp_src_dir, st);
  143. }
  144. if (!cpp_namespace.isEmpty()) {
  145. nl_indent(st);
  146. st << "cpp_namespace ";
  147. save_string(cpp_namespace, st);
  148. }
  149. if (!java_dir.isEmpty()) {
  150. nl_indent(st);
  151. st << "java_dir ";
  152. save_string(java_dir, st);
  153. }
  154. if (!java_package.isEmpty()) {
  155. nl_indent(st);
  156. st << "java_package ";
  157. save_string(java_package, st);
  158. }
  159. if (!php_dir.isEmpty()) {
  160. nl_indent(st);
  161. st << "php_dir ";
  162. save_string(php_dir, st);
  163. }
  164. if (!php_namespace.isEmpty()) {
  165. nl_indent(st);
  166. st << "php_namespace ";
  167. save_string(php_namespace, st);
  168. }
  169. if (!python_dir.isEmpty()) {
  170. nl_indent(st);
  171. st << "python_dir ";
  172. save_string(python_dir, st);
  173. }
  174. if (!python_package.isEmpty()) {
  175. nl_indent(st);
  176. st << "python_package ";
  177. save_string(python_package, st);
  178. }
  179. if (!idl_dir.isEmpty()) {
  180. nl_indent(st);
  181. st << "idl_dir ";
  182. save_string(idl_dir, st);
  183. }
  184. if (!idl_module.isEmpty()) {
  185. nl_indent(st);
  186. st << "idl_module ";
  187. save_string(idl_module, st);
  188. }
  189. }
  190. void PackageData::read(char * & st, char * & k) {
  191. BasicData::read(st, k); // updates k
  192. if (!strcmp(k, "cpp_h_dir")) {
  193. cpp_h_dir = read_string(st);
  194. k = read_keyword(st);
  195. }
  196. if (!strcmp(k, "cpp_src_dir")) {
  197. cpp_src_dir = read_string(st);
  198. k = read_keyword(st);
  199. }
  200. if (!strcmp(k, "cpp_namespace")) {
  201. cpp_namespace = read_string(st);
  202. k = read_keyword(st);
  203. }
  204. if (!strcmp(k, "java_dir")) {
  205. java_dir = read_string(st);
  206. k = read_keyword(st);
  207. }
  208. if (!strcmp(k, "java_package")) {
  209. java_package = read_string(st);
  210. k = read_keyword(st);
  211. }
  212. if (!strcmp(k, "php_dir")) {
  213. php_dir = read_string(st);
  214. k = read_keyword(st);
  215. }
  216. if (!strcmp(k, "php_namespace")) {
  217. php_namespace = read_string(st);
  218. k = read_keyword(st);
  219. }
  220. if (!strcmp(k, "python_dir")) {
  221. python_dir = read_string(st);
  222. k = read_keyword(st);
  223. }
  224. if (!strcmp(k, "python_package")) {
  225. python_package = read_string(st);
  226. k = read_keyword(st);
  227. }
  228. if (!strcmp(k, "idl_dir")) {
  229. idl_dir = read_string(st);
  230. k = read_keyword(st);
  231. }
  232. if (!strcmp(k, "idl_module")) {
  233. idl_module = read_string(st);
  234. k = read_keyword(st);
  235. }
  236. }